[gtk-vnc] Death to tabs



commit 941e91b45bc3de70422a400b000c37025e10a758
Author: Daniel P. Berrange <berrange redhat com>
Date:   Fri Dec 9 16:56:13 2011 +0000

    Death to tabs
    
    Remove all tabs, change indentation level to 4 spaces. Add
    emacs magic to files which were missing it. Reindent all
    files with new rules

 examples/gvncviewer.c       | 1028 +++---
 plugin/gtk-vnc-plugin.c     |  413 ++--
 plugin/gtk-vnc-plugin.h     |   37 +-
 plugin/npapi.h              |  234 +-
 plugin/npshell.c            |  142 +-
 plugin/npunix.c             |   48 +-
 plugin/npupp.h              |  596 ++--
 src/continuation.c          |   64 +-
 src/continuation.h          |   28 +-
 src/coroutine.h             |   28 +-
 src/coroutine_gthread.c     |  196 +-
 src/coroutine_ucontext.c    |  118 +-
 src/d3des.c                 | 1078 +++---
 src/d3des.h                 |   84 +-
 src/dh.c                    |  122 +-
 src/dh.h                    |    7 +
 src/gtk-vnc.h               |    7 +
 src/gvnc.h                  |    7 +
 src/gvncpulse.h             |    7 +
 src/vncaudio.c              |   30 +-
 src/vncaudio.h              |   18 +-
 src/vncaudioformat.c        |   36 +-
 src/vncaudioformat.h        |   24 +-
 src/vncaudiopulse.c         |  160 +-
 src/vncaudiopulse.h         |   12 +-
 src/vncaudiosample.c        |   48 +-
 src/vncaudiosample.h        |   12 +-
 src/vncbaseaudio.c          |  106 +-
 src/vncbaseaudio.h          |   18 +-
 src/vncbaseframebuffer.c    | 1156 ++++----
 src/vncbaseframebuffer.h    |   34 +-
 src/vncbaseframebufferblt.h |  220 +-
 src/vnccairoframebuffer.c   |  184 +-
 src/vnccairoframebuffer.h   |   26 +-
 src/vnccolormap.c           |   88 +-
 src/vnccolormap.h           |   38 +-
 src/vncconnection.c         | 7754 +++++++++++++++++++++---------------------
 src/vncconnection.h         |  194 +-
 src/vncconnectionblt.h      |  160 +-
 src/vnccursor.c             |  336 +-
 src/vnccursor.h             |   28 +-
 src/vncdisplay.c            | 3446 ++++++++++----------
 src/vncdisplay.h            |  142 +-
 src/vncdisplaykeymap.c      |  254 +-
 src/vncdisplaykeymap.h      |   11 +-
 src/vncframebuffer.c        |   84 +-
 src/vncframebuffer.h        |  110 +-
 src/vncgrabsequence.c       |   92 +-
 src/vncgrabsequence.h       |   12 +-
 src/vncimageframebuffer.c   |  264 +-
 src/vncimageframebuffer.h   |   26 +-
 src/vncmodule.c             |   11 +-
 src/vncpixelformat.c        |   36 +-
 src/vncpixelformat.h        |   28 +-
 src/vncutil.c               |   26 +-
 src/vncutil.h               |   16 +-
 tools/gvnccapture.c         |  832 +++---
 57 files changed, 10193 insertions(+), 10123 deletions(-)
---
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 607cdfa..7e2b937 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -84,12 +84,12 @@
 
 static gchar **args = NULL;
 static const GOptionEntry options [] =
-{
-	{
-		G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
-		NULL, "[hostname][:display]" },
-	{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
-};
+    {
+        {
+            G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
+            NULL, "[hostname][:display]" },
+        { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
+    };
 
 #ifdef HAVE_PULSEAUDIO
 static VncAudioPulse *pa = NULL;
@@ -98,679 +98,679 @@ static VncAudioPulse *pa = NULL;
 static GtkWidget *vnc;
 
 typedef struct {
-	GtkWidget *label;
-	guint curkeys;
-	guint numkeys;
-	guint *keysyms;
-	gboolean set;
+    GtkWidget *label;
+    guint curkeys;
+    guint numkeys;
+    guint *keysyms;
+    gboolean set;
 } VncGrabDefs;
 
 static void set_title(VncDisplay *vncdisplay, GtkWidget *window,
-	gboolean grabbed)
+                      gboolean grabbed)
 {
-	const gchar *name = vnc_display_get_name(VNC_DISPLAY(vncdisplay));
-	VncGrabSequence *seq = vnc_display_get_grab_keys(vncdisplay);
-	gchar *seqstr = vnc_grab_sequence_as_string(seq);
-	gchar *title;
-
-	if (grabbed)
-		title = g_strdup_printf("(Press %s to release pointer) %s - GVncViewer",
-					seqstr, name);
-	else
-		title = g_strdup_printf("%s - GVncViewer",
-					name);
-
-	gtk_window_set_title(GTK_WINDOW(window), title);
-
-	g_free(seqstr);
-	g_free(title);
+    const gchar *name = vnc_display_get_name(VNC_DISPLAY(vncdisplay));
+    VncGrabSequence *seq = vnc_display_get_grab_keys(vncdisplay);
+    gchar *seqstr = vnc_grab_sequence_as_string(seq);
+    gchar *title;
+
+    if (grabbed)
+        title = g_strdup_printf("(Press %s to release pointer) %s - GVncViewer",
+                                seqstr, name);
+    else
+        title = g_strdup_printf("%s - GVncViewer",
+                                name);
+
+    gtk_window_set_title(GTK_WINDOW(window), title);
+
+    g_free(seqstr);
+    g_free(title);
 }
 
 static gboolean vnc_screenshot(GtkWidget *window G_GNUC_UNUSED,
-	GdkEvent *ev, GtkWidget *vncdisplay)
+                               GdkEvent *ev, GtkWidget *vncdisplay)
 {
-	if (ev->key.keyval == GDK_F11) {
-		GdkPixbuf *pix = vnc_display_get_pixbuf(VNC_DISPLAY(vncdisplay));
-		gdk_pixbuf_save(pix, "gvncviewer.png", "png", NULL, "tEXt::Generator App", "gvncviewer", NULL);
-		g_object_unref(pix);
-		printf("Screenshot saved to gvncviewer.png\n");
-	}
-	return FALSE;
+    if (ev->key.keyval == GDK_F11) {
+        GdkPixbuf *pix = vnc_display_get_pixbuf(VNC_DISPLAY(vncdisplay));
+        gdk_pixbuf_save(pix, "gvncviewer.png", "png", NULL, "tEXt::Generator App", "gvncviewer", NULL);
+        g_object_unref(pix);
+        printf("Screenshot saved to gvncviewer.png\n");
+    }
+    return FALSE;
 }
 
 static void vnc_grab(GtkWidget *vncdisplay, GtkWidget *window)
 {
-	set_title(VNC_DISPLAY(vncdisplay), window, TRUE);
+    set_title(VNC_DISPLAY(vncdisplay), window, TRUE);
 }
 
 static void vnc_ungrab(GtkWidget *vncdisplay, GtkWidget *window)
 {
-	set_title(VNC_DISPLAY(vncdisplay), window, FALSE);
+    set_title(VNC_DISPLAY(vncdisplay), window, FALSE);
 }
 
 static int connected = 0;
 
 static void vnc_connected(GtkWidget *vncdisplay G_GNUC_UNUSED)
 {
-	printf("Connected to server\n");
-	connected = 1;
+    printf("Connected to server\n");
+    connected = 1;
 }
 
 static void vnc_initialized(GtkWidget *vncdisplay, GtkWidget *window)
 {
-	printf("Connection initialized\n");
-	set_title(VNC_DISPLAY(vncdisplay), window, FALSE);
-	gtk_widget_show_all(window);
+    printf("Connection initialized\n");
+    set_title(VNC_DISPLAY(vncdisplay), window, FALSE);
+    gtk_widget_show_all(window);
 
 #ifdef HAVE_PULSEAUDIO
-	VncConnection *conn;
-	VncAudioFormat format = {
-		VNC_AUDIO_FORMAT_RAW_S32,
-		2,
-		44100,
-	};
-	conn = vnc_display_get_connection(VNC_DISPLAY(vncdisplay));
-	vnc_connection_set_audio_format(conn, &format);
-	vnc_connection_set_audio(conn, VNC_AUDIO(pa));
-	vnc_connection_audio_enable(conn);
+    VncConnection *conn;
+    VncAudioFormat format = {
+        VNC_AUDIO_FORMAT_RAW_S32,
+        2,
+        44100,
+    };
+    conn = vnc_display_get_connection(VNC_DISPLAY(vncdisplay));
+    vnc_connection_set_audio_format(conn, &format);
+    vnc_connection_set_audio(conn, VNC_AUDIO(pa));
+    vnc_connection_audio_enable(conn);
 #endif
 }
 
 static void vnc_auth_failure(GtkWidget *vncdisplay G_GNUC_UNUSED,
-	const char *msg)
+                             const char *msg)
 {
-	printf("Authentication failed '%s'\n", msg ? msg : "");
+    printf("Authentication failed '%s'\n", msg ? msg : "");
 }
 
 static void vnc_desktop_resize(GtkWidget *vncdisplay G_GNUC_UNUSED,
-	int width, int height)
+                               int width, int height)
 {
-	printf("Remote desktop size changed to %dx%d\n", width, height);
+    printf("Remote desktop size changed to %dx%d\n", width, height);
 }
 
 static void vnc_disconnected(GtkWidget *vncdisplay G_GNUC_UNUSED)
 {
-	if(connected)
-		printf("Disconnected from server\n");
-	else
-		printf("Failed to connect to server\n");
-	gtk_main_quit();
+    if(connected)
+        printf("Disconnected from server\n");
+    else
+        printf("Failed to connect to server\n");
+    gtk_main_quit();
 }
 
 static void send_caf1(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F1 };
-	printf("Sending Ctrl+Alt+F1\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F1 };
+    printf("Sending Ctrl+Alt+F1\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_caf2(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F2 };
-	printf("Sending Ctrl+Alt+F2\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F2 };
+    printf("Sending Ctrl+Alt+F2\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_caf3(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F3 };
-	printf("Sending Ctrl+Alt+F3\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F3 };
+    printf("Sending Ctrl+Alt+F3\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_caf4(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F4 };
-	printf("Sending Ctrl+Alt+F4\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F4 };
+    printf("Sending Ctrl+Alt+F4\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_caf5(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F5 };
-	printf("Sending Ctrl+Alt+F5\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F5 };
+    printf("Sending Ctrl+Alt+F5\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_caf6(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F6 };
-	printf("Sending Ctrl+Alt+F6\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F6 };
+    printf("Sending Ctrl+Alt+F6\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_caf7(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F7 };
-	printf("Sending Ctrl+Alt+F7\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F7 };
+    printf("Sending Ctrl+Alt+F7\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_caf8(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F8 };
-	printf("Sending Ctrl+Alt+F8\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_F8 };
+    printf("Sending Ctrl+Alt+F8\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_cad(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_Delete };
-	printf("Sending Ctrl+Alt+Delete\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_Delete };
+    printf("Sending Ctrl+Alt+Delete\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void send_cab(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *vncdisplay)
 {
-	guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_BackSpace };
-	printf("Sending Ctrl+Alt+Backspace\n");
-	vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
-		sizeof(keys)/sizeof(keys[0]));
+    guint keys[] = { GDK_Control_L, GDK_Alt_L, GDK_BackSpace };
+    printf("Sending Ctrl+Alt+Backspace\n");
+    vnc_display_send_keys(VNC_DISPLAY(vncdisplay), keys,
+                          sizeof(keys)/sizeof(keys[0]));
 }
 
 static void do_fullscreen(GtkWidget *menu, GtkWidget *window)
 {
-	if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
-		gtk_window_fullscreen(GTK_WINDOW(window));
-	else
-		gtk_window_unfullscreen(GTK_WINDOW(window));
+    if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
+        gtk_window_fullscreen(GTK_WINDOW(window));
+    else
+        gtk_window_unfullscreen(GTK_WINDOW(window));
 }
 
 static void do_scaling(GtkWidget *menu, GtkWidget *vncdisplay)
 {
-	if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
-		vnc_display_set_scaling(VNC_DISPLAY(vncdisplay), TRUE);
-	else
-		vnc_display_set_scaling(VNC_DISPLAY(vncdisplay), FALSE);
+    if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
+        vnc_display_set_scaling(VNC_DISPLAY(vncdisplay), TRUE);
+    else
+        vnc_display_set_scaling(VNC_DISPLAY(vncdisplay), FALSE);
 }
 
 static void dialog_update_keysyms(GtkWidget *window, guint *keysyms, guint numsyms)
 {
-	gchar *keys;
-	int i;
+    gchar *keys;
+    int i;
 
-	keys = g_strdup("");
-	for (i = 0; i < numsyms; i++)
-	{
-		keys = g_strdup_printf("%s%s%s", keys,
-			(strlen(keys) > 0) ? "+" : " ", gdk_keyval_name(keysyms[i]));
-	}
+    keys = g_strdup("");
+    for (i = 0; i < numsyms; i++)
+        {
+            keys = g_strdup_printf("%s%s%s", keys,
+                                   (strlen(keys) > 0) ? "+" : " ", gdk_keyval_name(keysyms[i]));
+        }
 
-	gtk_label_set_text( GTK_LABEL(window), keys);
+    gtk_label_set_text( GTK_LABEL(window), keys);
 }
 
 static gboolean dialog_key_ignore(int keyval)
 {
-	switch (keyval) {
-		case GDK_Return:
-		case GDK_Escape:
-			return TRUE;
-	}
+    switch (keyval) {
+    case GDK_Return:
+    case GDK_Escape:
+        return TRUE;
+    }
 
-	return FALSE;
+    return FALSE;
 }
 
 static gboolean dialog_key_press(GtkWidget *window G_GNUC_UNUSED,
-        GdkEvent *ev, VncGrabDefs *defs)
+                                 GdkEvent *ev, VncGrabDefs *defs)
 {
-	gboolean keySymExists;
-	int i;
+    gboolean keySymExists;
+    int i;
 
-	if (dialog_key_ignore(ev->key.keyval))
-		return FALSE;
+    if (dialog_key_ignore(ev->key.keyval))
+        return FALSE;
 
-	if (defs->set && defs->curkeys)
-		return FALSE;
+    if (defs->set && defs->curkeys)
+        return FALSE;
 
-	/* Check whether we already have keysym in array - i.e. it was handler by something else */
-	keySymExists = FALSE;
-	for (i = 0; i < defs->curkeys; i++) {
-		if (defs->keysyms[i] == ev->key.keyval)
-			keySymExists = TRUE;
-	}
+    /* Check whether we already have keysym in array - i.e. it was handler by something else */
+    keySymExists = FALSE;
+    for (i = 0; i < defs->curkeys; i++) {
+        if (defs->keysyms[i] == ev->key.keyval)
+            keySymExists = TRUE;
+    }
 
-	if (!keySymExists) {
-		defs->keysyms = g_renew(guint, defs->keysyms, defs->curkeys + 1);
-		defs->keysyms[defs->curkeys] = ev->key.keyval;
-		defs->curkeys++;
-	}
+    if (!keySymExists) {
+        defs->keysyms = g_renew(guint, defs->keysyms, defs->curkeys + 1);
+        defs->keysyms[defs->curkeys] = ev->key.keyval;
+        defs->curkeys++;
+    }
 
-	dialog_update_keysyms(defs->label, defs->keysyms, defs->curkeys);
+    dialog_update_keysyms(defs->label, defs->keysyms, defs->curkeys);
 
-	if (!ev->key.is_modifier) {
-		defs->set = TRUE;
-		defs->numkeys = defs->curkeys;
-		defs->curkeys--;
-	}
+    if (!ev->key.is_modifier) {
+        defs->set = TRUE;
+        defs->numkeys = defs->curkeys;
+        defs->curkeys--;
+    }
 
-	return FALSE;
+    return FALSE;
 }
 
 static gboolean dialog_key_release(GtkWidget *window G_GNUC_UNUSED,
-        GdkEvent *ev, VncGrabDefs *defs)
+                                   GdkEvent *ev, VncGrabDefs *defs)
 {
-	int i;
-
-	if (dialog_key_ignore(ev->key.keyval))
-		return FALSE;
-
-	if (defs->set) {
-		if (defs->curkeys == 0)
-			defs->set = FALSE;
-		if (defs->curkeys)
-			defs->curkeys--;
-		return FALSE;
-	}
-
-	for (i = 0; i < defs->curkeys; i++)
-	{
-		if (defs->keysyms[i] == ev->key.keyval)
-		{
-			defs->keysyms[i] = defs->keysyms[defs->curkeys - 1];
-			defs->curkeys--;
-			defs->keysyms = g_renew(guint, defs->keysyms, defs->curkeys);
-		}
-	}
-
-	dialog_update_keysyms(defs->label, defs->keysyms, defs->curkeys);
-
-	return FALSE;
+    int i;
+
+    if (dialog_key_ignore(ev->key.keyval))
+        return FALSE;
+
+    if (defs->set) {
+        if (defs->curkeys == 0)
+            defs->set = FALSE;
+        if (defs->curkeys)
+            defs->curkeys--;
+        return FALSE;
+    }
+
+    for (i = 0; i < defs->curkeys; i++)
+        {
+            if (defs->keysyms[i] == ev->key.keyval)
+                {
+                    defs->keysyms[i] = defs->keysyms[defs->curkeys - 1];
+                    defs->curkeys--;
+                    defs->keysyms = g_renew(guint, defs->keysyms, defs->curkeys);
+                }
+        }
+
+    dialog_update_keysyms(defs->label, defs->keysyms, defs->curkeys);
+
+    return FALSE;
 }
 
 static void do_set_grab_keys(GtkWidget *menu G_GNUC_UNUSED, GtkWidget *window)
 {
-	VncGrabDefs *defs;
-	VncGrabSequence *seq;
-	GtkWidget *dialog, *content_area, *label;
-	gint result;
-
-	dialog = gtk_dialog_new_with_buttons ("Key recorder",
-						GTK_WINDOW(window),
-						GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-						GTK_STOCK_OK,
-						GTK_RESPONSE_ACCEPT,
-						GTK_STOCK_CANCEL,
-						GTK_RESPONSE_REJECT,
-						NULL);
-
-	label = gtk_label_new("Please press desired grab key combination");
-	defs = g_new(VncGrabDefs, 1);
-	defs->label = label;
-	defs->keysyms = 0;
-	defs->numkeys = 0;
-	defs->curkeys = 0;
-	defs->set = FALSE;
-	g_signal_connect(dialog, "key-press-event",
-			G_CALLBACK(dialog_key_press), defs);
-	g_signal_connect(dialog, "key-release-event",
-			G_CALLBACK(dialog_key_release), defs);
-	gtk_widget_set_size_request(dialog, 300, 100);
-	content_area = gtk_dialog_get_content_area( GTK_DIALOG(dialog) );
-	gtk_container_add( GTK_CONTAINER(content_area), label);
-	gtk_widget_show_all(dialog);
-
-	result = gtk_dialog_run(GTK_DIALOG(dialog));
-	if (result == GTK_RESPONSE_ACCEPT) {
-		/* Accepted so we make a grab sequence from it */
-		seq = vnc_grab_sequence_new(defs->numkeys,
-					    defs->keysyms);
-
-		vnc_display_set_grab_keys(VNC_DISPLAY(vnc), seq);
-		set_title(VNC_DISPLAY(vnc), window, FALSE);
-		vnc_grab_sequence_free(seq);
-	}
-	g_free(defs);
-	gtk_widget_destroy(dialog);
+    VncGrabDefs *defs;
+    VncGrabSequence *seq;
+    GtkWidget *dialog, *content_area, *label;
+    gint result;
+
+    dialog = gtk_dialog_new_with_buttons ("Key recorder",
+                                          GTK_WINDOW(window),
+                                          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          GTK_STOCK_OK,
+                                          GTK_RESPONSE_ACCEPT,
+                                          GTK_STOCK_CANCEL,
+                                          GTK_RESPONSE_REJECT,
+                                          NULL);
+
+    label = gtk_label_new("Please press desired grab key combination");
+    defs = g_new(VncGrabDefs, 1);
+    defs->label = label;
+    defs->keysyms = 0;
+    defs->numkeys = 0;
+    defs->curkeys = 0;
+    defs->set = FALSE;
+    g_signal_connect(dialog, "key-press-event",
+                     G_CALLBACK(dialog_key_press), defs);
+    g_signal_connect(dialog, "key-release-event",
+                     G_CALLBACK(dialog_key_release), defs);
+    gtk_widget_set_size_request(dialog, 300, 100);
+    content_area = gtk_dialog_get_content_area( GTK_DIALOG(dialog) );
+    gtk_container_add( GTK_CONTAINER(content_area), label);
+    gtk_widget_show_all(dialog);
+
+    result = gtk_dialog_run(GTK_DIALOG(dialog));
+    if (result == GTK_RESPONSE_ACCEPT) {
+        /* Accepted so we make a grab sequence from it */
+        seq = vnc_grab_sequence_new(defs->numkeys,
+                                    defs->keysyms);
+
+        vnc_display_set_grab_keys(VNC_DISPLAY(vnc), seq);
+        set_title(VNC_DISPLAY(vnc), window, FALSE);
+        vnc_grab_sequence_free(seq);
+    }
+    g_free(defs);
+    gtk_widget_destroy(dialog);
 }
 
 static void vnc_credential(GtkWidget *vncdisplay, GValueArray *credList)
 {
-	GtkWidget *dialog = NULL;
-	int response;
-	unsigned int i, prompt = 0;
-	const char **data;
-
-	printf("Got credential request for %d credential(s)\n", credList->n_values);
-
-	data = g_new0(const char *, credList->n_values);
-
-	for (i = 0 ; i < credList->n_values ; i++) {
-		GValue *cred = g_value_array_get_nth(credList, i);
-		switch (g_value_get_enum(cred)) {
-		case VNC_DISPLAY_CREDENTIAL_USERNAME:
-		case VNC_DISPLAY_CREDENTIAL_PASSWORD:
-			prompt++;
-			break;
-		case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
-			data[i] = "gvncviewer";
-		default:
-			break;
-		}
-	}
-
-	if (prompt) {
-		GtkWidget **label, **entry, *box, *vbox;
-		int row;
-		dialog = gtk_dialog_new_with_buttons("Authentication required",
-						     NULL,
-						     0,
-						     GTK_STOCK_CANCEL,
-						     GTK_RESPONSE_CANCEL,
-						     GTK_STOCK_OK,
-						     GTK_RESPONSE_OK,
-						     NULL);
-		gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
-
-		box = gtk_table_new(credList->n_values, 2, FALSE);
-		label = g_new(GtkWidget *, prompt);
-		entry = g_new(GtkWidget *, prompt);
-
-		for (i = 0, row =0 ; i < credList->n_values ; i++) {
-			GValue *cred = g_value_array_get_nth(credList, i);
-			entry[row] = gtk_entry_new();
-			switch (g_value_get_enum(cred)) {
-			case VNC_DISPLAY_CREDENTIAL_USERNAME:
-				label[row] = gtk_label_new("Username:");
-				break;
-			case VNC_DISPLAY_CREDENTIAL_PASSWORD:
-				label[row] = gtk_label_new("Password:");
-				gtk_entry_set_activates_default(GTK_ENTRY(entry[row]), TRUE);
-				break;
-			default:
-				continue;
-			}
-			if (g_value_get_enum (cred) == VNC_DISPLAY_CREDENTIAL_PASSWORD)
-				gtk_entry_set_visibility (GTK_ENTRY (entry[row]), FALSE);
-
-			gtk_table_attach(GTK_TABLE(box), label[i], 0, 1, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
-			gtk_table_attach(GTK_TABLE(box), entry[i], 1, 2, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
-			row++;
-		}
-
-		vbox = gtk_bin_get_child(GTK_BIN(dialog));
-		gtk_container_add(GTK_CONTAINER(vbox), box);
-
-		gtk_widget_show_all(dialog);
-		response = gtk_dialog_run(GTK_DIALOG(dialog));
-		gtk_widget_hide(GTK_WIDGET(dialog));
-
-		if (response == GTK_RESPONSE_OK) {
-			for (i = 0, row = 0 ; i < credList->n_values ; i++) {
-				GValue *cred = g_value_array_get_nth(credList, i);
-				switch (g_value_get_enum(cred)) {
-				case VNC_DISPLAY_CREDENTIAL_USERNAME:
-				case VNC_DISPLAY_CREDENTIAL_PASSWORD:
-					data[i] = gtk_entry_get_text(GTK_ENTRY(entry[row]));
-					break;
-				default:
-					continue;
-				}
-				row++;
-			}
-		}
-	}
-
-	for (i = 0 ; i < credList->n_values ; i++) {
-		GValue *cred = g_value_array_get_nth(credList, i);
-		if (data[i]) {
-			if (vnc_display_set_credential(VNC_DISPLAY(vncdisplay),
-						       g_value_get_enum(cred),
-						       data[i])) {
-				printf("Failed to set credential type %d\n", g_value_get_enum(cred));
-				vnc_display_close(VNC_DISPLAY(vncdisplay));
-			}
-		} else {
-			printf("Unsupported credential type %d\n", g_value_get_enum(cred));
-			vnc_display_close(VNC_DISPLAY(vncdisplay));
-		}
-	}
-
-	g_free(data);
-	if (dialog)
-		gtk_widget_destroy(GTK_WIDGET(dialog));
+    GtkWidget *dialog = NULL;
+    int response;
+    unsigned int i, prompt = 0;
+    const char **data;
+
+    printf("Got credential request for %d credential(s)\n", credList->n_values);
+
+    data = g_new0(const char *, credList->n_values);
+
+    for (i = 0 ; i < credList->n_values ; i++) {
+        GValue *cred = g_value_array_get_nth(credList, i);
+        switch (g_value_get_enum(cred)) {
+        case VNC_DISPLAY_CREDENTIAL_USERNAME:
+        case VNC_DISPLAY_CREDENTIAL_PASSWORD:
+            prompt++;
+            break;
+        case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
+            data[i] = "gvncviewer";
+        default:
+            break;
+        }
+    }
+
+    if (prompt) {
+        GtkWidget **label, **entry, *box, *vbox;
+        int row;
+        dialog = gtk_dialog_new_with_buttons("Authentication required",
+                                             NULL,
+                                             0,
+                                             GTK_STOCK_CANCEL,
+                                             GTK_RESPONSE_CANCEL,
+                                             GTK_STOCK_OK,
+                                             GTK_RESPONSE_OK,
+                                             NULL);
+        gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+
+        box = gtk_table_new(credList->n_values, 2, FALSE);
+        label = g_new(GtkWidget *, prompt);
+        entry = g_new(GtkWidget *, prompt);
+
+        for (i = 0, row =0 ; i < credList->n_values ; i++) {
+            GValue *cred = g_value_array_get_nth(credList, i);
+            entry[row] = gtk_entry_new();
+            switch (g_value_get_enum(cred)) {
+            case VNC_DISPLAY_CREDENTIAL_USERNAME:
+                label[row] = gtk_label_new("Username:");
+                break;
+            case VNC_DISPLAY_CREDENTIAL_PASSWORD:
+                label[row] = gtk_label_new("Password:");
+                gtk_entry_set_activates_default(GTK_ENTRY(entry[row]), TRUE);
+                break;
+            default:
+                continue;
+            }
+            if (g_value_get_enum (cred) == VNC_DISPLAY_CREDENTIAL_PASSWORD)
+                gtk_entry_set_visibility (GTK_ENTRY (entry[row]), FALSE);
+
+            gtk_table_attach(GTK_TABLE(box), label[i], 0, 1, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
+            gtk_table_attach(GTK_TABLE(box), entry[i], 1, 2, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
+            row++;
+        }
+
+        vbox = gtk_bin_get_child(GTK_BIN(dialog));
+        gtk_container_add(GTK_CONTAINER(vbox), box);
+
+        gtk_widget_show_all(dialog);
+        response = gtk_dialog_run(GTK_DIALOG(dialog));
+        gtk_widget_hide(GTK_WIDGET(dialog));
+
+        if (response == GTK_RESPONSE_OK) {
+            for (i = 0, row = 0 ; i < credList->n_values ; i++) {
+                GValue *cred = g_value_array_get_nth(credList, i);
+                switch (g_value_get_enum(cred)) {
+                case VNC_DISPLAY_CREDENTIAL_USERNAME:
+                case VNC_DISPLAY_CREDENTIAL_PASSWORD:
+                    data[i] = gtk_entry_get_text(GTK_ENTRY(entry[row]));
+                    break;
+                default:
+                    continue;
+                }
+                row++;
+            }
+        }
+    }
+
+    for (i = 0 ; i < credList->n_values ; i++) {
+        GValue *cred = g_value_array_get_nth(credList, i);
+        if (data[i]) {
+            if (vnc_display_set_credential(VNC_DISPLAY(vncdisplay),
+                                           g_value_get_enum(cred),
+                                           data[i])) {
+                printf("Failed to set credential type %d\n", g_value_get_enum(cred));
+                vnc_display_close(VNC_DISPLAY(vncdisplay));
+            }
+        } else {
+            printf("Unsupported credential type %d\n", g_value_get_enum(cred));
+            vnc_display_close(VNC_DISPLAY(vncdisplay));
+        }
+    }
+
+    g_free(data);
+    if (dialog)
+        gtk_widget_destroy(GTK_WIDGET(dialog));
 }
 
 #if WITH_LIBVIEW
 static gboolean window_state_event(GtkWidget *widget,
-				   GdkEventWindowState *event,
-				   gpointer data)
+                                   GdkEventWindowState *event,
+                                   gpointer data)
 {
-	ViewAutoDrawer *drawer = VIEW_AUTODRAWER(data);
-
-	if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
-		if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
-			vnc_display_force_grab(VNC_DISPLAY(vnc), TRUE);
-			ViewAutoDrawer_SetActive(drawer, TRUE);
-		} else {
-			vnc_display_force_grab(VNC_DISPLAY(vnc), FALSE);
-			ViewAutoDrawer_SetActive(drawer, FALSE);
-		}
-	}
-
-	return FALSE;
+    ViewAutoDrawer *drawer = VIEW_AUTODRAWER(data);
+
+    if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
+        if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
+            vnc_display_force_grab(VNC_DISPLAY(vnc), TRUE);
+            ViewAutoDrawer_SetActive(drawer, TRUE);
+        } else {
+            vnc_display_force_grab(VNC_DISPLAY(vnc), FALSE);
+            ViewAutoDrawer_SetActive(drawer, FALSE);
+        }
+    }
+
+    return FALSE;
 }
 #endif
 
 int main(int argc, char **argv)
 {
-	gchar *name;
-	GOptionContext *context;
-	GError *error = NULL;
-	char port[1024], hostname[1024];
-	char *display;
-	GtkWidget *window;
-	GtkWidget *layout;
-	GtkWidget *menubar;
-	GtkWidget *sendkey, *view, *settings;
-	GtkWidget *submenu;
-	GtkWidget *caf1;
-	GtkWidget *caf2;
-	GtkWidget *caf3;
-	GtkWidget *caf4;
-	GtkWidget *caf5;
-	GtkWidget *caf6;
-	GtkWidget *caf7;
-	GtkWidget *caf8;
-	GtkWidget *cad;
-	GtkWidget *cab;
-	GtkWidget *fullscreen;
-	GtkWidget *scaling;
-	GtkWidget *showgrabkeydlg;
-	const char *help_msg = "Run 'gvncviewer --help' to see a full list of available command line options";
-
-	name = g_strdup_printf("- Simple VNC Client on Gtk-VNC %s",
-                                 vnc_util_get_version_string());
-
-	/* Setup command line options */
-	context = g_option_context_new (name);
-	g_option_context_add_main_entries (context, options, NULL);
-	g_option_context_add_group (context, gtk_get_option_group (TRUE));
-	g_option_context_add_group (context, vnc_display_get_option_group ());
-	g_option_context_parse (context, &argc, &argv, &error);
-	if (error) {
-		g_print ("%s\n%s\n",
-			 error->message,
-			help_msg);
-		g_error_free (error);
-		return 1;
-	}
-	if (!args || (g_strv_length(args) != 1)) {
-		fprintf(stderr, "Usage: gvncviewer [hostname][:display]\n%s\n", help_msg);
-		return 1;
-	}
-
-	vnc = vnc_display_new();
-
-	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gchar *name;
+    GOptionContext *context;
+    GError *error = NULL;
+    char port[1024], hostname[1024];
+    char *display;
+    GtkWidget *window;
+    GtkWidget *layout;
+    GtkWidget *menubar;
+    GtkWidget *sendkey, *view, *settings;
+    GtkWidget *submenu;
+    GtkWidget *caf1;
+    GtkWidget *caf2;
+    GtkWidget *caf3;
+    GtkWidget *caf4;
+    GtkWidget *caf5;
+    GtkWidget *caf6;
+    GtkWidget *caf7;
+    GtkWidget *caf8;
+    GtkWidget *cad;
+    GtkWidget *cab;
+    GtkWidget *fullscreen;
+    GtkWidget *scaling;
+    GtkWidget *showgrabkeydlg;
+    const char *help_msg = "Run 'gvncviewer --help' to see a full list of available command line options";
+
+    name = g_strdup_printf("- Simple VNC Client on Gtk-VNC %s",
+                           vnc_util_get_version_string());
+
+    /* Setup command line options */
+    context = g_option_context_new (name);
+    g_option_context_add_main_entries (context, options, NULL);
+    g_option_context_add_group (context, gtk_get_option_group (TRUE));
+    g_option_context_add_group (context, vnc_display_get_option_group ());
+    g_option_context_parse (context, &argc, &argv, &error);
+    if (error) {
+        g_print ("%s\n%s\n",
+                 error->message,
+                 help_msg);
+        g_error_free (error);
+        return 1;
+    }
+    if (!args || (g_strv_length(args) != 1)) {
+        fprintf(stderr, "Usage: gvncviewer [hostname][:display]\n%s\n", help_msg);
+        return 1;
+    }
+
+    vnc = vnc_display_new();
+
+    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 #if WITH_LIBVIEW
-	layout = ViewAutoDrawer_New();
+    layout = ViewAutoDrawer_New();
 #else
-	layout = gtk_vbox_new(FALSE, 0);
+    layout = gtk_vbox_new(FALSE, 0);
 #endif
-	menubar = gtk_menu_bar_new();
+    menubar = gtk_menu_bar_new();
 
 #if HAVE_PULSEAUDIO
-	pa = vnc_audio_pulse_new();
+    pa = vnc_audio_pulse_new();
 #endif
 
-	gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
+    gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
 
-	sendkey = gtk_menu_item_new_with_mnemonic("_Send Key");
-	gtk_menu_shell_append(GTK_MENU_SHELL(menubar), sendkey);
+    sendkey = gtk_menu_item_new_with_mnemonic("_Send Key");
+    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), sendkey);
 
-	submenu = gtk_menu_new();
+    submenu = gtk_menu_new();
 
-	caf1 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_1");
-	caf2 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_2");
-	caf3 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_3");
-	caf4 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_4");
-	caf5 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_5");
-	caf6 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_6");
-	caf7 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_7");
-	caf8 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_8");
-	cad = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+_Del");
-	cab = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+_Backspace");
+    caf1 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_1");
+    caf2 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_2");
+    caf3 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_3");
+    caf4 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_4");
+    caf5 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_5");
+    caf6 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_6");
+    caf7 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_7");
+    caf8 = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+F_8");
+    cad = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+_Del");
+    cab = gtk_menu_item_new_with_mnemonic("Ctrl+Alt+_Backspace");
 
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf1);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf2);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf3);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf4);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf5);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf6);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf7);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf8);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), cad);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), cab);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf1);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf2);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf3);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf4);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf5);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf6);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf7);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), caf8);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), cad);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), cab);
 
-	gtk_menu_item_set_submenu(GTK_MENU_ITEM(sendkey), submenu);
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(sendkey), submenu);
 
-	view = gtk_menu_item_new_with_mnemonic("_View");
-	gtk_menu_shell_append(GTK_MENU_SHELL(menubar), view);
+    view = gtk_menu_item_new_with_mnemonic("_View");
+    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), view);
 
-	submenu = gtk_menu_new();
+    submenu = gtk_menu_new();
 
-	fullscreen = gtk_check_menu_item_new_with_mnemonic("_Full Screen");
-	scaling = gtk_check_menu_item_new_with_mnemonic("Scaled display");
+    fullscreen = gtk_check_menu_item_new_with_mnemonic("_Full Screen");
+    scaling = gtk_check_menu_item_new_with_mnemonic("Scaled display");
 
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), fullscreen);
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), scaling);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), fullscreen);
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), scaling);
 
-	gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), submenu);
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), submenu);
 
-	settings = gtk_menu_item_new_with_mnemonic("_Settings");
-	gtk_menu_shell_append(GTK_MENU_SHELL(menubar), settings);
+    settings = gtk_menu_item_new_with_mnemonic("_Settings");
+    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), settings);
 
-	submenu = gtk_menu_new();
+    submenu = gtk_menu_new();
 
-	showgrabkeydlg = gtk_menu_item_new_with_mnemonic("_Set grab keys");
-	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), showgrabkeydlg);
+    showgrabkeydlg = gtk_menu_item_new_with_mnemonic("_Set grab keys");
+    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), showgrabkeydlg);
 
-	gtk_menu_item_set_submenu(GTK_MENU_ITEM(settings), submenu);
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(settings), submenu);
 
 #if WITH_LIBVIEW
-	ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(layout), FALSE);
-	ViewOvBox_SetOver(VIEW_OV_BOX(layout), menubar);
-	ViewOvBox_SetUnder(VIEW_OV_BOX(layout), vnc);
+    ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(layout), FALSE);
+    ViewOvBox_SetOver(VIEW_OV_BOX(layout), menubar);
+    ViewOvBox_SetUnder(VIEW_OV_BOX(layout), vnc);
 #else
-	gtk_box_pack_start(GTK_BOX(layout), menubar, FALSE, TRUE, 0);
-	gtk_box_pack_start(GTK_BOX(layout), vnc, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(layout), menubar, FALSE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(layout), vnc, TRUE, TRUE, 0);
 #endif
-	gtk_container_add(GTK_CONTAINER(window), layout);
-	gtk_widget_realize(vnc);
-
-	snprintf(hostname, sizeof(hostname), "%s", args[0]);
-	display = strchr(hostname, ':');
-
-	if (display) {
-		*display = 0;
-		snprintf(port, sizeof(port), "%d", 5900 + atoi(display + 1));
-	} else
-		snprintf(port, sizeof(port), "%d", 5900);
-
-	if (!*hostname) 
-		snprintf(hostname, sizeof(hostname), "%s", "127.0.0.1");
-	vnc_display_open_host(VNC_DISPLAY(vnc), hostname, port);
-	vnc_display_set_keyboard_grab(VNC_DISPLAY(vnc), TRUE);
-	vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);
-
-	if (!gtk_widget_is_composited(window)) {
-		vnc_display_set_scaling(VNC_DISPLAY(vnc), TRUE);
-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scaling), TRUE);
-	}
-
-	g_signal_connect(window, "delete-event",
-			 G_CALLBACK(gtk_main_quit), NULL);
-	g_signal_connect(vnc, "vnc-connected",
-			 G_CALLBACK(vnc_connected), NULL);
-	g_signal_connect(vnc, "vnc-initialized",
-			 G_CALLBACK(vnc_initialized), window);
-	g_signal_connect(vnc, "vnc-disconnected",
-			 G_CALLBACK(vnc_disconnected), NULL);
-	g_signal_connect(vnc, "vnc-auth-credential",
-			 G_CALLBACK(vnc_credential), NULL);
-	g_signal_connect(vnc, "vnc-auth-failure",
-			 G_CALLBACK(vnc_auth_failure), NULL);
-
-	g_signal_connect(vnc, "vnc-desktop-resize",
-			 G_CALLBACK(vnc_desktop_resize), NULL);
-
-	g_signal_connect(vnc, "vnc-pointer-grab",
-			 G_CALLBACK(vnc_grab), window);
-	g_signal_connect(vnc, "vnc-pointer-ungrab",
-			 G_CALLBACK(vnc_ungrab), window);
-
-	g_signal_connect(window, "key-press-event",
-			 G_CALLBACK(vnc_screenshot), vnc);
-
-	g_signal_connect(caf1, "activate",
-			 G_CALLBACK(send_caf1), vnc);
-	g_signal_connect(caf2, "activate",
-			 G_CALLBACK(send_caf2), vnc);
-	g_signal_connect(caf3, "activate",
-			 G_CALLBACK(send_caf3), vnc);
-	g_signal_connect(caf4, "activate",
-			 G_CALLBACK(send_caf4), vnc);
-	g_signal_connect(caf5, "activate",
-			 G_CALLBACK(send_caf5), vnc);
-	g_signal_connect(caf6, "activate",
-			 G_CALLBACK(send_caf6), vnc);
-	g_signal_connect(caf7, "activate",
-			 G_CALLBACK(send_caf7), vnc);
-	g_signal_connect(caf8, "activate",
-			 G_CALLBACK(send_caf8), vnc);
-	g_signal_connect(cad, "activate",
-			 G_CALLBACK(send_cad), vnc);
-	g_signal_connect(cab, "activate",
-			 G_CALLBACK(send_cab), vnc);
-	g_signal_connect(showgrabkeydlg, "activate",
-			 G_CALLBACK(do_set_grab_keys), window);
-	g_signal_connect(fullscreen, "toggled",
-			 G_CALLBACK(do_fullscreen), window);
-	g_signal_connect(scaling, "toggled",
-			 G_CALLBACK(do_scaling), vnc);
+    gtk_container_add(GTK_CONTAINER(window), layout);
+    gtk_widget_realize(vnc);
+
+    snprintf(hostname, sizeof(hostname), "%s", args[0]);
+    display = strchr(hostname, ':');
+
+    if (display) {
+        *display = 0;
+        snprintf(port, sizeof(port), "%d", 5900 + atoi(display + 1));
+    } else
+        snprintf(port, sizeof(port), "%d", 5900);
+
+    if (!*hostname) 
+        snprintf(hostname, sizeof(hostname), "%s", "127.0.0.1");
+    vnc_display_open_host(VNC_DISPLAY(vnc), hostname, port);
+    vnc_display_set_keyboard_grab(VNC_DISPLAY(vnc), TRUE);
+    vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);
+
+    if (!gtk_widget_is_composited(window)) {
+        vnc_display_set_scaling(VNC_DISPLAY(vnc), TRUE);
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scaling), TRUE);
+    }
+
+    g_signal_connect(window, "delete-event",
+                     G_CALLBACK(gtk_main_quit), NULL);
+    g_signal_connect(vnc, "vnc-connected",
+                     G_CALLBACK(vnc_connected), NULL);
+    g_signal_connect(vnc, "vnc-initialized",
+                     G_CALLBACK(vnc_initialized), window);
+    g_signal_connect(vnc, "vnc-disconnected",
+                     G_CALLBACK(vnc_disconnected), NULL);
+    g_signal_connect(vnc, "vnc-auth-credential",
+                     G_CALLBACK(vnc_credential), NULL);
+    g_signal_connect(vnc, "vnc-auth-failure",
+                     G_CALLBACK(vnc_auth_failure), NULL);
+
+    g_signal_connect(vnc, "vnc-desktop-resize",
+                     G_CALLBACK(vnc_desktop_resize), NULL);
+
+    g_signal_connect(vnc, "vnc-pointer-grab",
+                     G_CALLBACK(vnc_grab), window);
+    g_signal_connect(vnc, "vnc-pointer-ungrab",
+                     G_CALLBACK(vnc_ungrab), window);
+
+    g_signal_connect(window, "key-press-event",
+                     G_CALLBACK(vnc_screenshot), vnc);
+
+    g_signal_connect(caf1, "activate",
+                     G_CALLBACK(send_caf1), vnc);
+    g_signal_connect(caf2, "activate",
+                     G_CALLBACK(send_caf2), vnc);
+    g_signal_connect(caf3, "activate",
+                     G_CALLBACK(send_caf3), vnc);
+    g_signal_connect(caf4, "activate",
+                     G_CALLBACK(send_caf4), vnc);
+    g_signal_connect(caf5, "activate",
+                     G_CALLBACK(send_caf5), vnc);
+    g_signal_connect(caf6, "activate",
+                     G_CALLBACK(send_caf6), vnc);
+    g_signal_connect(caf7, "activate",
+                     G_CALLBACK(send_caf7), vnc);
+    g_signal_connect(caf8, "activate",
+                     G_CALLBACK(send_caf8), vnc);
+    g_signal_connect(cad, "activate",
+                     G_CALLBACK(send_cad), vnc);
+    g_signal_connect(cab, "activate",
+                     G_CALLBACK(send_cab), vnc);
+    g_signal_connect(showgrabkeydlg, "activate",
+                     G_CALLBACK(do_set_grab_keys), window);
+    g_signal_connect(fullscreen, "toggled",
+                     G_CALLBACK(do_fullscreen), window);
+    g_signal_connect(scaling, "toggled",
+                     G_CALLBACK(do_scaling), vnc);
 #if WITH_LIBVIEW
-	g_signal_connect(window, "window-state-event",
-			 G_CALLBACK(window_state_event), layout);
+    g_signal_connect(window, "window-state-event",
+                     G_CALLBACK(window_state_event), layout);
 #endif
 
-	gtk_main();
+    gtk_main();
 
-	return 0;
+    return 0;
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/plugin/gtk-vnc-plugin.c b/plugin/gtk-vnc-plugin.c
index c5e5b53..df82bb9 100644
--- a/plugin/gtk-vnc-plugin.c
+++ b/plugin/gtk-vnc-plugin.c
@@ -42,235 +42,235 @@
 static void
 vnc_connected (GtkWidget *vnc G_GNUC_UNUSED, void *Thisv)
 {
-  PluginInstance *This = (PluginInstance *) Thisv;
+    PluginInstance *This = (PluginInstance *) Thisv;
 
-  debug ("vnc_connected, This=%p", This);
+    debug ("vnc_connected, This=%p", This);
 }
 
 static void
 vnc_disconnected (GtkWidget *vnc G_GNUC_UNUSED, void *Thisv)
 {
-  PluginInstance *This = (PluginInstance *) Thisv;
+    PluginInstance *This = (PluginInstance *) Thisv;
 
-  debug ("vnc_disconnected, This=%p", This);
+    debug ("vnc_disconnected, This=%p", This);
 }
 
 static void
 vnc_auth_credential (GtkWidget *vnc, GValueArray *creds, void *Thisv)
 {
-  GtkWidget *dlg = NULL;
-  PluginInstance *This = (PluginInstance *) Thisv;
-  unsigned i, prompt = 0;
-  const char **data;
-
-  debug ("vnc_auth_credential, This=%p", This);
-
-  data = g_new0 (const char *, creds->n_values);
-
-  for (i = 0; i < creds->n_values; ++i) {
-    GValue *cred = g_value_array_get_nth (creds, i);
-    switch (g_value_get_enum (cred)) {
-    case VNC_DISPLAY_CREDENTIAL_USERNAME:
-    case VNC_DISPLAY_CREDENTIAL_PASSWORD:
-      prompt++;
-      break;
-    case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
-      data[i] = "gvncviewer";
-      break;
-    }
-  }
-
-  /* Prompt user for username and password. */
-  if (prompt) {
-    GtkWidget **label, **entry, *box, *vbox;
-    int row, response;
-
-    dlg = gtk_dialog_new_with_buttons
-      ("Gtk-VNC: Authentication required",
-       GTK_WINDOW (This->container),
-       GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
-       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-       GTK_STOCK_OK, GTK_RESPONSE_OK,
-       NULL);
-    gtk_dialog_set_default_response (GTK_DIALOG(dlg), GTK_RESPONSE_OK);
-
-    box = gtk_table_new (creds->n_values, 2, FALSE);
-    label = g_new (GtkWidget *, prompt);
-    entry = g_new (GtkWidget *, prompt);
-
-    for (i = 0, row = 0; i < creds->n_values; ++i) {
-      GValue *cred = g_value_array_get_nth (creds, i);
-      switch (g_value_get_enum(cred)) {
-      case VNC_DISPLAY_CREDENTIAL_USERNAME:
-	label[row] = gtk_label_new("Username:");
-	break;
-      case VNC_DISPLAY_CREDENTIAL_PASSWORD:
-	label[row] = gtk_label_new("Password:");
-	break;
-      default:
-	continue;
-      }
-      entry[row] = gtk_entry_new();
-      if (g_value_get_enum (cred) == VNC_DISPLAY_CREDENTIAL_PASSWORD)
-	gtk_entry_set_visibility (GTK_ENTRY (entry[row]), FALSE);
-
-      gtk_table_attach(GTK_TABLE(box), label[i], 0, 1, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
-      gtk_table_attach(GTK_TABLE(box), entry[i], 1, 2, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
-      row++;
+    GtkWidget *dlg = NULL;
+    PluginInstance *This = (PluginInstance *) Thisv;
+    unsigned i, prompt = 0;
+    const char **data;
+
+    debug ("vnc_auth_credential, This=%p", This);
+
+    data = g_new0 (const char *, creds->n_values);
+
+    for (i = 0; i < creds->n_values; ++i) {
+        GValue *cred = g_value_array_get_nth (creds, i);
+        switch (g_value_get_enum (cred)) {
+        case VNC_DISPLAY_CREDENTIAL_USERNAME:
+        case VNC_DISPLAY_CREDENTIAL_PASSWORD:
+            prompt++;
+            break;
+        case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
+            data[i] = "gvncviewer";
+            break;
+        }
     }
 
-    vbox = gtk_bin_get_child(GTK_BIN(dlg));
-    gtk_container_add(GTK_CONTAINER(vbox), box);
-
-    gtk_widget_show_all(dlg);
-    response = gtk_dialog_run(GTK_DIALOG(dlg));
-    gtk_widget_hide(GTK_WIDGET(dlg));
-
-    if (response == GTK_RESPONSE_OK) {
-      for (i = 0, row = 0 ; i < creds->n_values ; i++) {
-	GValue *cred = g_value_array_get_nth(creds, i);
-	switch (g_value_get_enum(cred)) {
-	case VNC_DISPLAY_CREDENTIAL_USERNAME:
-	case VNC_DISPLAY_CREDENTIAL_PASSWORD:
-	  data[i] = gtk_entry_get_text(GTK_ENTRY(entry[row]));
-	  row++;
-	  break;
-	}
-      }
+    /* Prompt user for username and password. */
+    if (prompt) {
+        GtkWidget **label, **entry, *box, *vbox;
+        int row, response;
+
+        dlg = gtk_dialog_new_with_buttons
+            ("Gtk-VNC: Authentication required",
+             GTK_WINDOW (This->container),
+             GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+             GTK_STOCK_OK, GTK_RESPONSE_OK,
+             NULL);
+        gtk_dialog_set_default_response (GTK_DIALOG(dlg), GTK_RESPONSE_OK);
+
+        box = gtk_table_new (creds->n_values, 2, FALSE);
+        label = g_new (GtkWidget *, prompt);
+        entry = g_new (GtkWidget *, prompt);
+
+        for (i = 0, row = 0; i < creds->n_values; ++i) {
+            GValue *cred = g_value_array_get_nth (creds, i);
+            switch (g_value_get_enum(cred)) {
+            case VNC_DISPLAY_CREDENTIAL_USERNAME:
+                label[row] = gtk_label_new("Username:");
+                break;
+            case VNC_DISPLAY_CREDENTIAL_PASSWORD:
+                label[row] = gtk_label_new("Password:");
+                break;
+            default:
+                continue;
+            }
+            entry[row] = gtk_entry_new();
+            if (g_value_get_enum (cred) == VNC_DISPLAY_CREDENTIAL_PASSWORD)
+                gtk_entry_set_visibility (GTK_ENTRY (entry[row]), FALSE);
+
+            gtk_table_attach(GTK_TABLE(box), label[i], 0, 1, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
+            gtk_table_attach(GTK_TABLE(box), entry[i], 1, 2, row, row+1, GTK_SHRINK, GTK_SHRINK, 3, 3);
+            row++;
+        }
+
+        vbox = gtk_bin_get_child(GTK_BIN(dlg));
+        gtk_container_add(GTK_CONTAINER(vbox), box);
+
+        gtk_widget_show_all(dlg);
+        response = gtk_dialog_run(GTK_DIALOG(dlg));
+        gtk_widget_hide(GTK_WIDGET(dlg));
+
+        if (response == GTK_RESPONSE_OK) {
+            for (i = 0, row = 0 ; i < creds->n_values ; i++) {
+                GValue *cred = g_value_array_get_nth(creds, i);
+                switch (g_value_get_enum(cred)) {
+                case VNC_DISPLAY_CREDENTIAL_USERNAME:
+                case VNC_DISPLAY_CREDENTIAL_PASSWORD:
+                    data[i] = gtk_entry_get_text(GTK_ENTRY(entry[row]));
+                    row++;
+                    break;
+                }
+            }
+        }
     }
-  }
-
-  /* Set the credentials. */
-  for (i = 0 ; i < creds->n_values ; i++) {
-    GValue *cred = g_value_array_get_nth(creds, i);
-    if (data[i]) {
-      if (vnc_display_set_credential(VNC_DISPLAY(vnc),
-				     g_value_get_enum(cred),
-				     data[i])) {
-	debug ("Failed to set credential type %d", g_value_get_enum(cred));
-	vnc_display_close(VNC_DISPLAY(vnc));
-      }
-    } else {
-      debug ("Unsupported credential type %d", g_value_get_enum(cred));
-      vnc_display_close(VNC_DISPLAY(vnc));
+
+    /* Set the credentials. */
+    for (i = 0 ; i < creds->n_values ; i++) {
+        GValue *cred = g_value_array_get_nth(creds, i);
+        if (data[i]) {
+            if (vnc_display_set_credential(VNC_DISPLAY(vnc),
+                                           g_value_get_enum(cred),
+                                           data[i])) {
+                debug ("Failed to set credential type %d", g_value_get_enum(cred));
+                vnc_display_close(VNC_DISPLAY(vnc));
+            }
+        } else {
+            debug ("Unsupported credential type %d", g_value_get_enum(cred));
+            vnc_display_close(VNC_DISPLAY(vnc));
+        }
     }
-  }
 
-  g_free (data);
-  if (dlg)
-    gtk_widget_destroy (GTK_WIDGET(dlg));
+    g_free (data);
+    if (dlg)
+        gtk_widget_destroy (GTK_WIDGET(dlg));
 }
 
 NPError
 GtkVNCXSetWindow (NPP instance, NPWindow *window)
 {
-  PluginInstance *This;
-  NPSetWindowCallbackStruct *ws_info;
+    PluginInstance *This;
+    NPSetWindowCallbackStruct *ws_info;
 
-  if (instance == NULL)
-    return NPERR_INVALID_INSTANCE_ERROR;
+    if (instance == NULL)
+        return NPERR_INVALID_INSTANCE_ERROR;
 
-  This = (PluginInstance*) instance->pdata;
+    This = (PluginInstance*) instance->pdata;
 
-  debug ("GtkVNCXSetWindow, This=%p", This);
+    debug ("GtkVNCXSetWindow, This=%p", This);
 
-  if (This == NULL)
-    return NPERR_INVALID_INSTANCE_ERROR;
+    if (This == NULL)
+        return NPERR_INVALID_INSTANCE_ERROR;
 
-  ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
+    ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
 
-  /* Mozilla likes to re-run its greatest hits */
-  if (window == This->window &&
-      window->x == This->x &&
-      window->y == This->y &&
-      window->width == This->width &&
-      window->height == This->height) {
-    debug ("gtk-vnc-plugin: window re-run; returning");
-    return NPERR_NO_ERROR;
-  }
-
-  This->window = window;
-  This->x = window->x;
-  This->y = window->y;
-  This->width = window->width;
-  This->height = window->height;
-
-  /* Create a GtkPlug container and a Gtk-VNC widget inside it. */
-  This->container = gtk_plug_new ((GdkNativeWindow)(long)window->window);
-  This->vnc = vnc_display_new ();
-
-  /* Make sure the canvas is capable of receiving focus. */
-  GTK_WIDGET_SET_FLAGS (GTK_WIDGET(This->vnc), GTK_CAN_FOCUS);
-
-  /* All the events that our canvas wants to receive */
-  gtk_widget_add_events
-    (This->vnc,
-     GDK_BUTTON_PRESS_MASK |
-     GDK_BUTTON_RELEASE_MASK |
-     GDK_KEY_PRESS_MASK |
-     GDK_KEY_RELEASE_MASK |
-     GDK_POINTER_MOTION_MASK |
-     GDK_SCROLL_MASK |
-     GDK_EXPOSURE_MASK |
-     GDK_VISIBILITY_NOTIFY_MASK |
-     GDK_ENTER_NOTIFY_MASK |
-     GDK_LEAVE_NOTIFY_MASK |
-     GDK_FOCUS_CHANGE_MASK);
-
-  /* Connect up the signals. */
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-connected",
-		    G_CALLBACK(vnc_connected), This);
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-disconnected",
-		    G_CALLBACK(vnc_disconnected), This);
+    /* Mozilla likes to re-run its greatest hits */
+    if (window == This->window &&
+        window->x == This->x &&
+        window->y == This->y &&
+        window->width == This->width &&
+        window->height == This->height) {
+        debug ("gtk-vnc-plugin: window re-run; returning");
+        return NPERR_NO_ERROR;
+    }
+
+    This->window = window;
+    This->x = window->x;
+    This->y = window->y;
+    This->width = window->width;
+    This->height = window->height;
+
+    /* Create a GtkPlug container and a Gtk-VNC widget inside it. */
+    This->container = gtk_plug_new ((GdkNativeWindow)(long)window->window);
+    This->vnc = vnc_display_new ();
+
+    /* Make sure the canvas is capable of receiving focus. */
+    GTK_WIDGET_SET_FLAGS (GTK_WIDGET(This->vnc), GTK_CAN_FOCUS);
+
+    /* All the events that our canvas wants to receive */
+    gtk_widget_add_events
+        (This->vnc,
+         GDK_BUTTON_PRESS_MASK |
+         GDK_BUTTON_RELEASE_MASK |
+         GDK_KEY_PRESS_MASK |
+         GDK_KEY_RELEASE_MASK |
+         GDK_POINTER_MOTION_MASK |
+         GDK_SCROLL_MASK |
+         GDK_EXPOSURE_MASK |
+         GDK_VISIBILITY_NOTIFY_MASK |
+         GDK_ENTER_NOTIFY_MASK |
+         GDK_LEAVE_NOTIFY_MASK |
+         GDK_FOCUS_CHANGE_MASK);
+
+    /* Connect up the signals. */
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-connected",
+                      G_CALLBACK(vnc_connected), This);
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-disconnected",
+                      G_CALLBACK(vnc_disconnected), This);
 #if 0
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-initialized",
-		    G_CALLBACK(vnc_initialized), This);
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-initialized",
+                      G_CALLBACK(vnc_initialized), This);
 #endif
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-auth-credential",
-		    G_CALLBACK(vnc_auth_credential), This);
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-auth-credential",
+                      G_CALLBACK(vnc_auth_credential), This);
 #if 0
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-auth-failure",
-		    G_CALLBACK(vnc_auth_failure), This);
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-desktop-resize",
-		    G_CALLBACK(vnc_desktop_resize), This);
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-pointer-grab",
-		    G_CALLBACK(vnc_pointer_grab), This);
-  g_signal_connect (G_OBJECT(This->vnc), "vnc-pointer-ungrab",
-		    G_CALLBACK(vnc_pointer_ungrab), This);
-  g_signal_connect (G_OBJECT(This->vnc), "key-press-event",
-		    G_CALLBACK(vnc_screenshow), This);
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-auth-failure",
+                      G_CALLBACK(vnc_auth_failure), This);
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-desktop-resize",
+                      G_CALLBACK(vnc_desktop_resize), This);
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-pointer-grab",
+                      G_CALLBACK(vnc_pointer_grab), This);
+    g_signal_connect (G_OBJECT(This->vnc), "vnc-pointer-ungrab",
+                      G_CALLBACK(vnc_pointer_ungrab), This);
+    g_signal_connect (G_OBJECT(This->vnc), "key-press-event",
+                      G_CALLBACK(vnc_screenshow), This);
 #endif
 
-  gtk_widget_show (This->vnc);
+    gtk_widget_show (This->vnc);
 
-  gtk_container_add (GTK_CONTAINER(This->container), This->vnc);
+    gtk_container_add (GTK_CONTAINER(This->container), This->vnc);
 
-  gtk_widget_show (This->container);
+    gtk_widget_show (This->container);
 
-  /*gtk_widget_realize (This->vnc);*/
+    /*gtk_widget_realize (This->vnc);*/
 
-  /* Start connection to remote host. */
-  if (This->host && This->port) {
-    debug ("starting connection to %s:%s", This->host, This->port);
-    vnc_display_open_host (VNC_DISPLAY(This->vnc), This->host, This->port);
-  }
+    /* Start connection to remote host. */
+    if (This->host && This->port) {
+        debug ("starting connection to %s:%s", This->host, This->port);
+        vnc_display_open_host (VNC_DISPLAY(This->vnc), This->host, This->port);
+    }
 
-  return NPERR_NO_ERROR;
+    return NPERR_NO_ERROR;
 }
 
 NPError
 GtkVNCDestroyWindow (NPP instance)
 {
-  PluginInstance *This = (PluginInstance*) instance->pdata;
+    PluginInstance *This = (PluginInstance*) instance->pdata;
 
-  debug ("GtkVNCDestroyWindow, This=%p", This);
+    debug ("GtkVNCDestroyWindow, This=%p", This);
 
-  if (This && This->container) {
-    gtk_widget_destroy (This->container);
-    This->container = This->vnc = NULL;
-  }
+    if (This && This->container) {
+        gtk_widget_destroy (This->container);
+        This->container = This->vnc = NULL;
+    }
 
-  return NPERR_NO_ERROR;
+    return NPERR_NO_ERROR;
 }
 
 static NPWindow windowlessWindow;
@@ -278,30 +278,37 @@ static NPWindow windowlessWindow;
 int16
 GtkVNCXHandleEvent(NPP instance, void *event)
 {
-  XGraphicsExposeEvent exposeEvent;
-  XEvent *nsEvent;
+    XGraphicsExposeEvent exposeEvent;
+    XEvent *nsEvent;
 
-  debug ("GtkVNCXHandleEvent");
+    debug ("GtkVNCXHandleEvent");
 
-  nsEvent = (XEvent *) event;
-  exposeEvent = nsEvent->xgraphicsexpose;
+    nsEvent = (XEvent *) event;
+    exposeEvent = nsEvent->xgraphicsexpose;
 
-  /*printf(" event: x, y, w, h = %d, %d, %d, %d; display @ %p, window/drawable = %d\n",
-    exposeEvent.x,
-    exposeEvent.y,
-    exposeEvent.width,
-    exposeEvent.height,
-    exposeEvent.display,
-    exposeEvent.drawable);*/
+    /*printf(" event: x, y, w, h = %d, %d, %d, %d; display @ %p, window/drawable = %d\n",
+      exposeEvent.x,
+      exposeEvent.y,
+      exposeEvent.width,
+      exposeEvent.height,
+      exposeEvent.display,
+      exposeEvent.drawable);*/
 
-  windowlessWindow.window = exposeEvent.display;
-  windowlessWindow.x = exposeEvent.x;
-  windowlessWindow.y = exposeEvent.y;
-  windowlessWindow.width = exposeEvent.width;
-  windowlessWindow.height = exposeEvent.height;
-  windowlessWindow.ws_info = (void *)exposeEvent.drawable;
+    windowlessWindow.window = exposeEvent.display;
+    windowlessWindow.x = exposeEvent.x;
+    windowlessWindow.y = exposeEvent.y;
+    windowlessWindow.width = exposeEvent.width;
+    windowlessWindow.height = exposeEvent.height;
+    windowlessWindow.ws_info = (void *)exposeEvent.drawable;
 
-  NPP_SetWindow(instance, &windowlessWindow);
+    NPP_SetWindow(instance, &windowlessWindow);
 
-  return 0;
+    return 0;
 }
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/plugin/gtk-vnc-plugin.h b/plugin/gtk-vnc-plugin.h
index e2113f6..4eb453d 100644
--- a/plugin/gtk-vnc-plugin.h
+++ b/plugin/gtk-vnc-plugin.h
@@ -45,18 +45,18 @@
 #define PLUGIN_DESCRIPTION  "VNC (remote desktop) viewer plugin"
 
 typedef struct {
-  uint16 mode;
-  NPWindow *window;
-  int32 x, y;
-  uint32 width, height;
+    uint16 mode;
+    NPWindow *window;
+    int32 x, y;
+    uint32 width, height;
 
-  NPP instance;
-  NPBool pluginsHidden;
+    NPP instance;
+    NPBool pluginsHidden;
 
-  GtkWidget *container;
-  GtkWidget *vnc;
+    GtkWidget *container;
+    GtkWidget *vnc;
 
-  char *host, *port;
+    char *host, *port;
 } PluginInstance;
 
 extern NPError GtkVNCXSetWindow (NPP instance, NPWindow* window);
@@ -67,16 +67,23 @@ extern int16 GtkVNCXHandleEvent (NPP instance, void* event);
 static inline void
 debug (const char *msg, ...)
 {
-  va_list args;
+    va_list args;
 
-  va_start (args, msg);
-  vfprintf (stderr, msg, args);
-  va_end (args);
-  fprintf (stderr, "\n");
-  fflush (stderr);
+    va_start (args, msg);
+    vfprintf (stderr, msg, args);
+    va_end (args);
+    fprintf (stderr, "\n");
+    fflush (stderr);
 }
 #else
 static inline void debug (const char *msg G_GNUC_UNUSED, ...) { }
 #endif
 
 #endif /* GTK_VNC_PLUGIN_H */
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/plugin/npapi.h b/plugin/npapi.h
index 6f783a1..5da7aae 100644
--- a/plugin/npapi.h
+++ b/plugin/npapi.h
@@ -78,26 +78,26 @@
 #endif
 
 #if defined (__OS2__ ) || defined (OS2)
-#	ifndef XP_OS2
-#		define XP_OS2 1
-#	endif /* XP_OS2 */
+#        ifndef XP_OS2
+#                define XP_OS2 1
+#        endif /* XP_OS2 */
 #endif /* __OS2__ */
 
 #ifdef _WINDOWS
-#	include <windef.h>
-#	ifndef XP_WIN
-#		define XP_WIN 1
-#	endif /* XP_WIN */
+#        include <windef.h>
+#        ifndef XP_WIN
+#                define XP_WIN 1
+#        endif /* XP_WIN */
 #endif /* _WINDOWS */
 
 #ifdef __MWERKS__
-#	define _declspec __declspec
-#	ifdef __INTEL__
-#		undef NULL
-#		ifndef XP_WIN
-#			define XP_WIN 1
-#		endif /* XP_WIN */
-#	endif /* __INTEL__ */
+#        define _declspec __declspec
+#        ifdef __INTEL__
+#                undef NULL
+#                ifndef XP_WIN
+#                        define XP_WIN 1
+#                endif /* XP_WIN */
+#        endif /* __INTEL__ */
 #endif /* __MWERKS__ */
 
 #ifdef XP_MACOSX
@@ -108,11 +108,11 @@
 #endif
 
 #if defined(XP_UNIX) 
-#	include <stdio.h>
-#	if defined(MOZ_X11)
-#		include <X11/Xlib.h>
-#		include <X11/Xutil.h>
-#	endif
+#        include <stdio.h>
+#        if defined(MOZ_X11)
+#                include <X11/Xlib.h>
+#                include <X11/Xutil.h>
+#        endif
 #endif
 
 /*----------------------------------------------------------------------*/
@@ -129,24 +129,24 @@
    FileVersion and ProductVersion are 32bit ints, all other
    entries are strings the MUST be terminated wwith a \0.
 
-AN EXAMPLE:
+   AN EXAMPLE:
 
-RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
+   RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
 
-RCDATA NP_INFO_MIMEType    { "video/x-video|",
-                             "video/x-flick\0" }
-RCDATA NP_INFO_FileExtents { "avi|",
-                             "flc\0" }
-RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
-                             "MMOS2 Flc/Fli player(*.flc)\0" }
+   RCDATA NP_INFO_MIMEType    { "video/x-video|",
+   "video/x-flick\0" }
+   RCDATA NP_INFO_FileExtents { "avi|",
+   "flc\0" }
+   RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
+   "MMOS2 Flc/Fli player(*.flc)\0" }
 
-RCDATA NP_INFO_FileVersion       { 1,0,0,1 }
-RCDATA NP_INFO_CompanyName       { "Netscape Communications\0" }
-RCDATA NP_INFO_FileDescription   { "NPAVI32 Extension DLL\0"
-RCDATA NP_INFO_InternalName      { "NPAVI32\0" )
-RCDATA NP_INFO_LegalCopyright    { "Copyright Netscape Communications \251 1996\0"
-RCDATA NP_INFO_OriginalFilename  { "NVAPI32.DLL" }
-RCDATA NP_INFO_ProductName       { "NPAVI32 Dynamic Link Library\0" }
+   RCDATA NP_INFO_FileVersion       { 1,0,0,1 }
+   RCDATA NP_INFO_CompanyName       { "Netscape Communications\0" }
+   RCDATA NP_INFO_FileDescription   { "NPAVI32 Extension DLL\0"
+   RCDATA NP_INFO_InternalName      { "NPAVI32\0" )
+   RCDATA NP_INFO_LegalCopyright    { "Copyright Netscape Communications \251 1996\0"
+   RCDATA NP_INFO_OriginalFilename  { "NVAPI32.DLL" }
+   RCDATA NP_INFO_ProductName       { "NPAVI32 Dynamic Link Library\0" }
 
 */
 
@@ -224,10 +224,10 @@ typedef enum {
 } NPDrawingModel;
 #endif
 
-typedef unsigned char	NPBool;
-typedef int16			NPError;
-typedef int16			NPReason;
-typedef char*			NPMIMEType;
+typedef unsigned char        NPBool;
+typedef int16                        NPError;
+typedef int16                        NPReason;
+typedef char*                        NPMIMEType;
 
 
 
@@ -240,8 +240,8 @@ typedef char*			NPMIMEType;
  */
 typedef struct _NPP
 {
-  void*	pdata;      /* plug-in private data */
-  void*	ndata;      /* netscape private data */
+  void*        pdata;      /* plug-in private data */
+  void*        ndata;      /* netscape private data */
 } NPP_t;
 
 typedef NPP_t*  NPP;
@@ -278,8 +278,8 @@ typedef struct _NPByteRange
 
 typedef struct _NPSavedData
 {
-  int32	len;
-  void*	buf;
+  int32        len;
+  void*        buf;
 } NPSavedData;
 
 
@@ -477,11 +477,11 @@ typedef struct _NPWindow
                  /* OS/2: x - Position of bottom left corner  */
                  /* OS/2: y - relative to visible netscape window */
   int32 x;       /* Position of top left corner relative */
-  int32 y;       /* to a netscape page.					*/
+  int32 y;       /* to a netscape page.                                        */
   uint32 width;  /* Maximum window size */
   uint32 height;
   NPRect clipRect; /* Clipping rectangle in port coordinates */
-                   /* Used by MAC only.			  */
+                   /* Used by MAC only.                          */
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
   void * ws_info; /* Platform-dependent additonal data */
 #endif /* XP_UNIX */
@@ -492,7 +492,7 @@ typedef struct _NPWindow
 typedef struct _NPFullPrint
 {
   NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */
-  NPBool printOne;		 /* TRUE if plugin should print one copy to default printer */
+  NPBool printOne;                 /* TRUE if plugin should print one copy to default printer */
   void* platformPrint; /* Platform-specific printing info */
 } NPFullPrint;
 
@@ -513,7 +513,7 @@ typedef struct _NPPrint
 } NPPrint;
 
 #ifdef XP_MACOSX
-typedef EventRecord	NPEvent;
+typedef EventRecord        NPEvent;
 #elif defined(XP_WIN)
 typedef struct _NPEvent
 {
@@ -531,7 +531,7 @@ typedef struct _NPEvent
 #elif defined (XP_UNIX) && defined(MOZ_X11)
 typedef XEvent NPEvent;
 #else
-typedef void*			NPEvent;
+typedef void*                        NPEvent;
 #endif /* XP_MACOSX */
 
 #ifdef XP_MACOSX
@@ -601,11 +601,11 @@ enum NPEventType {
 #define NP_ASFILE     3
 #define NP_ASFILEONLY 4
 
-#define NP_MAXREADY	(((unsigned)(~0)<<1)>>1)
+#define NP_MAXREADY        (((unsigned)(~0)<<1)>>1)
 
 
 /*----------------------------------------------------------------------*/
-/*		     Error and Reason Code definitions			*/
+/*                     Error and Reason Code definitions                        */
 /*----------------------------------------------------------------------*/
 
 /*
@@ -677,82 +677,82 @@ enum NPEventType {
 extern "C" {
 #endif
 
-/*
- * NPP_* functions are provided by the plugin and called by the navigator.
- */
+  /*
+   * NPP_* functions are provided by the plugin and called by the navigator.
+   */
 
 #ifdef XP_UNIX
-char* NPP_GetMIMEDescription(void);
+  char* NPP_GetMIMEDescription(void);
 #endif /* XP_UNIX */
 
-NPError NP_LOADDS NPP_Initialize(void);
-void    NP_LOADDS NPP_Shutdown(void);
-NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
-                          uint16 mode, int16 argc, char* argn[],
-                          char* argv[], NPSavedData* saved);
-NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
-NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
-NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
-                                NPStream* stream, NPBool seekable,
-                                uint16* stype);
-NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
-                                    NPReason reason);
-int32   NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
-int32   NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
-                            int32 len, void* buffer);
-void    NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
-                                   const char* fname);
-void    NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
-int16   NP_LOADDS NPP_HandleEvent(NPP instance, void* event);
-void    NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
-                                NPReason reason, void* notifyData);
+  NPError NP_LOADDS NPP_Initialize(void);
+  void    NP_LOADDS NPP_Shutdown(void);
+  NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
+                            uint16 mode, int16 argc, char* argn[],
+                            char* argv[], NPSavedData* saved);
+  NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
+  NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
+  NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
+                                  NPStream* stream, NPBool seekable,
+                                  uint16* stype);
+  NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
+                                      NPReason reason);
+  int32   NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
+  int32   NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
+                              int32 len, void* buffer);
+  void    NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
+                                     const char* fname);
+  void    NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
+  int16   NP_LOADDS NPP_HandleEvent(NPP instance, void* event);
+  void    NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
+                                  NPReason reason, void* notifyData);
 #ifdef OJI
-jref    NP_LOADDS NPP_GetJavaClass(void);
+  jref    NP_LOADDS NPP_GetJavaClass(void);
 #endif
-NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
-NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
+  NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
+  NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
 
-/*
- * NPN_* functions are provided by the navigator and called by the plugin.
- */
-void    NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
-                              int* netscape_major, int* netscape_minor);
-NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
-                                   const char* target, void* notifyData);
-NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url,
-                             const char* target);
-NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
-                                    const char* target, uint32 len,
-                                    const char* buf, NPBool file,
-                                    void* notifyData);
-NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url,
-                              const char* target, uint32 len,
-                              const char* buf, NPBool file);
-NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
-NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
-                                const char* target, NPStream** stream);
-int32   NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
-NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
-void    NP_LOADDS NPN_Status(NPP instance, const char* message);
-const char* NP_LOADDS	NPN_UserAgent(NPP instance);
-void*   NP_LOADDS NPN_MemAlloc(uint32 size);
-void    NP_LOADDS NPN_MemFree(void* ptr);
-uint32  NP_LOADDS NPN_MemFlush(uint32 size);
-void    NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
+  /*
+   * NPN_* functions are provided by the navigator and called by the plugin.
+   */
+  void    NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
+                                int* netscape_major, int* netscape_minor);
+  NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
+                                     const char* target, void* notifyData);
+  NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url,
+                               const char* target);
+  NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
+                                      const char* target, uint32 len,
+                                      const char* buf, NPBool file,
+                                      void* notifyData);
+  NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url,
+                                const char* target, uint32 len,
+                                const char* buf, NPBool file);
+  NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
+  NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
+                                  const char* target, NPStream** stream);
+  int32   NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
+  NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
+  void    NP_LOADDS NPN_Status(NPP instance, const char* message);
+  const char* NP_LOADDS        NPN_UserAgent(NPP instance);
+  void*   NP_LOADDS NPN_MemAlloc(uint32 size);
+  void    NP_LOADDS NPN_MemFree(void* ptr);
+  uint32  NP_LOADDS NPN_MemFlush(uint32 size);
+  void    NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
 #ifdef OJI
-JRIEnv* NP_LOADDS NPN_GetJavaEnv(void);
-jref    NP_LOADDS NPN_GetJavaPeer(NPP instance);
-#endif
-NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value);
-NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value);
-void    NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
-void    NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
-void    NP_LOADDS NPN_ForceRedraw(NPP instance);
-void    NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
-void    NP_LOADDS NPN_PopPopupsEnabledState(NPP instance);
-void    NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance,
-                                            void (*func) (void *),
-                                            void *userData);
+  JRIEnv* NP_LOADDS NPN_GetJavaEnv(void);
+  jref    NP_LOADDS NPN_GetJavaPeer(NPP instance);
+#endif
+  NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value);
+  NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value);
+  void    NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
+  void    NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
+  void    NP_LOADDS NPN_ForceRedraw(NPP instance);
+  void    NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
+  void    NP_LOADDS NPN_PopPopupsEnabledState(NPP instance);
+  void    NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance,
+                                              void (*func) (void *),
+                                              void *userData);
 
 #ifdef __cplusplus
 }  /* end extern "C" */
diff --git a/plugin/npshell.c b/plugin/npshell.c
index 0252a02..c59bc89 100644
--- a/plugin/npshell.c
+++ b/plugin/npshell.c
@@ -57,23 +57,23 @@
 
 
 /*
-The contents of this file are subject to the Mozilla Public License
+  The contents of this file are subject to the Mozilla Public License
 
-Version 1.1 (the "License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
+  Version 1.1 (the "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
 
-Software distributed under the License is distributed on an "AS IS" basis,
-WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
-the specific language governing rights and limitations under the License.
+  Software distributed under the License is distributed on an "AS IS" basis,
+  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+  the specific language governing rights and limitations under the License.
 
-The Original Code is stub code that defines the binary interface to a Mozilla
-plugin.
+  The Original Code is stub code that defines the binary interface to a Mozilla
+  plugin.
 
-The Initial Developer of the Original Code is Mozilla.
+  The Initial Developer of the Original Code is Mozilla.
 
-Portions created by Adobe Systems Incorporated are Copyright (C) 2007. All Rights Reserved.
+  Portions created by Adobe Systems Incorporated are Copyright (C) 2007. All Rights Reserved.
 
-Contributor(s): Adobe Systems Incorporated.
+  Contributor(s): Adobe Systems Incorporated.
 */
 
 
@@ -282,80 +282,80 @@ NPP_DestroyStream(NPP instance, NPStream *stream G_GNUC_UNUSED,
   if (instance == NULL)
     return NPERR_INVALID_INSTANCE_ERROR;
 
-    /***** Insert NPP_DestroyStream code here *****\
-    PluginInstance* This;
-    This = (PluginInstance*) instance->pdata;
-    \**********************************************/
+  /***** Insert NPP_DestroyStream code here *****\
+         PluginInstance* This;
+         This = (PluginInstance*) instance->pdata;
+         \**********************************************/
 
-    return NPERR_NO_ERROR;
+  return NPERR_NO_ERROR;
 }
 
 void
 NPP_StreamAsFile(NPP instance G_GNUC_UNUSED, NPStream *stream G_GNUC_UNUSED,
                  const char* fname G_GNUC_UNUSED)
 {
-    /*printf("NPP_StreamAsFile()\n");*/
-    /***** Insert NPP_StreamAsFile code here *****\
-    PluginInstance* This;
-    if (instance != NULL)
-        This = (PluginInstance*) instance->pdata;
-    \*********************************************/
+  /*printf("NPP_StreamAsFile()\n");*/
+  /***** Insert NPP_StreamAsFile code here *****\
+         PluginInstance* This;
+         if (instance != NULL)
+         This = (PluginInstance*) instance->pdata;
+         \*********************************************/
 }
 
 void
 NPP_URLNotify(NPP instance G_GNUC_UNUSED, const char* url G_GNUC_UNUSED,
               NPReason reason G_GNUC_UNUSED, void* notifyData G_GNUC_UNUSED)
 {
-    /*printf("NPP_URLNotify()\n");*/
-    /***** Insert NPP_URLNotify code here *****\
-    PluginInstance* This;
-    if (instance != NULL)
-        This = (PluginInstance*) instance->pdata;
-    \*********************************************/
+  /*printf("NPP_URLNotify()\n");*/
+  /***** Insert NPP_URLNotify code here *****\
+         PluginInstance* This;
+         if (instance != NULL)
+         This = (PluginInstance*) instance->pdata;
+         \*********************************************/
 }
 
 
 void
 NPP_Print(NPP instance, NPPrint* printInfo)
 {
-    /*printf("NPP_Print()\n");*/
-    if(printInfo == NULL)
-        return;
-
-    if (instance != NULL) {
-    /***** Insert NPP_Print code here *****\
-        PluginInstance* This = (PluginInstance*) instance->pdata;
-    \**************************************/
-
-        if (printInfo->mode == NP_FULL) {
-            /*
-             * PLUGIN DEVELOPERS:
-             *  If your plugin would like to take over
-             *  printing completely when it is in full-screen mode,
-             *  set printInfo->pluginPrinted to TRUE and print your
-             *  plugin as you see fit.  If your plugin wants Netscape
-             *  to handle printing in this case, set
-             *  printInfo->pluginPrinted to FALSE (the default) and
-             *  do nothing.  If you do want to handle printing
-             *  yourself, printOne is true if the print button
-             *  (as opposed to the print menu) was clicked.
-             *  On the Macintosh, platformPrint is a THPrint; on
-             *  Windows, platformPrint is a structure
-             *  (defined in npapi.h) containing the printer name, port,
-             *  etc.
-             */
+  /*printf("NPP_Print()\n");*/
+  if(printInfo == NULL)
+    return;
 
+  if (instance != NULL) {
     /***** Insert NPP_Print code here *****\
-            void* platformPrint =
-                printInfo->print.fullPrint.platformPrint;
-            NPBool printOne =
-                printInfo->print.fullPrint.printOne;
-    \**************************************/
-
-            /* Do the default*/
-            printInfo->print.fullPrint.pluginPrinted = FALSE;
-        }
-        else {  /* If not fullscreen, we must be embedded */
+           PluginInstance* This = (PluginInstance*) instance->pdata;
+           \**************************************/
+
+    if (printInfo->mode == NP_FULL) {
+      /*
+       * PLUGIN DEVELOPERS:
+       *  If your plugin would like to take over
+       *  printing completely when it is in full-screen mode,
+       *  set printInfo->pluginPrinted to TRUE and print your
+       *  plugin as you see fit.  If your plugin wants Netscape
+       *  to handle printing in this case, set
+       *  printInfo->pluginPrinted to FALSE (the default) and
+       *  do nothing.  If you do want to handle printing
+       *  yourself, printOne is true if the print button
+       *  (as opposed to the print menu) was clicked.
+       *  On the Macintosh, platformPrint is a THPrint; on
+       *  Windows, platformPrint is a structure
+       *  (defined in npapi.h) containing the printer name, port,
+       *  etc.
+       */
+
+      /***** Insert NPP_Print code here *****\
+             void* platformPrint =
+             printInfo->print.fullPrint.platformPrint;
+             NPBool printOne =
+             printInfo->print.fullPrint.printOne;
+             \**************************************/
+
+      /* Do the default*/
+      printInfo->print.fullPrint.pluginPrinted = FALSE;
+    }
+    else {  /* If not fullscreen, we must be embedded */
             /*
              * PLUGIN DEVELOPERS:
              *  If your plugin is embedded, or is full-screen
@@ -368,14 +368,14 @@ NPP_Print(NPP instance, NPPrint* printInfo)
              *  device context.
              */
 
-    /***** Insert NPP_Print code here *****\
-            NPWindow* printWindow =
-                &(printInfo->print.embedPrint.window);
-            void* platformPrint =
-                printInfo->print.embedPrint.platformPrint;
-    \**************************************/
-        }
+      /***** Insert NPP_Print code here *****\
+             NPWindow* printWindow =
+             &(printInfo->print.embedPrint.window);
+             void* platformPrint =
+             printInfo->print.embedPrint.platformPrint;
+             \**************************************/
     }
+  }
 }
 
 int16 NPP_HandleEvent(NPP instance, void* event)
diff --git a/plugin/npunix.c b/plugin/npunix.c
index 67a72f0..fb80ea2 100644
--- a/plugin/npunix.c
+++ b/plugin/npunix.c
@@ -93,7 +93,7 @@ static NPNetscapeFuncs   gNetscapeFuncs;    /* Netscape Function table */
 
 void
 NPN_Version(int* plugin_major, int* plugin_minor,
-         int* netscape_major, int* netscape_minor)
+            int* netscape_major, int* netscape_minor)
 {
     *plugin_major = NP_VERSION_MAJOR;
     *plugin_minor = NP_VERSION_MINOR;
@@ -108,14 +108,14 @@ NPError
 NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
 {
     return CallNPN_GetValueProc(gNetscapeFuncs.getvalue,
-                    instance, variable, r_value);
+                                instance, variable, r_value);
 }
 
 NPError
 NPN_SetValue(NPP instance, NPPVariable variable, void *value)
 {
     return CallNPN_SetValueProc(gNetscapeFuncs.setvalue,
-                    instance, variable, value);
+                                instance, variable, value);
 }
 
 NPError
@@ -132,10 +132,10 @@ NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notify
 
 NPError
 NPN_PostURL(NPP instance, const char* url, const char* window,
-         uint32 len, const char* buf, NPBool file)
+            uint32 len, const char* buf, NPBool file)
 {
     return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance,
-                    url, window, len, buf, file);
+                               url, window, len, buf, file);
 }
 
 NPError
@@ -143,36 +143,36 @@ NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len,
                   const char* buf, NPBool file, void* notifyData)
 {
     return CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify,
-            instance, url, window, len, buf, file, notifyData);
+                                     instance, url, window, len, buf, file, notifyData);
 }
 
 NPError
 NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
 {
     return CallNPN_RequestReadProc(gNetscapeFuncs.requestread,
-                    stream, rangeList);
+                                   stream, rangeList);
 }
 
 NPError
 NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
-          NPStream** stream_ptr)
+              NPStream** stream_ptr)
 {
     return CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance,
-                    type, window, stream_ptr);
+                                 type, window, stream_ptr);
 }
 
 int32
 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
 {
     return CallNPN_WriteProc(gNetscapeFuncs.write, instance,
-                    stream, len, buffer);
+                             stream, len, buffer);
 }
 
 NPError
 NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
 {
     return CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream,
-                        instance, stream, reason);
+                                     instance, stream, reason);
 }
 
 void
@@ -217,7 +217,7 @@ JRIEnv* NPN_GetJavaEnv()
 jref NPN_GetJavaPeer(NPP instance)
 {
     return CallNPN_GetJavaPeerProc(gNetscapeFuncs.getJavaPeer,
-                       instance);
+                                   instance);
 }
 #endif
 
@@ -225,14 +225,14 @@ void
 NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
 {
     CallNPN_InvalidateRectProc(gNetscapeFuncs.invalidaterect, instance,
-        invalidRect);
+                               invalidRect);
 }
 
 void
 NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
 {
     CallNPN_InvalidateRegionProc(gNetscapeFuncs.invalidateregion, instance,
-        invalidRegion);
+                                 invalidRegion);
 }
 
 void
@@ -244,13 +244,13 @@ NPN_ForceRedraw(NPP instance)
 void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
 {
     CallNPN_PushPopupsEnabledStateProc(gNetscapeFuncs.pushpopupsenabledstate,
-        instance, enabled);
+                                       instance, enabled);
 }
 
 void NPN_PopPopupsEnabledState(NPP instance)
 {
     CallNPN_PopPopupsEnabledStateProc(gNetscapeFuncs.poppopupsenabledstate,
-        instance);
+                                      instance);
 }
 
 
@@ -268,7 +268,7 @@ void NPN_PopPopupsEnabledState(NPP instance)
 
 static NPError
 Private_New(NPMIMEType pluginType, NPP instance, uint16 mode,
-        int16 argc, char* argn[], char* argv[], NPSavedData* saved)
+            int16 argc, char* argn[], char* argv[], NPSavedData* saved)
 {
     NPError ret;
     PLUGINDEBUGSTR("New");
@@ -299,7 +299,7 @@ Private_NewStream(NPP instance G_GNUC_UNUSED, NPMIMEType type G_GNUC_UNUSED,
 {
     NPError err = NPERR_NO_ERROR;
     PLUGINDEBUGSTR("NewStream");
-/*    err = NPP_NewStream(instance, type, stream, seekable, stype);*/
+    /*    err = NPP_NewStream(instance, type, stream, seekable, stype);*/
     return err;
 }
 
@@ -314,7 +314,7 @@ Private_WriteReady(NPP instance, NPStream* stream)
 
 static int32
 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
-        void* buffer)
+              void* buffer)
 {
     unsigned int result;
     PLUGINDEBUGSTR("Write");
@@ -341,7 +341,7 @@ Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
 
 static void
 Private_URLNotify(NPP instance, const char* url,
-                NPReason reason, void* notifyData)
+                  NPReason reason, void* notifyData)
 
 {
     PLUGINDEBUGSTR("URLNotify");
@@ -351,8 +351,8 @@ Private_URLNotify(NPP instance, const char* url,
 static NPError
 Private_GetValue(void *instance, NPPVariable variable, void *result)
 {
-	NPError rv = NPP_GetValue(instance, variable, result);
-	return rv;
+    NPError rv = NPP_GetValue(instance, variable, result);
+    return rv;
 }
 
 static void
@@ -368,8 +368,8 @@ Private_GetJavaClass(void)
 {
     jref clazz = NPP_GetJavaClass();
     if (clazz) {
-    JRIEnv* env = NPN_GetJavaEnv();
-    return JRI_NewGlobalRef(env, clazz);
+        JRIEnv* env = NPN_GetJavaEnv();
+        return JRI_NewGlobalRef(env, clazz);
     }
     return NULL;
 }
diff --git a/plugin/npupp.h b/plugin/npupp.h
index d8d7ee1..e1755a3 100644
--- a/plugin/npupp.h
+++ b/plugin/npupp.h
@@ -66,117 +66,117 @@
 
 /******************************************************************************************
    plug-in function table macros
- 	        for each function in and out of the plugin API we define
+                 for each function in and out of the plugin API we define
                     typedef NPP_FooUPP
-					#define NewNPP_FooProc
-					#define CallNPP_FooProc
- *******************************************************************************************/
+                                        #define NewNPP_FooProc
+                                        #define CallNPP_FooProc
+*******************************************************************************************/
 
 
 /* NPP_Initialize */
 typedef void (* NP_LOADDS NPP_InitializeUPP)(void);
-#define NewNPP_InitializeProc(FUNC)		\
-		((NPP_InitializeUPP) (FUNC))
-#define CallNPP_InitializeProc(FUNC)		\
-		(*(FUNC))()
+#define NewNPP_InitializeProc(FUNC)             \
+    ((NPP_InitializeUPP) (FUNC))
+#define CallNPP_InitializeProc(FUNC)            \
+    (*(FUNC))()
 
 /* NPP_Shutdown */
 typedef void (* NP_LOADDS NPP_ShutdownUPP)(void);
-#define NewNPP_ShutdownProc(FUNC)		\
-		((NPP_ShutdownUPP) (FUNC))
-#define CallNPP_ShutdownProc(FUNC)		\
-		(*(FUNC))()
+#define NewNPP_ShutdownProc(FUNC)               \
+    ((NPP_ShutdownUPP) (FUNC))
+#define CallNPP_ShutdownProc(FUNC)              \
+    (*(FUNC))()
 
 /* NPP_New */
-typedef NPError	(* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
-#define NewNPP_NewProc(FUNC)		\
-		((NPP_NewUPP) (FUNC))
-#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
+typedef NPError        (* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
+#define NewNPP_NewProc(FUNC)                    \
+    ((NPP_NewUPP) (FUNC))
+#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
 
 /* NPP_Destroy */
-typedef NPError	(* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save);
-#define NewNPP_DestroyProc(FUNC)		\
-		((NPP_DestroyUPP) (FUNC))
-#define CallNPP_DestroyProc(FUNC, ARG1, ARG2)		\
-		(*(FUNC))((ARG1), (ARG2))
+typedef NPError        (* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save);
+#define NewNPP_DestroyProc(FUNC)                \
+    ((NPP_DestroyUPP) (FUNC))
+#define CallNPP_DestroyProc(FUNC, ARG1, ARG2)   \
+    (*(FUNC))((ARG1), (ARG2))
 
 /* NPP_SetWindow */
-typedef NPError	(* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window);
-#define NewNPP_SetWindowProc(FUNC)		\
-		((NPP_SetWindowUPP) (FUNC))
-#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2)		\
-		(*(FUNC))((ARG1), (ARG2))
+typedef NPError        (* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window);
+#define NewNPP_SetWindowProc(FUNC)              \
+    ((NPP_SetWindowUPP) (FUNC))
+#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
+    (*(FUNC))((ARG1), (ARG2))
 
 /* NPP_NewStream */
-typedef NPError	(* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
-#define NewNPP_NewStreamProc(FUNC)		\
-		((NPP_NewStreamUPP) (FUNC))
-#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
+typedef NPError        (* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
+#define NewNPP_NewStreamProc(FUNC)              \
+    ((NPP_NewStreamUPP) (FUNC))
+#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
 
 /* NPP_DestroyStream */
-typedef NPError	(* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
-#define NewNPP_DestroyStreamProc(FUNC)		\
-		((NPP_DestroyStreamUPP) (FUNC))
-#define CallNPP_DestroyStreamProc(FUNC,  NPParg, NPStreamPtr, NPReasonArg)		\
-		(*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg))
+typedef NPError        (* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
+#define NewNPP_DestroyStreamProc(FUNC)          \
+    ((NPP_DestroyStreamUPP) (FUNC))
+#define CallNPP_DestroyStreamProc(FUNC,  NPParg, NPStreamPtr, NPReasonArg) \
+    (*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg))
 
 /* NPP_WriteReady */
 typedef int32 (* NP_LOADDS NPP_WriteReadyUPP)(NPP instance, NPStream* stream);
-#define NewNPP_WriteReadyProc(FUNC)		\
-		((NPP_WriteReadyUPP) (FUNC))
-#define CallNPP_WriteReadyProc(FUNC,  NPParg, NPStreamPtr)		\
-		(*(FUNC))((NPParg), (NPStreamPtr))
+#define NewNPP_WriteReadyProc(FUNC)             \
+    ((NPP_WriteReadyUPP) (FUNC))
+#define CallNPP_WriteReadyProc(FUNC,  NPParg, NPStreamPtr)  \
+    (*(FUNC))((NPParg), (NPStreamPtr))
 
 /* NPP_Write */
 typedef int32 (* NP_LOADDS NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
-#define NewNPP_WriteProc(FUNC)		\
-		((NPP_WriteUPP) (FUNC))
-#define CallNPP_WriteProc(FUNC,  NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr)		\
-		(*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
+#define NewNPP_WriteProc(FUNC)                  \
+    ((NPP_WriteUPP) (FUNC))
+#define CallNPP_WriteProc(FUNC,  NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
+    (*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
 
 /* NPP_StreamAsFile */
 typedef void (* NP_LOADDS NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname);
-#define NewNPP_StreamAsFileProc(FUNC)		\
-		((NPP_StreamAsFileUPP) (FUNC))
-#define CallNPP_StreamAsFileProc(FUNC,  ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+#define NewNPP_StreamAsFileProc(FUNC)           \
+    ((NPP_StreamAsFileUPP) (FUNC))
+#define CallNPP_StreamAsFileProc(FUNC,  ARG1, ARG2, ARG3)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPP_Print */
 typedef void (* NP_LOADDS NPP_PrintUPP)(NPP instance, NPPrint* platformPrint);
-#define NewNPP_PrintProc(FUNC)		\
-		((NPP_PrintUPP) (FUNC))
-#define CallNPP_PrintProc(FUNC,  NPParg, NPPrintArg)		\
-		(*(FUNC))((NPParg), (NPPrintArg))
+#define NewNPP_PrintProc(FUNC)                  \
+    ((NPP_PrintUPP) (FUNC))
+#define CallNPP_PrintProc(FUNC,  NPParg, NPPrintArg)    \
+    (*(FUNC))((NPParg), (NPPrintArg))
 
 /* NPP_HandleEvent */
 typedef int16 (* NP_LOADDS NPP_HandleEventUPP)(NPP instance, void* event);
-#define NewNPP_HandleEventProc(FUNC)		\
-		((NPP_HandleEventUPP) (FUNC))
-#define CallNPP_HandleEventProc(FUNC,  NPParg, voidPtr)		\
-		(*(FUNC))((NPParg), (voidPtr))
+#define NewNPP_HandleEventProc(FUNC)            \
+    ((NPP_HandleEventUPP) (FUNC))
+#define CallNPP_HandleEventProc(FUNC,  NPParg, voidPtr) \
+    (*(FUNC))((NPParg), (voidPtr))
 
 /* NPP_URLNotify */
 typedef void (* NP_LOADDS NPP_URLNotifyUPP)(NPP instance, const char* url, NPReason reason, void* notifyData);
-#define NewNPP_URLNotifyProc(FUNC)		\
-		((NPP_URLNotifyUPP) (FUNC))
-#define CallNPP_URLNotifyProc(FUNC,  ARG1, ARG2, ARG3, ARG4)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+#define NewNPP_URLNotifyProc(FUNC)              \
+    ((NPP_URLNotifyUPP) (FUNC))
+#define CallNPP_URLNotifyProc(FUNC,  ARG1, ARG2, ARG3, ARG4)    \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
 
 /* NPP_GetValue */
-typedef NPError	(* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
-#define NewNPP_GetValueProc(FUNC)		\
-		((NPP_GetValueUPP) (FUNC))
-#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+typedef NPError        (* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
+#define NewNPP_GetValueProc(FUNC)               \
+    ((NPP_GetValueUPP) (FUNC))
+#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3)    \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPP_SetValue */
-typedef NPError	(* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
-#define NewNPP_SetValueProc(FUNC)		\
-		((NPP_SetValueUPP) (FUNC))
-#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+typedef NPError        (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
+#define NewNPP_SetValueProc(FUNC)               \
+    ((NPP_SetValueUPP) (FUNC))
+#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3)    \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /*
  *  Netscape entry points
@@ -184,325 +184,325 @@ typedef NPError	(* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable
 
 
 /* NPN_GetValue */
-typedef NPError	(* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
-#define NewNPN_GetValueProc(FUNC)		\
-		((NPN_GetValueUPP) (FUNC))
-#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+typedef NPError        (* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
+#define NewNPN_GetValueProc(FUNC)               \
+    ((NPN_GetValueUPP) (FUNC))
+#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3)    \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_SetValue */
-typedef NPError	(* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
-#define NewNPN_SetValueProc(FUNC)		\
-		((NPN_SetValueUPP) (FUNC))
-#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+typedef NPError        (* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
+#define NewNPN_SetValueProc(FUNC)               \
+    ((NPN_SetValueUPP) (FUNC))
+#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3)    \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_GetUrlNotify */
-typedef NPError	(* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData);
-#define NewNPN_GetURLNotifyProc(FUNC)		\
-		((NPN_GetURLNotifyUPP) (FUNC))
-#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+typedef NPError        (* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData);
+#define NewNPN_GetURLNotifyProc(FUNC)           \
+    ((NPN_GetURLNotifyUPP) (FUNC))
+#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4)  \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
 
 /* NPN_PostUrlNotify */
 typedef NPError (* NP_LOADDS NPN_PostURLNotifyUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData);
-#define NewNPN_PostURLNotifyProc(FUNC)		\
-		((NPN_PostURLNotifyUPP) (FUNC))
+#define NewNPN_PostURLNotifyProc(FUNC)          \
+    ((NPN_PostURLNotifyUPP) (FUNC))
 #define CallNPN_PostURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
 
 /* NPN_GetUrl */
-typedef NPError	(* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
-#define NewNPN_GetURLProc(FUNC)		\
-		((NPN_GetURLUPP) (FUNC))
-#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+typedef NPError        (* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
+#define NewNPN_GetURLProc(FUNC)                 \
+    ((NPN_GetURLUPP) (FUNC))
+#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3)  \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_PostUrl */
 typedef NPError (* NP_LOADDS NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
-#define NewNPN_PostURLProc(FUNC)		\
-		((NPN_PostURLUPP) (FUNC))
-#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
+#define NewNPN_PostURLProc(FUNC)                \
+    ((NPN_PostURLUPP) (FUNC))
+#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
 
 /* NPN_RequestRead */
-typedef NPError	(* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
-#define NewNPN_RequestReadProc(FUNC)		\
-		((NPN_RequestReadUPP) (FUNC))
-#define CallNPN_RequestReadProc(FUNC, stream, range)		\
-		(*(FUNC))((stream), (range))
+typedef NPError        (* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
+#define NewNPN_RequestReadProc(FUNC)            \
+    ((NPN_RequestReadUPP) (FUNC))
+#define CallNPN_RequestReadProc(FUNC, stream, range)    \
+    (*(FUNC))((stream), (range))
 
 /* NPN_NewStream */
-typedef NPError	(* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
-#define NewNPN_NewStreamProc(FUNC)		\
-		((NPN_NewStreamUPP) (FUNC))
-#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream)		\
-		(*(FUNC))((npp), (type), (window), (stream))
+typedef NPError        (* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
+#define NewNPN_NewStreamProc(FUNC)              \
+    ((NPN_NewStreamUPP) (FUNC))
+#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream)  \
+    (*(FUNC))((npp), (type), (window), (stream))
 
 /* NPN_Write */
 typedef int32 (* NP_LOADDS NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer);
-#define NewNPN_WriteProc(FUNC)		\
-		((NPN_WriteUPP) (FUNC))
-#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer)		\
-		(*(FUNC))((npp), (stream), (len), (buffer))
+#define NewNPN_WriteProc(FUNC)                  \
+    ((NPN_WriteUPP) (FUNC))
+#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer)   \
+    (*(FUNC))((npp), (stream), (len), (buffer))
 
 /* NPN_DestroyStream */
 typedef NPError (* NP_LOADDS NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
-#define NewNPN_DestroyStreamProc(FUNC)		\
-		((NPN_DestroyStreamUPP) (FUNC))
-#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason)		\
-		(*(FUNC))((npp), (stream), (reason))
+#define NewNPN_DestroyStreamProc(FUNC)          \
+    ((NPN_DestroyStreamUPP) (FUNC))
+#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason)    \
+    (*(FUNC))((npp), (stream), (reason))
 
 /* NPN_Status */
 typedef void (* NP_LOADDS NPN_StatusUPP)(NPP instance, const char* message);
-#define NewNPN_StatusProc(FUNC)		\
-		((NPN_StatusUPP) (FUNC))
-#define CallNPN_StatusProc(FUNC, npp, msg)		\
-		(*(FUNC))((npp), (msg))	
+#define NewNPN_StatusProc(FUNC)                 \
+    ((NPN_StatusUPP) (FUNC))
+#define CallNPN_StatusProc(FUNC, npp, msg)      \
+    (*(FUNC))((npp), (msg))        
 
 /* NPN_UserAgent */
-typedef const char*	(* NP_LOADDS NPN_UserAgentUPP)(NPP instance);
+typedef const char*        (* NP_LOADDS NPN_UserAgentUPP)(NPP instance);
 #define NewNPN_UserAgentProc(FUNC)              \
-                ((NPN_UserAgentUPP) (FUNC))
-#define CallNPN_UserAgentProc(FUNC, ARG1)               \
-                (*(FUNC))((ARG1))
+    ((NPN_UserAgentUPP) (FUNC))
+#define CallNPN_UserAgentProc(FUNC, ARG1)       \
+    (*(FUNC))((ARG1))
 
 /* NPN_MemAlloc */
 typedef void* (* NP_LOADDS NPN_MemAllocUPP)(uint32 size);
-#define NewNPN_MemAllocProc(FUNC)		\
-		((NPN_MemAllocUPP) (FUNC))
-#define CallNPN_MemAllocProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))	
+#define NewNPN_MemAllocProc(FUNC)               \
+    ((NPN_MemAllocUPP) (FUNC))
+#define CallNPN_MemAllocProc(FUNC, ARG1)        \
+    (*(FUNC))((ARG1))        
 
 /* NPN__MemFree */
 typedef void (* NP_LOADDS NPN_MemFreeUPP)(void* ptr);
-#define NewNPN_MemFreeProc(FUNC)		\
-		((NPN_MemFreeUPP) (FUNC))
-#define CallNPN_MemFreeProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))	
+#define NewNPN_MemFreeProc(FUNC)                \
+    ((NPN_MemFreeUPP) (FUNC))
+#define CallNPN_MemFreeProc(FUNC, ARG1)         \
+    (*(FUNC))((ARG1))        
 
 /* NPN_MemFlush */
 typedef uint32 (* NP_LOADDS NPN_MemFlushUPP)(uint32 size);
-#define NewNPN_MemFlushProc(FUNC)		\
-		((NPN_MemFlushUPP) (FUNC))
-#define CallNPN_MemFlushProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))	
+#define NewNPN_MemFlushProc(FUNC)               \
+    ((NPN_MemFlushUPP) (FUNC))
+#define CallNPN_MemFlushProc(FUNC, ARG1)        \
+    (*(FUNC))((ARG1))        
 
 /* NPN_ReloadPlugins */
 typedef void (* NP_LOADDS NPN_ReloadPluginsUPP)(NPBool reloadPages);
-#define NewNPN_ReloadPluginsProc(FUNC)		\
-		((NPN_ReloadPluginsUPP) (FUNC))
-#define CallNPN_ReloadPluginsProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))	
+#define NewNPN_ReloadPluginsProc(FUNC)          \
+    ((NPN_ReloadPluginsUPP) (FUNC))
+#define CallNPN_ReloadPluginsProc(FUNC, ARG1)   \
+    (*(FUNC))((ARG1))        
 
 /* NPN_GetJavaEnv */
 #ifdef OJI
 typedef JRIEnv* (* NP_LOADDS NPN_GetJavaEnvUPP)(void);
 #endif
-#define NewNPN_GetJavaEnvProc(FUNC)		\
-		((NPN_GetJavaEnvUPP) (FUNC))
-#define CallNPN_GetJavaEnvProc(FUNC)		\
-		(*(FUNC))()	
+#define NewNPN_GetJavaEnvProc(FUNC)             \
+    ((NPN_GetJavaEnvUPP) (FUNC))
+#define CallNPN_GetJavaEnvProc(FUNC)            \
+    (*(FUNC))()        
 
 /* NPN_GetJavaPeer */
 #ifdef OJI
 typedef jref (* NP_LOADDS NPN_GetJavaPeerUPP)(NPP instance);
 #endif
-#define NewNPN_GetJavaPeerProc(FUNC)		\
-		((NPN_GetJavaPeerUPP) (FUNC))
-#define CallNPN_GetJavaPeerProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))	
+#define NewNPN_GetJavaPeerProc(FUNC)            \
+    ((NPN_GetJavaPeerUPP) (FUNC))
+#define CallNPN_GetJavaPeerProc(FUNC, ARG1)     \
+    (*(FUNC))((ARG1))        
 
 /* NPN_InvalidateRect */
 typedef void (* NP_LOADDS NPN_InvalidateRectUPP)(NPP instance, NPRect *rect);
-#define NewNPN_InvalidateRectProc(FUNC)		\
-		((NPN_InvalidateRectUPP) (FUNC))
-#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2)		\
-		(*(FUNC))((ARG1), (ARG2))	
+#define NewNPN_InvalidateRectProc(FUNC)         \
+    ((NPN_InvalidateRectUPP) (FUNC))
+#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2)    \
+    (*(FUNC))((ARG1), (ARG2))        
 
 /* NPN_InvalidateRegion */
 typedef void (* NP_LOADDS NPN_InvalidateRegionUPP)(NPP instance, NPRegion region);
-#define NewNPN_InvalidateRegionProc(FUNC)		\
-		((NPN_InvalidateRegionUPP) (FUNC))
-#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2)		\
-		(*(FUNC))((ARG1), (ARG2))	
+#define NewNPN_InvalidateRegionProc(FUNC)       \
+    ((NPN_InvalidateRegionUPP) (FUNC))
+#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2)  \
+    (*(FUNC))((ARG1), (ARG2))        
 
 /* NPN_ForceRedraw */
 typedef void (* NP_LOADDS NPN_ForceRedrawUPP)(NPP instance);
-#define NewNPN_ForceRedrawProc(FUNC)		\
-		((NPN_ForceRedrawUPP) (FUNC))
-#define CallNPN_ForceRedrawProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))	
+#define NewNPN_ForceRedrawProc(FUNC)            \
+    ((NPN_ForceRedrawUPP) (FUNC))
+#define CallNPN_ForceRedrawProc(FUNC, ARG1)     \
+    (*(FUNC))((ARG1))        
 
 /* NPN_GetStringIdentifier */
 typedef NPIdentifier (* NP_LOADDS NPN_GetStringIdentifierUPP)(const NPUTF8* name);
-#define NewNPN_GetStringIdentifierProc(FUNC)		\
-		((NPN_GetStringIdentifierUPP) (FUNC))
-#define CallNPN_GetStringIdentifierProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_GetStringIdentifierProc(FUNC)    \
+    ((NPN_GetStringIdentifierUPP) (FUNC))
+#define CallNPN_GetStringIdentifierProc(FUNC, ARG1) \
+    (*(FUNC))((ARG1))
 
 /* NPN_GetStringIdentifiers */
 typedef void (* NP_LOADDS NPN_GetStringIdentifiersUPP)(const NPUTF8** names,
-                                                 int32_t nameCount,
-                                                 NPIdentifier* identifiers);
-#define NewNPN_GetStringIdentifiersProc(FUNC)		\
-		((NPN_GetStringIdentifiersUPP) (FUNC))
-#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+                                                       int32_t nameCount,
+                                                       NPIdentifier* identifiers);
+#define NewNPN_GetStringIdentifiersProc(FUNC)   \
+    ((NPN_GetStringIdentifiersUPP) (FUNC))
+#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3)    \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_GetIntIdentifier */
 typedef NPIdentifier (* NP_LOADDS NPN_GetIntIdentifierUPP)(int32_t intid);
-#define NewNPN_GetIntIdentifierProc(FUNC)		\
-		((NPN_GetIntIdentifierUPP) (FUNC))
-#define CallNPN_GetIntIdentifierProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_GetIntIdentifierProc(FUNC)       \
+    ((NPN_GetIntIdentifierUPP) (FUNC))
+#define CallNPN_GetIntIdentifierProc(FUNC, ARG1)    \
+    (*(FUNC))((ARG1))
 
 /* NPN_IdentifierIsString */
 typedef bool (* NP_LOADDS NPN_IdentifierIsStringUPP)(NPIdentifier identifier);
-#define NewNPN_IdentifierIsStringProc(FUNC)		\
-		((NPN_IdentifierIsStringUPP) (FUNC))
-#define CallNPN_IdentifierIsStringProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_IdentifierIsStringProc(FUNC)     \
+    ((NPN_IdentifierIsStringUPP) (FUNC))
+#define CallNPN_IdentifierIsStringProc(FUNC, ARG1)  \
+    (*(FUNC))((ARG1))
 
 /* NPN_UTF8FromIdentifier */
 typedef NPUTF8* (* NP_LOADDS NPN_UTF8FromIdentifierUPP)(NPIdentifier identifier);
-#define NewNPN_UTF8FromIdentifierProc(FUNC)		\
-		((NPN_UTF8FromIdentifierUPP) (FUNC))
-#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_UTF8FromIdentifierProc(FUNC)     \
+    ((NPN_UTF8FromIdentifierUPP) (FUNC))
+#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1)  \
+    (*(FUNC))((ARG1))
 
 /* NPN_IntFromIdentifier */
 typedef int32_t (* NP_LOADDS NPN_IntFromIdentifierUPP)(NPIdentifier identifier);
-#define NewNPN_IntFromIdentifierProc(FUNC)		\
-		((NPN_IntFromIdentifierUPP) (FUNC))
-#define CallNPN_IntFromIdentifierProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_IntFromIdentifierProc(FUNC)      \
+    ((NPN_IntFromIdentifierUPP) (FUNC))
+#define CallNPN_IntFromIdentifierProc(FUNC, ARG1)   \
+    (*(FUNC))((ARG1))
 
 /* NPN_CreateObject */
 typedef NPObject* (* NP_LOADDS NPN_CreateObjectUPP)(NPP npp, NPClass *aClass);
-#define NewNPN_CreateObjectProc(FUNC)		\
-		((NPN_CreateObjectUPP) (FUNC))
-#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2)		\
-		(*(FUNC))((ARG1), (ARG2))
+#define NewNPN_CreateObjectProc(FUNC)           \
+    ((NPN_CreateObjectUPP) (FUNC))
+#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2)  \
+    (*(FUNC))((ARG1), (ARG2))
 
 /* NPN_RetainObject */
 typedef NPObject* (* NP_LOADDS NPN_RetainObjectUPP)(NPObject *obj);
-#define NewNPN_RetainObjectProc(FUNC)		\
-		((NPN_RetainObjectUPP) (FUNC))
-#define CallNPN_RetainObjectProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_RetainObjectProc(FUNC)           \
+    ((NPN_RetainObjectUPP) (FUNC))
+#define CallNPN_RetainObjectProc(FUNC, ARG1)    \
+    (*(FUNC))((ARG1))
 
 /* NPN_ReleaseObject */
 typedef void (* NP_LOADDS NPN_ReleaseObjectUPP)(NPObject *obj);
-#define NewNPN_ReleaseObjectProc(FUNC)		\
-		((NPN_ReleaseObjectUPP) (FUNC))
-#define CallNPN_ReleaseObjectProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_ReleaseObjectProc(FUNC)          \
+    ((NPN_ReleaseObjectUPP) (FUNC))
+#define CallNPN_ReleaseObjectProc(FUNC, ARG1)   \
+    (*(FUNC))((ARG1))
 
 /* NPN_Invoke */
 typedef bool (* NP_LOADDS NPN_InvokeUPP)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
-#define NewNPN_InvokeProc(FUNC)		\
-		((NPN_InvokeUPP) (FUNC))
-#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
+#define NewNPN_InvokeProc(FUNC)                 \
+    ((NPN_InvokeUPP) (FUNC))
+#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)    \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
 
 /* NPN_InvokeDefault */
 typedef bool (* NP_LOADDS NPN_InvokeDefaultUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
-#define NewNPN_InvokeDefaultProc(FUNC)		\
-		((NPN_InvokeDefaultUPP) (FUNC))
-#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
+#define NewNPN_InvokeDefaultProc(FUNC)          \
+    ((NPN_InvokeDefaultUPP) (FUNC))
+#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
 
 /* NPN_Evaluate */
 typedef bool (* NP_LOADDS NPN_EvaluateUPP)(NPP npp, NPObject *obj, NPString *script, NPVariant *result);
-#define NewNPN_EvaluateProc(FUNC)		\
-		((NPN_EvaluateUPP) (FUNC))
-#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+#define NewNPN_EvaluateProc(FUNC)               \
+    ((NPN_EvaluateUPP) (FUNC))
+#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4)  \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
 
 /* NPN_GetProperty */
 typedef bool (* NP_LOADDS NPN_GetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result);
-#define NewNPN_GetPropertyProc(FUNC)		\
-		((NPN_GetPropertyUPP) (FUNC))
-#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+#define NewNPN_GetPropertyProc(FUNC)            \
+    ((NPN_GetPropertyUPP) (FUNC))
+#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
 
 /* NPN_SetProperty */
 typedef bool (* NP_LOADDS NPN_SetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value);
-#define NewNPN_SetPropertyProc(FUNC)		\
-		((NPN_SetPropertyUPP) (FUNC))
-#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+#define NewNPN_SetPropertyProc(FUNC)            \
+    ((NPN_SetPropertyUPP) (FUNC))
+#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
 
 /* NPN_RemoveProperty */
 typedef bool (* NP_LOADDS NPN_RemovePropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
-#define NewNPN_RemovePropertyProc(FUNC)		\
-		((NPN_RemovePropertyUPP) (FUNC))
-#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+#define NewNPN_RemovePropertyProc(FUNC)         \
+    ((NPN_RemovePropertyUPP) (FUNC))
+#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3)  \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_HasProperty */
 typedef bool (* NP_LOADDS NPN_HasPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
-#define NewNPN_HasPropertyProc(FUNC)		\
-		((NPN_HasPropertyUPP) (FUNC))
-#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+#define NewNPN_HasPropertyProc(FUNC)            \
+    ((NPN_HasPropertyUPP) (FUNC))
+#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3) \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_HasMethod */
 typedef bool (* NP_LOADDS NPN_HasMethodUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
-#define NewNPN_HasMethodProc(FUNC)		\
-		((NPN_HasMethodUPP) (FUNC))
-#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+#define NewNPN_HasMethodProc(FUNC)              \
+    ((NPN_HasMethodUPP) (FUNC))
+#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_ReleaseVariantValue */
 typedef void (* NP_LOADDS NPN_ReleaseVariantValueUPP)(NPVariant *variant);
-#define NewNPN_ReleaseVariantValueProc(FUNC)		\
-		((NPN_ReleaseVariantValueUPP) (FUNC))
-#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_ReleaseVariantValueProc(FUNC)    \
+    ((NPN_ReleaseVariantValueUPP) (FUNC))
+#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1) \
+    (*(FUNC))((ARG1))
 
 /* NPN_SetException */
 typedef void (* NP_LOADDS NPN_SetExceptionUPP)(NPObject *obj, const NPUTF8 *message);
-#define NewNPN_SetExceptionProc(FUNC)		\
-		((NPN_SetExceptionUPP) (FUNC))
-#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2)		\
-		(*(FUNC))((ARG1), (ARG2))	
+#define NewNPN_SetExceptionProc(FUNC)           \
+    ((NPN_SetExceptionUPP) (FUNC))
+#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2)  \
+    (*(FUNC))((ARG1), (ARG2))        
 
 /* NPN_PushPopupsEnabledStateUPP */
 typedef bool (* NP_LOADDS NPN_PushPopupsEnabledStateUPP)(NPP npp, NPBool enabled);
-#define NewNPN_PushPopupsEnabledStateProc(FUNC)		\
-		((NPN_PushPopupsEnabledStateUPP) (FUNC))
-#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2)		\
-		(*(FUNC))((ARG1), (ARG2))
+#define NewNPN_PushPopupsEnabledStateProc(FUNC) \
+    ((NPN_PushPopupsEnabledStateUPP) (FUNC))
+#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2)    \
+    (*(FUNC))((ARG1), (ARG2))
 
 /* NPN_PopPopupsEnabledState */
 typedef bool (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp);
-#define NewNPN_PopPopupsEnabledStateProc(FUNC)		\
-		((NPN_PopPopupsEnabledStateUPP) (FUNC))
-#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1)		\
-		(*(FUNC))((ARG1))
+#define NewNPN_PopPopupsEnabledStateProc(FUNC)  \
+    ((NPN_PopPopupsEnabledStateUPP) (FUNC))
+#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1)   \
+    (*(FUNC))((ARG1))
 
 /* NPN_Enumerate */
 typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count);
-#define NewNPN_EnumerateProc(FUNC)		\
-		((NPN_EnumerateUPP) (FUNC))
-#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+#define NewNPN_EnumerateProc(FUNC)              \
+    ((NPN_EnumerateUPP) (FUNC))
+#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
 
 /* NPN_PluginThreadAsyncCall */
 typedef void (* NP_LOADDS NPN_PluginThreadAsyncCallUPP)(NPP instance, void (*func)(void *), void *userData);
-#define NewNPN_PluginThreadAsyncCallProc(FUNC) \
-		((NPN_PluginThreadAsyncCallUPP) (FUNC))
-#define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3) \
-		(*(FUNC))((ARG1), (ARG2), (ARG3))
+#define NewNPN_PluginThreadAsyncCallProc(FUNC)  \
+    ((NPN_PluginThreadAsyncCallUPP) (FUNC))
+#define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3))
 
 /* NPN_Construct */
 typedef bool (* NP_LOADDS NPN_ConstructUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
-#define NewNPN_ConstructProc(FUNC)		\
-		((NPN_ConstructUPP) (FUNC))
-#define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)      \
-		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
+#define NewNPN_ConstructProc(FUNC)              \
+    ((NPN_ConstructUPP) (FUNC))
+#define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)   \
+    (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
 
 
 
@@ -596,10 +596,10 @@ typedef struct _NPNetscapeFuncs {
  * and NPPShutdownUPP for Netscape's use.
  */
 typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*);
-#define NewNPP_MainEntryProc(FUNC)		\
-		((NPP_MainEntryUPP) (FUNC))
-#define CallNPP_MainEntryProc(FUNC,  netscapeFunc, pluginFunc, shutdownUPP)		\
-		(*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
+#define NewNPP_MainEntryProc(FUNC)              \
+    ((NPP_MainEntryUPP) (FUNC))
+#define CallNPP_MainEntryProc(FUNC,  netscapeFunc, pluginFunc, shutdownUPP) \
+    (*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
 
 /*
  * Mac OS X version(s) of NP_GetMIMEDescription(const char *)
@@ -611,32 +611,32 @@ typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*,
  */
 
 enum
-{
- kBPSupportedMIMETypesStructVers_1    = 1
-};
+    {
+        kBPSupportedMIMETypesStructVers_1    = 1
+    };
 
 typedef struct _BPSupportedMIMETypes
 {
- SInt32    structVersion;      /* struct version */
- Handle    typeStrings;        /* STR# formated handle, allocated by plug-in */
- Handle    infoStrings;        /* STR# formated handle, allocated by plug-in */
+    SInt32    structVersion;      /* struct version */
+    Handle    typeStrings;        /* STR# formated handle, allocated by plug-in */
+    Handle    infoStrings;        /* STR# formated handle, allocated by plug-in */
 } BPSupportedMIMETypes;
 OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags);
 
- /* NP_GetMIMEDescription */
+/* NP_GetMIMEDescription */
 #define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription"
 typedef const char* (* NP_LOADDS NP_GetMIMEDescriptionUPP)();
-#define NewNP_GetMIMEDescEntryProc(FUNC)		\
-		((NP_GetMIMEDescriptionUPP) (FUNC))
-#define CallNP_GetMIMEDescEntryProc(FUNC)		\
-		(*(FUNC))()
+#define NewNP_GetMIMEDescEntryProc(FUNC)        \
+    ((NP_GetMIMEDescriptionUPP) (FUNC))
+#define CallNP_GetMIMEDescEntryProc(FUNC)       \
+    (*(FUNC))()
 
 /* BP_GetSupportedMIMETypes */
 typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, UInt32);
-#define NewBP_GetSupportedMIMETypesEntryProc(FUNC)		\
-		((BP_GetSupportedMIMETypesUPP) (FUNC))
-#define CallBP_GetMIMEDescEntryProc(FUNC,  mimeInfo, flags)		\
-		(*(FUNC))((mimeInfo), (flags))
+#define NewBP_GetSupportedMIMETypesEntryProc(FUNC)  \
+    ((BP_GetSupportedMIMETypesUPP) (FUNC))
+#define CallBP_GetMIMEDescEntryProc(FUNC,  mimeInfo, flags) \
+    (*(FUNC))((mimeInfo), (flags))
 
 #endif /* XP_MACOSX */
 
@@ -652,7 +652,7 @@ typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, U
 
 #if defined(XP_UNIX)
 /* GCC 3.3 and later support the visibility attribute. */
-#if defined(__GNUC__) && \
+#if defined(__GNUC__) &&                                        \
     ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
 #define NP_VISIBILITY_DEFAULT __attribute__((visibility("default")))
 #else
@@ -668,30 +668,30 @@ typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, U
 extern "C" {
 #endif
 
-/* plugin meta member functions */
+    /* plugin meta member functions */
 #if defined(__OS2__)
 
-typedef struct _NPPluginData {   /* Alternate OS2 Plugin interface */
-    char *pMimeTypes;
-    char *pFileExtents;
-    char *pFileOpenTemplate;
-    char *pProductName;
-    char *pProductDescription;
-    unsigned long dwProductVersionMS;
-    unsigned long dwProductVersionLS;
-} NPPluginData;
+    typedef struct _NPPluginData {   /* Alternate OS2 Plugin interface */
+        char *pMimeTypes;
+        char *pFileExtents;
+        char *pFileOpenTemplate;
+        char *pProductName;
+        char *pProductDescription;
+        unsigned long dwProductVersionMS;
+        unsigned long dwProductVersionLS;
+    } NPPluginData;
 
-NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData);
+    NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData);
 
 #endif
 
-NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
+    NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
 
-NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs);
+    NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs);
 
-NPError OSCALL NP_Shutdown();
+    NPError OSCALL NP_Shutdown();
 
-char*	NP_GetMIMEDescription();
+    char*        NP_GetMIMEDescription();
 
 #ifdef __cplusplus
 }
@@ -709,12 +709,12 @@ char*	NP_GetMIMEDescription();
 extern "C" {
 #endif
 
-/* plugin meta member functions */
+    /* plugin meta member functions */
 
-NP_EXPORT(char*)   NP_GetMIMEDescription(void);
-NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*);
-NP_EXPORT(NPError) NP_Shutdown(void);
-NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue);
+    NP_EXPORT(char*)   NP_GetMIMEDescription(void);
+    NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*);
+    NP_EXPORT(NPError) NP_Shutdown(void);
+    NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue);
 
 #ifdef __cplusplus
 }
diff --git a/src/continuation.c b/src/continuation.c
index 4f5b027..15ad8c1 100644
--- a/src/continuation.c
+++ b/src/continuation.c
@@ -28,62 +28,62 @@
  * union is a quick hack to let us do that
  */
 union cc_arg {
-	void *p;
-	int i[2];
+    void *p;
+    int i[2];
 };
 
 static void continuation_trampoline(int i0, int i1)
 {
-	union cc_arg arg;
-	struct continuation *cc;
-	arg.i[0] = i0;
-	arg.i[1] = i1;
-	cc = arg.p;
+    union cc_arg arg;
+    struct continuation *cc;
+    arg.i[0] = i0;
+    arg.i[1] = i1;
+    cc = arg.p;
 
-	cc->entry(cc);
+    cc->entry(cc);
 }
 
 int cc_init(struct continuation *cc)
 {
-	volatile union cc_arg arg;
-	arg.p = cc;
-	if (getcontext(&cc->uc) == -1)
-		return -1;
+    volatile union cc_arg arg;
+    arg.p = cc;
+    if (getcontext(&cc->uc) == -1)
+        return -1;
 
-	cc->uc.uc_link = &cc->last;
-	cc->uc.uc_stack.ss_sp = cc->stack;
-	cc->uc.uc_stack.ss_size = cc->stack_size;
-	cc->uc.uc_stack.ss_flags = 0;
+    cc->uc.uc_link = &cc->last;
+    cc->uc.uc_stack.ss_sp = cc->stack;
+    cc->uc.uc_stack.ss_size = cc->stack_size;
+    cc->uc.uc_stack.ss_flags = 0;
 
-	makecontext(&cc->uc, (void *)continuation_trampoline, 2, arg.i[0], arg.i[1]);
+    makecontext(&cc->uc, (void *)continuation_trampoline, 2, arg.i[0], arg.i[1]);
 
-	return 0;
+    return 0;
 }
 
 int cc_release(struct continuation *cc)
 {
-	if (cc->release)
-		return cc->release(cc);
+    if (cc->release)
+        return cc->release(cc);
 
-	return 0;
+    return 0;
 }
 
 int cc_swap(struct continuation *from, struct continuation *to)
 {
-	to->exited = 0;
-	if (getcontext(&to->last) == -1)
-		return -1;
-	else if (to->exited == 0)
-		to->exited = 1;
-	else if (to->exited == 1)
-		return 1;
+    to->exited = 0;
+    if (getcontext(&to->last) == -1)
+        return -1;
+    else if (to->exited == 0)
+        to->exited = 1;
+    else if (to->exited == 1)
+        return 1;
 
-	return swapcontext(&from->uc, &to->uc);
+    return swapcontext(&from->uc, &to->uc);
 }
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/continuation.h b/src/continuation.h
index 585788e..46f7a71 100644
--- a/src/continuation.h
+++ b/src/continuation.h
@@ -25,15 +25,15 @@
 
 struct continuation
 {
-	char *stack;
-	size_t stack_size;
-	void (*entry)(struct continuation *cc);
-	int (*release)(struct continuation *cc);
-
-	/* private */
-	ucontext_t uc;
-	ucontext_t last;
-	int exited;
+    char *stack;
+    size_t stack_size;
+    void (*entry)(struct continuation *cc);
+    int (*release)(struct continuation *cc);
+
+    /* private */
+    ucontext_t uc;
+    ucontext_t last;
+    int exited;
 };
 
 int cc_init(struct continuation *cc);
@@ -45,14 +45,14 @@ int cc_release(struct continuation *cc);
 int cc_swap(struct continuation *from, struct continuation *to);
 
 #define offset_of(type, member) ((unsigned long)(&((type *)0)->member))
-#define container_of(obj, type, member) \
-        (type *)(((char *)obj) - offset_of(type, member))
+#define container_of(obj, type, member)                 \
+    (type *)(((char *)obj) - offset_of(type, member))
 
 #endif
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/coroutine.h b/src/coroutine.h
index 90ad9e8..a3a9b57 100644
--- a/src/coroutine.h
+++ b/src/coroutine.h
@@ -31,22 +31,22 @@
 
 struct coroutine
 {
-	size_t stack_size;
-	void *(*entry)(void *);
-	int (*release)(struct coroutine *);
+    size_t stack_size;
+    void *(*entry)(void *);
+    int (*release)(struct coroutine *);
 
-	/* read-only */
-	int exited;
+    /* read-only */
+    int exited;
 
-	/* private */
-	struct coroutine *caller;
-	void *data;
+    /* private */
+    struct coroutine *caller;
+    void *data;
 
 #if WITH_UCONTEXT
-	struct continuation cc;
+    struct continuation cc;
 #else
-	GThread *thread;
-	gboolean runnable;
+    GThread *thread;
+    gboolean runnable;
 #endif
 };
 
@@ -65,8 +65,8 @@ void *coroutine_yield(void *arg);
 #endif
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/coroutine_gthread.c b/src/coroutine_gthread.c
index 14231a0..2fe56ba 100644
--- a/src/coroutine_gthread.c
+++ b/src/coroutine_gthread.c
@@ -37,127 +37,133 @@ static struct coroutine leader;
 
 static void coroutine_system_init(void)
 {
-	if (!g_thread_supported()) {
-	        CO_DEBUG("INIT");
-		g_thread_init(NULL);
-	}
-
-
-	run_cond = g_cond_new();
-	run_lock = g_mutex_new();
-	CO_DEBUG("LOCK");
-	g_mutex_lock(run_lock);
-
-	/* The thread that creates the first coroutine is the system coroutine
-	 * so let's fill out a structure for it */
-	leader.entry = NULL;
-	leader.release = NULL;
-	leader.stack_size = 0;
-	leader.exited = 0;
-	leader.thread = g_thread_self();
-	leader.runnable = TRUE; /* we're the one running right now */
-	leader.caller = NULL;
-	leader.data = NULL;
-
-	current = &leader;
+    if (!g_thread_supported()) {
+        CO_DEBUG("INIT");
+        g_thread_init(NULL);
+    }
+
+
+    run_cond = g_cond_new();
+    run_lock = g_mutex_new();
+    CO_DEBUG("LOCK");
+    g_mutex_lock(run_lock);
+
+    /* The thread that creates the first coroutine is the system coroutine
+     * so let's fill out a structure for it */
+    leader.entry = NULL;
+    leader.release = NULL;
+    leader.stack_size = 0;
+    leader.exited = 0;
+    leader.thread = g_thread_self();
+    leader.runnable = TRUE; /* we're the one running right now */
+    leader.caller = NULL;
+    leader.data = NULL;
+
+    current = &leader;
 }
 
 static gpointer coroutine_thread(gpointer opaque)
 {
-	struct coroutine *co = opaque;
-	CO_DEBUG("LOCK");
-	g_mutex_lock(run_lock);
-	while (!co->runnable) {
-		CO_DEBUG("WAIT");
-		g_cond_wait(run_cond, run_lock);
-	}
-
-	CO_DEBUG("RUNNABLE");
-	current = co;
-	co->data = co->entry(co->data);
-	co->exited = 1;
-
-	co->caller->runnable = TRUE;
-	CO_DEBUG("BROADCAST");
-	g_cond_broadcast(run_cond);
-	CO_DEBUG("UNLOCK");
-	g_mutex_unlock(run_lock);
-
-	return NULL;
+    struct coroutine *co = opaque;
+    CO_DEBUG("LOCK");
+    g_mutex_lock(run_lock);
+    while (!co->runnable) {
+        CO_DEBUG("WAIT");
+        g_cond_wait(run_cond, run_lock);
+    }
+
+    CO_DEBUG("RUNNABLE");
+    current = co;
+    co->data = co->entry(co->data);
+    co->exited = 1;
+
+    co->caller->runnable = TRUE;
+    CO_DEBUG("BROADCAST");
+    g_cond_broadcast(run_cond);
+    CO_DEBUG("UNLOCK");
+    g_mutex_unlock(run_lock);
+
+    return NULL;
 }
 
 int coroutine_init(struct coroutine *co)
 {
-	if (run_cond == NULL)
-		coroutine_system_init();
-
-	CO_DEBUG("NEW");
-	co->thread = g_thread_create_full(coroutine_thread, co, co->stack_size,
-					  FALSE, TRUE,
-					  G_THREAD_PRIORITY_NORMAL,
-					  NULL);
-	if (co->thread == NULL)
-		return -1;
-
-	co->exited = 0;
-	co->runnable = FALSE;
-	co->caller = NULL;
-
-	return 0;
+    if (run_cond == NULL)
+        coroutine_system_init();
+
+    CO_DEBUG("NEW");
+    co->thread = g_thread_create_full(coroutine_thread, co, co->stack_size,
+                                      FALSE, TRUE,
+                                      G_THREAD_PRIORITY_NORMAL,
+                                      NULL);
+    if (co->thread == NULL)
+        return -1;
+
+    co->exited = 0;
+    co->runnable = FALSE;
+    co->caller = NULL;
+
+    return 0;
 }
 
 int coroutine_release(struct coroutine *co G_GNUC_UNUSED)
 {
-	return 0;
+    return 0;
 }
 
 void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
 {
-	from->runnable = FALSE;
-	to->runnable = TRUE;
-	to->data = arg;
-	to->caller = from;
-	CO_DEBUG("BROADCAST");
-	g_cond_broadcast(run_cond);
-	CO_DEBUG("UNLOCK");
-	g_mutex_unlock(run_lock);
-	CO_DEBUG("LOCK");
-	g_mutex_lock(run_lock);
-	while (!from->runnable) {
-	        CO_DEBUG("WAIT");
-		g_cond_wait(run_cond, run_lock);
-	}
-	current = from;
-
-	CO_DEBUG("SWAPPED");
-	return from->data;
+    from->runnable = FALSE;
+    to->runnable = TRUE;
+    to->data = arg;
+    to->caller = from;
+    CO_DEBUG("BROADCAST");
+    g_cond_broadcast(run_cond);
+    CO_DEBUG("UNLOCK");
+    g_mutex_unlock(run_lock);
+    CO_DEBUG("LOCK");
+    g_mutex_lock(run_lock);
+    while (!from->runnable) {
+        CO_DEBUG("WAIT");
+        g_cond_wait(run_cond, run_lock);
+    }
+    current = from;
+
+    CO_DEBUG("SWAPPED");
+    return from->data;
 }
 
 struct coroutine *coroutine_self(void)
 {
-	return current;
+    return current;
 }
 
 void *coroutine_yieldto(struct coroutine *to, void *arg)
 {
-	if (to->caller) {
-		fprintf(stderr, "Co-routine is re-entering itself\n");
-		abort();
-	}
-	CO_DEBUG("SWAP");
-	return coroutine_swap(coroutine_self(), to, arg);
+    if (to->caller) {
+        fprintf(stderr, "Co-routine is re-entering itself\n");
+        abort();
+    }
+    CO_DEBUG("SWAP");
+    return coroutine_swap(coroutine_self(), to, arg);
 }
 
 void *coroutine_yield(void *arg)
 {
-	struct coroutine *to = coroutine_self()->caller;
-	if (!to) {
-		fprintf(stderr, "Co-routine is yielding to no one\n");
-		abort();
-	}
-
-	CO_DEBUG("SWAP");
-	coroutine_self()->caller = NULL;
-	return coroutine_swap(coroutine_self(), to, arg);
+    struct coroutine *to = coroutine_self()->caller;
+    if (!to) {
+        fprintf(stderr, "Co-routine is yielding to no one\n");
+        abort();
+    }
+
+    CO_DEBUG("SWAP");
+    coroutine_self()->caller = NULL;
+    return coroutine_swap(coroutine_self(), to, arg);
 }
-
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/coroutine_ucontext.c b/src/coroutine_ucontext.c
index 91059ad..a97e2b1 100644
--- a/src/coroutine_ucontext.c
+++ b/src/coroutine_ucontext.c
@@ -28,47 +28,47 @@
 
 int coroutine_release(struct coroutine *co)
 {
-	return cc_release(&co->cc);
+    return cc_release(&co->cc);
 }
 
 static int _coroutine_release(struct continuation *cc)
 {
-	struct coroutine *co = container_of(cc, struct coroutine, cc);
+    struct coroutine *co = container_of(cc, struct coroutine, cc);
 
-	if (co->release) {
-		int ret = co->release(co);
-		if (ret < 0)
-			return ret;
-	}
+    if (co->release) {
+        int ret = co->release(co);
+        if (ret < 0)
+            return ret;
+    }
 
-	co->caller = NULL;
+    co->caller = NULL;
 
-	return 0;
+    return 0;
 }
 
 static void coroutine_trampoline(struct continuation *cc)
 {
-	struct coroutine *co = container_of(cc, struct coroutine, cc);
-	co->data = co->entry(co->data);
+    struct coroutine *co = container_of(cc, struct coroutine, cc);
+    co->data = co->entry(co->data);
 }
 
 int coroutine_init(struct coroutine *co)
 {
-	if (co->stack_size == 0)
-		co->stack_size = 16 << 20;
-
-	co->cc.stack_size = co->stack_size;
-	co->cc.stack = mmap(0, co->stack_size,
-			    PROT_READ | PROT_WRITE,
-			    MAP_PRIVATE | MAP_ANONYMOUS,
-			    -1, 0);
-	if (co->cc.stack == MAP_FAILED)
-		return -1;
-	co->cc.entry = coroutine_trampoline;
-	co->cc.release = _coroutine_release;
-	co->exited = 0;
-
-	return cc_init(&co->cc);
+    if (co->stack_size == 0)
+        co->stack_size = 16 << 20;
+
+    co->cc.stack_size = co->stack_size;
+    co->cc.stack = mmap(0, co->stack_size,
+                        PROT_READ | PROT_WRITE,
+                        MAP_PRIVATE | MAP_ANONYMOUS,
+                        -1, 0);
+    if (co->cc.stack == MAP_FAILED)
+        return -1;
+    co->cc.entry = coroutine_trampoline;
+    co->cc.release = _coroutine_release;
+    co->exited = 0;
+
+    return cc_init(&co->cc);
 }
 
 #if 0
@@ -81,53 +81,53 @@ static struct coroutine *current;
 
 struct coroutine *coroutine_self(void)
 {
-	if (current == NULL)
-		current = &leader;
-	return current;
+    if (current == NULL)
+        current = &leader;
+    return current;
 }
 
 void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
 {
-	int ret;
-	to->data = arg;
-	current = to;
-	ret = cc_swap(&from->cc, &to->cc);
-	if (ret == 0)
-		return from->data;
-	else if (ret == 1) {
-		coroutine_release(to);
-		current = &leader;
-		to->exited = 1;
-		return to->data;
-	}
-
-	return NULL;
+    int ret;
+    to->data = arg;
+    current = to;
+    ret = cc_swap(&from->cc, &to->cc);
+    if (ret == 0)
+        return from->data;
+    else if (ret == 1) {
+        coroutine_release(to);
+        current = &leader;
+        to->exited = 1;
+        return to->data;
+    }
+
+    return NULL;
 }
 
 void *coroutine_yieldto(struct coroutine *to, void *arg)
 {
-	if (to->caller) {
-		fprintf(stderr, "Co-routine is re-entering itself\n");
-		abort();
-	}
-	to->caller = coroutine_self();
-	return coroutine_swap(coroutine_self(), to, arg);
+    if (to->caller) {
+        fprintf(stderr, "Co-routine is re-entering itself\n");
+        abort();
+    }
+    to->caller = coroutine_self();
+    return coroutine_swap(coroutine_self(), to, arg);
 }
 
 void *coroutine_yield(void *arg)
 {
-	struct coroutine *to = coroutine_self()->caller;
-	if (!to) {
-		fprintf(stderr, "Co-routine is yielding to no one\n");
-		abort();
-	}
-	coroutine_self()->caller = NULL;
-	return coroutine_swap(coroutine_self(), to, arg);
+    struct coroutine *to = coroutine_self()->caller;
+    if (!to) {
+        fprintf(stderr, "Co-routine is yielding to no one\n");
+        abort();
+    }
+    coroutine_self()->caller = NULL;
+    return coroutine_swap(coroutine_self(), to, arg);
 }
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/d3des.c b/src/d3des.c
index 71cb1ed..6dd1b1d 100644
--- a/src/d3des.c
+++ b/src/d3des.c
@@ -24,645 +24,645 @@ static void cookey(unsigned long *);
 
 static unsigned long KnL[32] = { 0L };
 /*
-static unsigned long KnR[32] = { 0L };
-static unsigned long Kn3[32] = { 0L };
-static unsigned char Df_Key[24] = {
-	0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
-	0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
-	0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
+  static unsigned long KnR[32] = { 0L };
+  static unsigned long Kn3[32] = { 0L };
+  static unsigned char Df_Key[24] = {
+  0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
+  0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
+  0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
 */
 
 /* VNC requires that this array be reversed so that the MSB is ignored instead
  * of the LSB - Anthony Liguori */
 #if 0
-static unsigned short bytebit[8]	= {
-	0200, 0100, 040, 020, 010, 04, 02, 01 };
+static unsigned short bytebit[8]        = {
+    0200, 0100, 040, 020, 010, 04, 02, 01 };
 #else
-static unsigned short bytebit[8]	= {
-        01, 02, 04, 010, 020, 040, 0100, 0200 };
+static unsigned short bytebit[8]        = {
+    01, 02, 04, 010, 020, 040, 0100, 0200 };
 #endif
 
 static unsigned long bigbyte[24] = {
-	0x800000L,	0x400000L,	0x200000L, 	0x100000L,
-	0x80000L,	0x40000L,	0x20000L,	0x10000L,
-	0x8000L,	0x4000L,	0x2000L,	0x1000L,
-	0x800L,		0x400L,		0x200L,		0x100L,
-	0x80L,		0x40L,		0x20L,		0x10L,
-	0x8L,		0x4L,		0x2L,		0x1L	};
+    0x800000L,        0x400000L,        0x200000L,         0x100000L,
+    0x80000L,        0x40000L,        0x20000L,        0x10000L,
+    0x8000L,        0x4000L,        0x2000L,        0x1000L,
+    0x800L,                0x400L,                0x200L,                0x100L,
+    0x80L,                0x40L,                0x20L,                0x10L,
+    0x8L,                0x4L,                0x2L,                0x1L        };
 
 /* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
 
 static unsigned char pc1[56] = {
-	56, 48, 40, 32, 24, 16,  8,	 0, 57, 49, 41, 33, 25, 17,
-	 9,  1, 58, 50, 42, 34, 26,	18, 10,  2, 59, 51, 43, 35,
-	62, 54, 46, 38, 30, 22, 14,	 6, 61, 53, 45, 37, 29, 21,
-	13,  5, 60, 52, 44, 36, 28,	20, 12,  4, 27, 19, 11,  3 };
+    56, 48, 40, 32, 24, 16,  8,         0, 57, 49, 41, 33, 25, 17,
+    9,  1, 58, 50, 42, 34, 26,        18, 10,  2, 59, 51, 43, 35,
+    62, 54, 46, 38, 30, 22, 14,         6, 61, 53, 45, 37, 29, 21,
+    13,  5, 60, 52, 44, 36, 28,        20, 12,  4, 27, 19, 11,  3 };
 
 static unsigned char totrot[16] = {
-	1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
+    1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
 
 static unsigned char pc2[48] = {
-	13, 16, 10, 23,  0,  4,	 2, 27, 14,  5, 20,  9,
-	22, 18, 11,  3, 25,  7,	15,  6, 26, 19, 12,  1,
-	40, 51, 30, 36, 46, 54,	29, 39, 50, 44, 32, 47,
-	43, 48, 38, 55, 33, 52,	45, 41, 49, 35, 28, 31 };
-
-void deskey(key, edf)	/* Thanks to James Gillogly & Phil Karn! */
-unsigned char *key;
-short edf;
+    13, 16, 10, 23,  0,  4,         2, 27, 14,  5, 20,  9,
+    22, 18, 11,  3, 25,  7,        15,  6, 26, 19, 12,  1,
+    40, 51, 30, 36, 46, 54,        29, 39, 50, 44, 32, 47,
+    43, 48, 38, 55, 33, 52,        45, 41, 49, 35, 28, 31 };
+
+void deskey(key, edf)        /* Thanks to James Gillogly & Phil Karn! */
+     unsigned char *key;
+     short edf;
 {
-	int i, j, l, m, n;
-	unsigned char pc1m[56], pcr[56];
-	unsigned long kn[32];
-
-	for ( j = 0; j < 56; j++ ) {
-		l = pc1[j];
-		m = l & 07;
-		pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0;
-		}
-	for( i = 0; i < 16; i++ ) {
-		if( edf == DE1 ) m = (15 - i) << 1;
-		else m = i << 1;
-		n = m + 1;
-		kn[m] = kn[n] = 0L;
-		for( j = 0; j < 28; j++ ) {
-			l = j + totrot[i];
-			if( l < 28 ) pcr[j] = pc1m[l];
-			else pcr[j] = pc1m[l - 28];
-			}
-		for( j = 28; j < 56; j++ ) {
-		    l = j + totrot[i];
-		    if( l < 56 ) pcr[j] = pc1m[l];
-		    else pcr[j] = pc1m[l - 28];
-		    }
-		for( j = 0; j < 24; j++ ) {
-			if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
-			if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
-			}
-		}
-	cookey(kn);
-	return;
-	}
+    int i, j, l, m, n;
+    unsigned char pc1m[56], pcr[56];
+    unsigned long kn[32];
+
+    for ( j = 0; j < 56; j++ ) {
+        l = pc1[j];
+        m = l & 07;
+        pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0;
+    }
+    for( i = 0; i < 16; i++ ) {
+        if( edf == DE1 ) m = (15 - i) << 1;
+        else m = i << 1;
+        n = m + 1;
+        kn[m] = kn[n] = 0L;
+        for( j = 0; j < 28; j++ ) {
+            l = j + totrot[i];
+            if( l < 28 ) pcr[j] = pc1m[l];
+            else pcr[j] = pc1m[l - 28];
+        }
+        for( j = 28; j < 56; j++ ) {
+            l = j + totrot[i];
+            if( l < 56 ) pcr[j] = pc1m[l];
+            else pcr[j] = pc1m[l - 28];
+        }
+        for( j = 0; j < 24; j++ ) {
+            if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
+            if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
+        }
+    }
+    cookey(kn);
+    return;
+}
 
 static void cookey(raw1)
-unsigned long *raw1;
+     unsigned long *raw1;
 {
-	unsigned long *cook, *raw0;
-	unsigned long dough[32];
-	int i;
-
-	cook = dough;
-	for( i = 0; i < 16; i++, raw1++ ) {
-		raw0 = raw1++;
-		*cook	 = (*raw0 & 0x00fc0000L) << 6;
-		*cook	|= (*raw0 & 0x00000fc0L) << 10;
-		*cook	|= (*raw1 & 0x00fc0000L) >> 10;
-		*cook++	|= (*raw1 & 0x00000fc0L) >> 6;
-		*cook	 = (*raw0 & 0x0003f000L) << 12;
-		*cook	|= (*raw0 & 0x0000003fL) << 16;
-		*cook	|= (*raw1 & 0x0003f000L) >> 4;
-		*cook++	|= (*raw1 & 0x0000003fL);
-		}
-	usekey(dough);
-	return;
-	}
+    unsigned long *cook, *raw0;
+    unsigned long dough[32];
+    int i;
+
+    cook = dough;
+    for( i = 0; i < 16; i++, raw1++ ) {
+        raw0 = raw1++;
+        *cook         = (*raw0 & 0x00fc0000L) << 6;
+        *cook        |= (*raw0 & 0x00000fc0L) << 10;
+        *cook        |= (*raw1 & 0x00fc0000L) >> 10;
+        *cook++        |= (*raw1 & 0x00000fc0L) >> 6;
+        *cook         = (*raw0 & 0x0003f000L) << 12;
+        *cook        |= (*raw0 & 0x0000003fL) << 16;
+        *cook        |= (*raw1 & 0x0003f000L) >> 4;
+        *cook++        |= (*raw1 & 0x0000003fL);
+    }
+    usekey(dough);
+    return;
+}
 
 void cpkey(into)
-unsigned long *into;
+     unsigned long *into;
 {
-	unsigned long *from, *endp;
+    unsigned long *from, *endp;
 
-	from = KnL, endp = &KnL[32];
-	while( from < endp ) *into++ = *from++;
-	return;
-	}
+    from = KnL, endp = &KnL[32];
+    while( from < endp ) *into++ = *from++;
+    return;
+}
 
 void usekey(from)
-unsigned long *from;
+     unsigned long *from;
 {
-	unsigned long *to, *endp;
+    unsigned long *to, *endp;
 
-	to = KnL, endp = &KnL[32];
-	while( to < endp ) *to++ = *from++;
-	return;
-	}
+    to = KnL, endp = &KnL[32];
+    while( to < endp ) *to++ = *from++;
+    return;
+}
 
 void des(inblock, outblock)
-unsigned char *inblock, *outblock;
+     unsigned char *inblock, *outblock;
 {
-	unsigned long work[2];
+    unsigned long work[2];
 
-	scrunch(inblock, work);
-	desfunc(work, KnL);
-	unscrun(work, outblock);
-	return;
-	}
+    scrunch(inblock, work);
+    desfunc(work, KnL);
+    unscrun(work, outblock);
+    return;
+}
 
 
 static void scrunch(outof, into)
-unsigned char *outof;
-unsigned long *into;
+     unsigned char *outof;
+     unsigned long *into;
 {
-	*into 	 = (*outof++ & 0xffL) << 24;
-	*into 	|= (*outof++ & 0xffL) << 16;
-	*into 	|= (*outof++ & 0xffL) << 8;
-	*into++ |= (*outof++ & 0xffL);
-	*into 	 = (*outof++ & 0xffL) << 24;
-	*into 	|= (*outof++ & 0xffL) << 16;
-	*into 	|= (*outof++ & 0xffL) << 8;
-	*into	|= (*outof   & 0xffL);
-	return;
-	}
+    *into          = (*outof++ & 0xffL) << 24;
+    *into         |= (*outof++ & 0xffL) << 16;
+    *into         |= (*outof++ & 0xffL) << 8;
+    *into++ |= (*outof++ & 0xffL);
+    *into          = (*outof++ & 0xffL) << 24;
+    *into         |= (*outof++ & 0xffL) << 16;
+    *into         |= (*outof++ & 0xffL) << 8;
+    *into        |= (*outof   & 0xffL);
+    return;
+}
 
 
 static void unscrun(outof, into)
-unsigned long *outof;
-unsigned char *into;
+     unsigned long *outof;
+     unsigned char *into;
 {
-	*into++ = (*outof >> 24) & 0xffL;
-	*into++ = (*outof >> 16) & 0xffL;
-	*into++ = (*outof >>  8) & 0xffL;
-	*into++ =  *outof++	 & 0xffL;
-	*into++ = (*outof >> 24) & 0xffL;
-	*into++ = (*outof >> 16) & 0xffL;
-	*into++ = (*outof >>  8) & 0xffL;
-	*into   =  *outof	 & 0xffL;
-	return;
-	}
+    *into++ = (*outof >> 24) & 0xffL;
+    *into++ = (*outof >> 16) & 0xffL;
+    *into++ = (*outof >>  8) & 0xffL;
+    *into++ =  *outof++         & 0xffL;
+    *into++ = (*outof >> 24) & 0xffL;
+    *into++ = (*outof >> 16) & 0xffL;
+    *into++ = (*outof >>  8) & 0xffL;
+    *into   =  *outof         & 0xffL;
+    return;
+}
 
 static unsigned long SP1[64] = {
-	0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
-	0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
-	0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
-	0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
-	0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
-	0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
-	0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L,
-	0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
-	0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
-	0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L,
-	0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L,
-	0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
-	0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
-	0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
-	0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
-	0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
+    0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
+    0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
+    0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
+    0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
+    0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
+    0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
+    0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L,
+    0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
+    0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
+    0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L,
+    0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L,
+    0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
+    0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
+    0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
+    0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
+    0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
 
 static unsigned long SP2[64] = {
-	0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
-	0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
-	0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
-	0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
-	0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
-	0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L,
-	0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
-	0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
-	0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
-	0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
-	0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
-	0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
-	0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
-	0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
-	0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
-	0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
+    0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
+    0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
+    0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
+    0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
+    0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
+    0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L,
+    0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
+    0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
+    0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
+    0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
+    0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
+    0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
+    0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
+    0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
+    0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
+    0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
 
 static unsigned long SP3[64] = {
-	0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
-	0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
-	0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
-	0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
-	0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
-	0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
-	0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
-	0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
-	0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
-	0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
-	0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
-	0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
-	0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
-	0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
-	0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
-	0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
+    0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
+    0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
+    0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
+    0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
+    0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
+    0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
+    0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
+    0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
+    0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
+    0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
+    0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
+    0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
+    0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
+    0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
+    0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
+    0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
 
 static unsigned long SP4[64] = {
-	0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
-	0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
-	0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
-	0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
-	0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
-	0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
-	0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
-	0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
-	0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
-	0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L,
-	0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
-	0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
-	0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
-	0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
-	0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
-	0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
+    0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
+    0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
+    0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
+    0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
+    0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
+    0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
+    0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
+    0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
+    0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
+    0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L,
+    0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
+    0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
+    0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
+    0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
+    0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
+    0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
 
 static unsigned long SP5[64] = {
-	0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
-	0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
-	0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
-	0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
-	0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
-	0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
-	0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
-	0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
-	0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
-	0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
-	0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
-	0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L,
-	0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
-	0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
-	0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
-	0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
+    0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
+    0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
+    0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
+    0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
+    0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
+    0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
+    0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
+    0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
+    0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
+    0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
+    0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
+    0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L,
+    0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
+    0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
+    0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
+    0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
 
 static unsigned long SP6[64] = {
-	0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
-	0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
-	0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
-	0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
-	0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
-	0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
-	0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
-	0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
-	0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
-	0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
-	0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
-	0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
-	0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
-	0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
-	0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
-	0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
+    0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
+    0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
+    0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
+    0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
+    0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
+    0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
+    0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
+    0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
+    0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
+    0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
+    0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
+    0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
+    0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
+    0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
+    0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
+    0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
 
 static unsigned long SP7[64] = {
-	0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
-	0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
-	0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
-	0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
-	0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
-	0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
-	0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
-	0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
-	0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
-	0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
-	0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
-	0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
-	0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
-	0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
-	0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
-	0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
+    0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
+    0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
+    0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
+    0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
+    0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
+    0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
+    0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
+    0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
+    0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
+    0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
+    0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
+    0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
+    0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
+    0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
+    0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
+    0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
 
 static unsigned long SP8[64] = {
-	0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
-	0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
-	0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
-	0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L,
-	0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
-	0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
-	0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
-	0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
-	0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
-	0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
-	0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
-	0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
-	0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
-	0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
-	0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
-	0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
+    0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
+    0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
+    0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
+    0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L,
+    0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
+    0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
+    0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
+    0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
+    0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
+    0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
+    0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
+    0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
+    0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
+    0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
+    0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
+    0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
 
 static void desfunc(block, keys)
-unsigned long *block, *keys;
+     unsigned long *block, *keys;
 {
-	unsigned long fval, work, right, leftt;
-	int round;
-
-	leftt = block[0];
-	right = block[1];
-	work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL;
-	right ^= work;
-	leftt ^= (work << 4);
-	work = ((leftt >> 16) ^ right) & 0x0000ffffL;
-	right ^= work;
-	leftt ^= (work << 16);
-	work = ((right >> 2) ^ leftt) & 0x33333333L;
-	leftt ^= work;
-	right ^= (work << 2);
-	work = ((right >> 8) ^ leftt) & 0x00ff00ffL;
-	leftt ^= work;
-	right ^= (work << 8);
-	right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL;
-	work = (leftt ^ right) & 0xaaaaaaaaL;
-	leftt ^= work;
-	right ^= work;
-	leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL;
-
-	for( round = 0; round < 8; round++ ) {
-		work  = (right << 28) | (right >> 4);
-		work ^= *keys++;
-		fval  = SP7[ work		 & 0x3fL];
-		fval |= SP5[(work >>  8) & 0x3fL];
-		fval |= SP3[(work >> 16) & 0x3fL];
-		fval |= SP1[(work >> 24) & 0x3fL];
-		work  = right ^ *keys++;
-		fval |= SP8[ work		 & 0x3fL];
-		fval |= SP6[(work >>  8) & 0x3fL];
-		fval |= SP4[(work >> 16) & 0x3fL];
-		fval |= SP2[(work >> 24) & 0x3fL];
-		leftt ^= fval;
-		work  = (leftt << 28) | (leftt >> 4);
-		work ^= *keys++;
-		fval  = SP7[ work		 & 0x3fL];
-		fval |= SP5[(work >>  8) & 0x3fL];
-		fval |= SP3[(work >> 16) & 0x3fL];
-		fval |= SP1[(work >> 24) & 0x3fL];
-		work  = leftt ^ *keys++;
-		fval |= SP8[ work		 & 0x3fL];
-		fval |= SP6[(work >>  8) & 0x3fL];
-		fval |= SP4[(work >> 16) & 0x3fL];
-		fval |= SP2[(work >> 24) & 0x3fL];
-		right ^= fval;
-		}
-
-	right = (right << 31) | (right >> 1);
-	work = (leftt ^ right) & 0xaaaaaaaaL;
-	leftt ^= work;
-	right ^= work;
-	leftt = (leftt << 31) | (leftt >> 1);
-	work = ((leftt >> 8) ^ right) & 0x00ff00ffL;
-	right ^= work;
-	leftt ^= (work << 8);
-	work = ((leftt >> 2) ^ right) & 0x33333333L;
-	right ^= work;
-	leftt ^= (work << 2);
-	work = ((right >> 16) ^ leftt) & 0x0000ffffL;
-	leftt ^= work;
-	right ^= (work << 16);
-	work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL;
-	leftt ^= work;
-	right ^= (work << 4);
-	*block++ = right;
-	*block = leftt;
-	return;
-	}
+    unsigned long fval, work, right, leftt;
+    int round;
+
+    leftt = block[0];
+    right = block[1];
+    work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL;
+    right ^= work;
+    leftt ^= (work << 4);
+    work = ((leftt >> 16) ^ right) & 0x0000ffffL;
+    right ^= work;
+    leftt ^= (work << 16);
+    work = ((right >> 2) ^ leftt) & 0x33333333L;
+    leftt ^= work;
+    right ^= (work << 2);
+    work = ((right >> 8) ^ leftt) & 0x00ff00ffL;
+    leftt ^= work;
+    right ^= (work << 8);
+    right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL;
+    work = (leftt ^ right) & 0xaaaaaaaaL;
+    leftt ^= work;
+    right ^= work;
+    leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL;
+
+    for( round = 0; round < 8; round++ ) {
+        work  = (right << 28) | (right >> 4);
+        work ^= *keys++;
+        fval  = SP7[ work                 & 0x3fL];
+        fval |= SP5[(work >>  8) & 0x3fL];
+        fval |= SP3[(work >> 16) & 0x3fL];
+        fval |= SP1[(work >> 24) & 0x3fL];
+        work  = right ^ *keys++;
+        fval |= SP8[ work                 & 0x3fL];
+        fval |= SP6[(work >>  8) & 0x3fL];
+        fval |= SP4[(work >> 16) & 0x3fL];
+        fval |= SP2[(work >> 24) & 0x3fL];
+        leftt ^= fval;
+        work  = (leftt << 28) | (leftt >> 4);
+        work ^= *keys++;
+        fval  = SP7[ work                 & 0x3fL];
+        fval |= SP5[(work >>  8) & 0x3fL];
+        fval |= SP3[(work >> 16) & 0x3fL];
+        fval |= SP1[(work >> 24) & 0x3fL];
+        work  = leftt ^ *keys++;
+        fval |= SP8[ work                 & 0x3fL];
+        fval |= SP6[(work >>  8) & 0x3fL];
+        fval |= SP4[(work >> 16) & 0x3fL];
+        fval |= SP2[(work >> 24) & 0x3fL];
+        right ^= fval;
+    }
+
+    right = (right << 31) | (right >> 1);
+    work = (leftt ^ right) & 0xaaaaaaaaL;
+    leftt ^= work;
+    right ^= work;
+    leftt = (leftt << 31) | (leftt >> 1);
+    work = ((leftt >> 8) ^ right) & 0x00ff00ffL;
+    right ^= work;
+    leftt ^= (work << 8);
+    work = ((leftt >> 2) ^ right) & 0x33333333L;
+    right ^= work;
+    leftt ^= (work << 2);
+    work = ((right >> 16) ^ leftt) & 0x0000ffffL;
+    leftt ^= work;
+    right ^= (work << 16);
+    work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL;
+    leftt ^= work;
+    right ^= (work << 4);
+    *block++ = right;
+    *block = leftt;
+    return;
+}
 
 #ifdef D2_DES
 
-void des2key(hexkey, mode)		/* stomps on Kn3 too */
-unsigned char *hexkey;			/* unsigned char[16] */
-short mode;
+void des2key(hexkey, mode)                /* stomps on Kn3 too */
+     unsigned char *hexkey;                        /* unsigned char[16] */
+     short mode;
 {
-	short revmod;
+    short revmod;
 
-	revmod = (mode == EN0) ? DE1 : EN0;
-	deskey(&hexkey[8], revmod);
-	cpkey(KnR);
-	deskey(hexkey, mode);
-	cpkey(Kn3);					/* Kn3 = KnL */
-	return;
-	}
+    revmod = (mode == EN0) ? DE1 : EN0;
+    deskey(&hexkey[8], revmod);
+    cpkey(KnR);
+    deskey(hexkey, mode);
+    cpkey(Kn3);                                        /* Kn3 = KnL */
+    return;
+}
 
 void Ddes(from, into)
-unsigned char *from, *into;		/* unsigned char[8] */
+     unsigned char *from, *into;                /* unsigned char[8] */
 {
-	unsigned long work[2];
+    unsigned long work[2];
 
-	scrunch(from, work);
-	desfunc(work, KnL);
-	desfunc(work, KnR);
-	desfunc(work, Kn3);
-	unscrun(work, into);
-	return;
-	}
+    scrunch(from, work);
+    desfunc(work, KnL);
+    desfunc(work, KnR);
+    desfunc(work, Kn3);
+    unscrun(work, into);
+    return;
+}
 
 void D2des(from, into)
-unsigned char *from;			/* unsigned char[16] */
-unsigned char *into;			/* unsigned char[16] */
+     unsigned char *from;                        /* unsigned char[16] */
+     unsigned char *into;                        /* unsigned char[16] */
 {
-	unsigned long *right, *l1, swap;
-	unsigned long leftt[2], bufR[2];
-
-	right = bufR;
-	l1 = &leftt[1];
-	scrunch(from, leftt);
-	scrunch(&from[8], right);
-	desfunc(leftt, KnL);
-	desfunc(right, KnL);
-	swap = *l1;
-	*l1 = *right;
-	*right = swap;
-	desfunc(leftt, KnR);
-	desfunc(right, KnR);
-	swap = *l1;
-	*l1 = *right;
-	*right = swap;
-	desfunc(leftt, Kn3);
-	desfunc(right, Kn3);
-	unscrun(leftt, into);
-	unscrun(right, &into[8]);
-	return;
-	}
+    unsigned long *right, *l1, swap;
+    unsigned long leftt[2], bufR[2];
+
+    right = bufR;
+    l1 = &leftt[1];
+    scrunch(from, leftt);
+    scrunch(&from[8], right);
+    desfunc(leftt, KnL);
+    desfunc(right, KnL);
+    swap = *l1;
+    *l1 = *right;
+    *right = swap;
+    desfunc(leftt, KnR);
+    desfunc(right, KnR);
+    swap = *l1;
+    *l1 = *right;
+    *right = swap;
+    desfunc(leftt, Kn3);
+    desfunc(right, Kn3);
+    unscrun(leftt, into);
+    unscrun(right, &into[8]);
+    return;
+}
 
 void makekey(aptr, kptr)
-char *aptr;				/* NULL-terminated  */
-unsigned char *kptr;		/* unsigned char[8] */
+     char *aptr;                                /* NULL-terminated  */
+     unsigned char *kptr;                /* unsigned char[8] */
 {
-	unsigned char *store;
-	int first, i;
-	unsigned long savek[96];
-
-	cpDkey(savek);
-	des2key(Df_Key, EN0);
-	for( i = 0; i < 8; i++ ) kptr[i] = Df_Key[i];
-	first = 1;
-	while( (*aptr != '\0') || first ) {
-		store = kptr;
-		for( i = 0; i < 8 && (*aptr != '\0'); i++ ) {
-			*store++ ^= *aptr & 0x7f;
-			*aptr++ = '\0';
-			}
-		Ddes(kptr, kptr);
-		first = 0;
-		}
-	useDkey(savek);
-	return;
-	}
+    unsigned char *store;
+    int first, i;
+    unsigned long savek[96];
+
+    cpDkey(savek);
+    des2key(Df_Key, EN0);
+    for( i = 0; i < 8; i++ ) kptr[i] = Df_Key[i];
+    first = 1;
+    while( (*aptr != '\0') || first ) {
+        store = kptr;
+        for( i = 0; i < 8 && (*aptr != '\0'); i++ ) {
+            *store++ ^= *aptr & 0x7f;
+            *aptr++ = '\0';
+        }
+        Ddes(kptr, kptr);
+        first = 0;
+    }
+    useDkey(savek);
+    return;
+}
 
 void make2key(aptr, kptr)
-char *aptr;				/* NULL-terminated   */
-unsigned char *kptr;		/* unsigned char[16] */
+     char *aptr;                                /* NULL-terminated   */
+     unsigned char *kptr;                /* unsigned char[16] */
 {
-	unsigned char *store;
-	int first, i;
-	unsigned long savek[96];
-
-	cpDkey(savek);
-	des2key(Df_Key, EN0);
-	for( i = 0; i < 16; i++ ) kptr[i] = Df_Key[i];
-	first = 1;
-	while( (*aptr != '\0') || first ) {
-		store = kptr;
-		for( i = 0; i < 16 && (*aptr != '\0'); i++ ) {
-			*store++ ^= *aptr & 0x7f;
-			*aptr++ = '\0';
-			}
-		D2des(kptr, kptr);
-		first = 0;
-		}
-	useDkey(savek);
-	return;
-	}
-
-#ifndef D3_DES	/* D2_DES only */
+    unsigned char *store;
+    int first, i;
+    unsigned long savek[96];
+
+    cpDkey(savek);
+    des2key(Df_Key, EN0);
+    for( i = 0; i < 16; i++ ) kptr[i] = Df_Key[i];
+    first = 1;
+    while( (*aptr != '\0') || first ) {
+        store = kptr;
+        for( i = 0; i < 16 && (*aptr != '\0'); i++ ) {
+            *store++ ^= *aptr & 0x7f;
+            *aptr++ = '\0';
+        }
+        D2des(kptr, kptr);
+        first = 0;
+    }
+    useDkey(savek);
+    return;
+}
+
+#ifndef D3_DES        /* D2_DES only */
 
 void cp2key(into)
-unsigned long *into;	/* unsigned long[64] */
+     unsigned long *into;        /* unsigned long[64] */
 {
-	unsigned long *from, *endp;
+    unsigned long *from, *endp;
 
-	cpkey(into);
-	into = &into[32];
-	from = KnR, endp = &KnR[32];
-	while( from < endp ) *into++ = *from++;
-	return;
-	}
+    cpkey(into);
+    into = &into[32];
+    from = KnR, endp = &KnR[32];
+    while( from < endp ) *into++ = *from++;
+    return;
+}
 
-void use2key(from)				/* stomps on Kn3 too */
-unsigned long *from;	/* unsigned long[64] */
+void use2key(from)                                /* stomps on Kn3 too */
+     unsigned long *from;        /* unsigned long[64] */
 {
-	unsigned long *to, *endp;
+    unsigned long *to, *endp;
 
-	usekey(from);
-	from = &from[32];
-	to = KnR, endp = &KnR[32];
-	while( to < endp ) *to++ = *from++;
-	cpkey(Kn3);					/* Kn3 = KnL */
-	return;
-	}
+    usekey(from);
+    from = &from[32];
+    to = KnR, endp = &KnR[32];
+    while( to < endp ) *to++ = *from++;
+    cpkey(Kn3);                                        /* Kn3 = KnL */
+    return;
+}
 
-#else	/* D3_DES too */
+#else        /* D3_DES too */
 
 void des3key(hexkey, mode)
-unsigned char *hexkey;			/* unsigned char[24] */
-short mode;
+     unsigned char *hexkey;                        /* unsigned char[24] */
+     short mode;
 {
-	unsigned char *first, *third;
-	short revmod;
-
-	if( mode == EN0 ) {
-		revmod = DE1;
-		first = hexkey;
-		third = &hexkey[16];
-		}
-	else {
-		revmod = EN0;
-		first = &hexkey[16];
-		third = hexkey;
-		}
-	deskey(&hexkey[8], revmod);
-	cpkey(KnR);
-	deskey(third, mode);
-	cpkey(Kn3);
-	deskey(first, mode);
-	return;
-	}
+    unsigned char *first, *third;
+    short revmod;
+
+    if( mode == EN0 ) {
+        revmod = DE1;
+        first = hexkey;
+        third = &hexkey[16];
+    }
+    else {
+        revmod = EN0;
+        first = &hexkey[16];
+        third = hexkey;
+    }
+    deskey(&hexkey[8], revmod);
+    cpkey(KnR);
+    deskey(third, mode);
+    cpkey(Kn3);
+    deskey(first, mode);
+    return;
+}
 
 void cp3key(into)
-unsigned long *into;	/* unsigned long[96] */
+     unsigned long *into;        /* unsigned long[96] */
 {
-	unsigned long *from, *endp;
+    unsigned long *from, *endp;
 
-	cpkey(into);
-	into = &into[32];
-	from = KnR, endp = &KnR[32];
-	while( from < endp ) *into++ = *from++;
-	from = Kn3, endp = &Kn3[32];
-	while( from < endp ) *into++ = *from++;
-	return;
-	}
+    cpkey(into);
+    into = &into[32];
+    from = KnR, endp = &KnR[32];
+    while( from < endp ) *into++ = *from++;
+    from = Kn3, endp = &Kn3[32];
+    while( from < endp ) *into++ = *from++;
+    return;
+}
 
 void use3key(from)
-unsigned long *from;	/* unsigned long[96] */
+     unsigned long *from;        /* unsigned long[96] */
 {
-	unsigned long *to, *endp;
+    unsigned long *to, *endp;
 
-	usekey(from);
-	from = &from[32];
-	to = KnR, endp = &KnR[32];
-	while( to < endp ) *to++ = *from++;
-	to = Kn3, endp = &Kn3[32];
-	while( to < endp ) *to++ = *from++;
-	return;
-	}
+    usekey(from);
+    from = &from[32];
+    to = KnR, endp = &KnR[32];
+    while( to < endp ) *to++ = *from++;
+    to = Kn3, endp = &Kn3[32];
+    while( to < endp ) *to++ = *from++;
+    return;
+}
 
 static void D3des(unsigned char *, unsigned char *);
 
-static void D3des(from, into)	/* amateur theatrics */
-unsigned char *from;			/* unsigned char[24] */
-unsigned char *into;			/* unsigned char[24] */
+static void D3des(from, into)        /* amateur theatrics */
+     unsigned char *from;                        /* unsigned char[24] */
+     unsigned char *into;                        /* unsigned char[24] */
 {
-	unsigned long swap, leftt[2], middl[2], right[2];
-
-	scrunch(from, leftt);
-	scrunch(&from[8], middl);
-	scrunch(&from[16], right);
-	desfunc(leftt, KnL);
-	desfunc(middl, KnL);
-	desfunc(right, KnL);
-	swap = leftt[1];
-	leftt[1] = middl[0];
-	middl[0] = swap;
-	swap = middl[1];
-	middl[1] = right[0];
-	right[0] = swap;
-	desfunc(leftt, KnR);
-	desfunc(middl, KnR);
-	desfunc(right, KnR);
-	swap = leftt[1];
-	leftt[1] = middl[0];
-	middl[0] = swap;
-	swap = middl[1];
-	middl[1] = right[0];
-	right[0] = swap;
-	desfunc(leftt, Kn3);
-	desfunc(middl, Kn3);
-	desfunc(right, Kn3);
-	unscrun(leftt, into);
-	unscrun(middl, &into[8]);
-	unscrun(right, &into[16]);
-	return;
-	}
+    unsigned long swap, leftt[2], middl[2], right[2];
+
+    scrunch(from, leftt);
+    scrunch(&from[8], middl);
+    scrunch(&from[16], right);
+    desfunc(leftt, KnL);
+    desfunc(middl, KnL);
+    desfunc(right, KnL);
+    swap = leftt[1];
+    leftt[1] = middl[0];
+    middl[0] = swap;
+    swap = middl[1];
+    middl[1] = right[0];
+    right[0] = swap;
+    desfunc(leftt, KnR);
+    desfunc(middl, KnR);
+    desfunc(right, KnR);
+    swap = leftt[1];
+    leftt[1] = middl[0];
+    middl[0] = swap;
+    swap = middl[1];
+    middl[1] = right[0];
+    right[0] = swap;
+    desfunc(leftt, Kn3);
+    desfunc(middl, Kn3);
+    desfunc(right, Kn3);
+    unscrun(leftt, into);
+    unscrun(middl, &into[8]);
+    unscrun(right, &into[16]);
+    return;
+}
 
 void make3key(aptr, kptr)
-char *aptr;				/* NULL-terminated   */
-unsigned char *kptr;		/* unsigned char[24] */
+     char *aptr;                                /* NULL-terminated   */
+     unsigned char *kptr;                /* unsigned char[24] */
 {
-	unsigned char *store;
-	int first, i;
-	unsigned long savek[96];
-
-	cp3key(savek);
-	des3key(Df_Key, EN0);
-	for( i = 0; i < 24; i++ ) kptr[i] = Df_Key[i];
-	first = 1;
-	while( (*aptr != '\0') || first ) {
-		store = kptr;
-		for( i = 0; i < 24 && (*aptr != '\0'); i++ ) {
-			*store++ ^= *aptr & 0x7f;
-			*aptr++ = '\0';
-			}
-		D3des(kptr, kptr);
-		first = 0;
-		}
-	use3key(savek);
-	return;
-	}
-
-#endif	/* D3_DES */
-#endif	/* D2_DES */
+    unsigned char *store;
+    int first, i;
+    unsigned long savek[96];
+
+    cp3key(savek);
+    des3key(Df_Key, EN0);
+    for( i = 0; i < 24; i++ ) kptr[i] = Df_Key[i];
+    first = 1;
+    while( (*aptr != '\0') || first ) {
+        store = kptr;
+        for( i = 0; i < 24 && (*aptr != '\0'); i++ ) {
+            *store++ ^= *aptr & 0x7f;
+            *aptr++ = '\0';
+        }
+        D3des(kptr, kptr);
+        first = 0;
+    }
+    use3key(savek);
+    return;
+}
+
+#endif        /* D3_DES */
+#endif        /* D2_DES */
 
 /* Validation sets:
  *
@@ -693,4 +693,10 @@ unsigned char *kptr;		/* unsigned char[24] */
  *
  * d3des V5.09 rwo 9208.04 20:31 Graven Imagery
  **********************************************************************/
-
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/d3des.h b/src/d3des.h
index c344582..4b6e4de 100644
--- a/src/d3des.h
+++ b/src/d3des.h
@@ -7,7 +7,7 @@
  * 920825 19:42 EDST
  *
  * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
- *	(GEnie : OUTER; CIS : [71755,204])
+ *        (GEnie : OUTER; CIS : [71755,204])
  */
 
 #undef D2_DES
@@ -15,47 +15,47 @@
 
 #ifdef D3_DES
 #ifndef D2_DES
-#define D2_DES		/* D2_DES is needed for D3_DES */
+#define D2_DES                /* D2_DES is needed for D3_DES */
 #endif
 #endif
 
-#define EN0	0		/* MODE == encrypt */
-#define DE1	1		/* MODE == decrypt */
+#define EN0        0                /* MODE == encrypt */
+#define DE1        1                /* MODE == decrypt */
 
 /* Useful on 68000-ish machines, but NOT USED here. */
 
 typedef union {
-	unsigned long blok[2];
-	unsigned short word[4];
-	unsigned char byte[8];
-	} M68K;
+    unsigned long blok[2];
+    unsigned short word[4];
+    unsigned char byte[8];
+} M68K;
 
 typedef union {
-	unsigned long dblok[4];
-	unsigned short dword[8];
-	unsigned char dbyte[16];
-	} M68K2;
+    unsigned long dblok[4];
+    unsigned short dword[8];
+    unsigned char dbyte[16];
+} M68K2;
 
 extern void deskey(unsigned char *, short);
-/*		      hexkey[8]     MODE
+/*                      hexkey[8]     MODE
  * Sets the internal key register according to the hexadecimal
  * key contained in the 8 bytes of hexkey, according to the DES,
  * for encryption or decryption according to MODE.
  */
 
 extern void usekey(unsigned long *);
-/*		    cookedkey[32]
+/*                    cookedkey[32]
  * Loads the internal key register with the data in cookedkey.
  */
 
 extern void cpkey(unsigned long *);
-/*		   cookedkey[32]
+/*                   cookedkey[32]
  * Copies the contents of the internal key register into the storage
  * located at &cookedkey[0].
  */
 
 extern void des(unsigned char *, unsigned char *);
-/*		    from[8]	      to[8]
+/*                    from[8]              to[8]
  * Encrypts/Decrypts (according to the key currently loaded in the
  * internal key register) one block of eight bytes at address 'from'
  * into the block at address 'to'.  They can be the same.
@@ -63,9 +63,9 @@ extern void des(unsigned char *, unsigned char *);
 
 #ifdef D2_DES
 
-#define desDkey(a,b)	des2key((a),(b))
+#define desDkey(a,b)        des2key((a),(b))
 extern void des2key(unsigned char *, short);
-/*		      hexkey[16]     MODE
+/*                      hexkey[16]     MODE
  * Sets the internal key registerS according to the hexadecimal
  * keyS contained in the 16 bytes of hexkey, according to the DES,
  * for DOUBLE encryption or decryption according to MODE.
@@ -73,84 +73,90 @@ extern void des2key(unsigned char *, short);
  */
 
 extern void Ddes(unsigned char *, unsigned char *);
-/*		    from[8]	      to[8]
+/*                    from[8]              to[8]
  * Encrypts/Decrypts (according to the keyS currently loaded in the
  * internal key registerS) one block of eight bytes at address 'from'
  * into the block at address 'to'.  They can be the same.
  */
 
 extern void D2des(unsigned char *, unsigned char *);
-/*		    from[16]	      to[16]
+/*                    from[16]              to[16]
  * Encrypts/Decrypts (according to the keyS currently loaded in the
  * internal key registerS) one block of SIXTEEN bytes at address 'from'
  * into the block at address 'to'.  They can be the same.
  */
 
 extern void makekey(char *, unsigned char *);
-/*		*password,	single-length key[8]
+/*                *password,        single-length key[8]
  * With a double-length default key, this routine hashes a NULL-terminated
  * string into an eight-byte random-looking key, suitable for use with the
  * deskey() routine.
  */
 
-#define makeDkey(a,b)	make2key((a),(b))
+#define makeDkey(a,b)        make2key((a),(b))
 extern void make2key(char *, unsigned char *);
-/*		*password,	double-length key[16]
+/*                *password,        double-length key[16]
  * With a double-length default key, this routine hashes a NULL-terminated
  * string into a sixteen-byte random-looking key, suitable for use with the
  * des2key() routine.
  */
 
-#ifndef D3_DES	/* D2_DES only */
+#ifndef D3_DES        /* D2_DES only */
 
-#define useDkey(a)	use2key((a))
-#define cpDkey(a)	cp2key((a))
+#define useDkey(a)        use2key((a))
+#define cpDkey(a)        cp2key((a))
 
 extern void use2key(unsigned long *);
-/*		    cookedkey[64]
+/*                    cookedkey[64]
  * Loads the internal key registerS with the data in cookedkey.
  * NOTE: this clobbers all three key registers!
  */
 
 extern voi  cp2key(unsigned long *);
-/*		   cookedkey[64]
+/*                   cookedkey[64]
  * Copies the contents of the internal key registerS into the storage
  * located at &cookedkey[0].
  */
 
-#else	/* D3_DES too */
+#else        /* D3_DES too */
 
-#define useDkey(a)	use3key((a))
-#define cpDkey(a)	cp3key((a))
+#define useDkey(a)        use3key((a))
+#define cpDkey(a)        cp3key((a))
 
 extern void des3key(unsigned char *, short);
-/*		      hexkey[24]     MODE
+/*                      hexkey[24]     MODE
  * Sets the internal key registerS according to the hexadecimal
  * keyS contained in the 24 bytes of hexkey, according to the DES,
  * for DOUBLE encryption or decryption according to MODE.
  */
 
 extern void use3key(unsigned long *);
-/*		    cookedkey[96]
+/*                    cookedkey[96]
  * Loads the 3 internal key registerS with the data in cookedkey.
  */
 
 extern void cp3key(unsigned long *);
-/*		   cookedkey[96]
+/*                   cookedkey[96]
  * Copies the contents of the 3 internal key registerS into the storage
  * located at &cookedkey[0].
  */
 
 extern void make3key(char *, unsigned char *);
-/*		*password,	triple-length key[24]
+/*                *password,        triple-length key[24]
  * With a triple-length default key, this routine hashes a NULL-terminated
  * string into a twenty-four-byte random-looking key, suitable for use with
  * the des3key() routine.
  */
 
-#endif	/* D3_DES */
-#endif	/* D2_DES */
+#endif        /* D3_DES */
+#endif        /* D2_DES */
 
 /* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery
- ********************************************************************/
-
+********************************************************************/
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/dh.c b/src/dh.c
index 3ab5e77..279b7c0 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -47,110 +47,110 @@
  */
 
 struct vnc_dh {
-       gcry_mpi_t gen;  /* g */
-       gcry_mpi_t mod;  /* p */
+    gcry_mpi_t gen;  /* g */
+    gcry_mpi_t mod;  /* p */
 
-       gcry_mpi_t priv; /* y */
-       gcry_mpi_t pub;  /* Y = g ^ y mod p */
+    gcry_mpi_t priv; /* y */
+    gcry_mpi_t pub;  /* Y = g ^ y mod p */
 
-       gcry_mpi_t key;  /*     X ^ y mod p */
+    gcry_mpi_t key;  /*     X ^ y mod p */
 };
 
 #define VNC_DH_MAX_BITS 31
 
 struct vnc_dh *vnc_dh_new(gcry_mpi_t gen, gcry_mpi_t mod)
 {
-       struct vnc_dh *ret = g_new0(struct vnc_dh, 1);
+    struct vnc_dh *ret = g_new0(struct vnc_dh, 1);
 
-       ret->gen = gcry_mpi_copy(gen);
-       ret->mod = gcry_mpi_copy(mod);
+    ret->gen = gcry_mpi_copy(gen);
+    ret->mod = gcry_mpi_copy(mod);
 
-       return ret;
+    return ret;
 }
 
 
 gcry_mpi_t vnc_dh_gen_secret(struct vnc_dh *dh)
 {
-       if (!(dh->priv = gcry_mpi_new(VNC_DH_MAX_BITS)))
-               abort();
+    if (!(dh->priv = gcry_mpi_new(VNC_DH_MAX_BITS)))
+        abort();
 
-       do {
-               gcry_mpi_randomize (dh->priv, (VNC_DH_MAX_BITS / 8) * 8, GCRY_STRONG_RANDOM);
-       } while (gcry_mpi_cmp_ui (dh->priv, 0) == 0);
+    do {
+        gcry_mpi_randomize (dh->priv, (VNC_DH_MAX_BITS / 8) * 8, GCRY_STRONG_RANDOM);
+    } while (gcry_mpi_cmp_ui (dh->priv, 0) == 0);
 
-       if (!(dh->pub = gcry_mpi_new(VNC_DH_MAX_BITS)))
-               abort();
+    if (!(dh->pub = gcry_mpi_new(VNC_DH_MAX_BITS)))
+        abort();
 
-       gcry_mpi_powm(dh->pub, dh->gen, dh->priv, dh->mod);
+    gcry_mpi_powm(dh->pub, dh->gen, dh->priv, dh->mod);
 
-       return dh->pub;
+    return dh->pub;
 }
 
 gcry_mpi_t vnc_dh_gen_key(struct vnc_dh *dh, gcry_mpi_t inter)
 {
-       if (!(dh->key = gcry_mpi_new(VNC_DH_MAX_BITS)))
-               abort();
+    if (!(dh->key = gcry_mpi_new(VNC_DH_MAX_BITS)))
+        abort();
 
-       gcry_mpi_powm(dh->key, inter, dh->priv, dh->mod);
+    gcry_mpi_powm(dh->key, inter, dh->priv, dh->mod);
 
-       return dh->key;
+    return dh->key;
 }
 
 void vnc_dh_free(struct vnc_dh *dh)
 {
-       if (dh->key)
-               gcry_mpi_release(dh->key);
-       if (dh->pub)
-               gcry_mpi_release(dh->pub);
-       if (dh->priv)
-               gcry_mpi_release(dh->priv);
-       if (dh->mod)
-               gcry_mpi_release(dh->mod);
-       if (dh->gen)
-               gcry_mpi_release(dh->gen);
-       g_free(dh);
+    if (dh->key)
+        gcry_mpi_release(dh->key);
+    if (dh->pub)
+        gcry_mpi_release(dh->pub);
+    if (dh->priv)
+        gcry_mpi_release(dh->priv);
+    if (dh->mod)
+        gcry_mpi_release(dh->mod);
+    if (dh->gen)
+        gcry_mpi_release(dh->gen);
+    g_free(dh);
 }
 
 void vnc_mpi_to_bytes(const gcry_mpi_t value, guchar* result, size_t size)
 {
-       gcry_error_t error;
-       size_t len;
-       int i;
-
-       error = gcry_mpi_print(GCRYMPI_FMT_USG, result, size, &len, value);
-       if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
-	       VNC_DEBUG ("MPI error: %s", gcry_strerror (error));
-	       abort();
-       }
-
-       /* right adjust the result
-	  68 183 219 160 0 0 0 0 becomes
-	  0 0 0 0 68 183 219 160 */
-       for(i=size-1;i>(int)size-1-(int)len;--i) {
-	       result[i] = result[i-size+len];
-       }
-       for(;i>=0;--i) {
-	       result[i] = 0;
-       }
+    gcry_error_t error;
+    size_t len;
+    int i;
+
+    error = gcry_mpi_print(GCRYMPI_FMT_USG, result, size, &len, value);
+    if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
+        VNC_DEBUG ("MPI error: %s", gcry_strerror (error));
+        abort();
+    }
+
+    /* right adjust the result
+       68 183 219 160 0 0 0 0 becomes
+       0 0 0 0 68 183 219 160 */
+    for(i=size-1;i>(int)size-1-(int)len;--i) {
+        result[i] = result[i-size+len];
+    }
+    for(;i>=0;--i) {
+        result[i] = 0;
+    }
 }
 
 gcry_mpi_t vnc_bytes_to_mpi(const guchar* value, size_t size)
 {
-       gcry_mpi_t ret;
-       gcry_error_t error;
+    gcry_mpi_t ret;
+    gcry_error_t error;
 
-       error = gcry_mpi_scan(&ret, GCRYMPI_FMT_USG, value, size, NULL);
-       if (gcry_err_code (error) != GPG_ERR_NO_ERROR)
-         VNC_DEBUG ("MPI error: %s", gcry_strerror (error));
+    error = gcry_mpi_scan(&ret, GCRYMPI_FMT_USG, value, size, NULL);
+    if (gcry_err_code (error) != GPG_ERR_NO_ERROR)
+        VNC_DEBUG ("MPI error: %s", gcry_strerror (error));
 
-       return ret;
+    return ret;
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/dh.h b/src/dh.h
index ed4fe14..b4b97a9 100644
--- a/src/dh.h
+++ b/src/dh.h
@@ -36,3 +36,10 @@ void vnc_mpi_to_bytes(const gcry_mpi_t value, guchar* result, size_t size);
 gcry_mpi_t vnc_bytes_to_mpi(const guchar* value, size_t size);
 
 #endif
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/gtk-vnc.h b/src/gtk-vnc.h
index 844022b..01a46ec 100644
--- a/src/gtk-vnc.h
+++ b/src/gtk-vnc.h
@@ -29,3 +29,10 @@
 #endif
 
 #endif
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/gvnc.h b/src/gvnc.h
index a686fb6..040138c 100644
--- a/src/gvnc.h
+++ b/src/gvnc.h
@@ -31,3 +31,10 @@
 #include <vncutil.h>
 
 #endif
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/gvncpulse.h b/src/gvncpulse.h
index de70663..d93f7a2 100644
--- a/src/gvncpulse.h
+++ b/src/gvncpulse.h
@@ -25,3 +25,10 @@
 #include <vncaudiopulse.h>
 
 #endif
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/vncaudio.c b/src/vncaudio.c
index 3400762..cb1cbe0 100644
--- a/src/vncaudio.c
+++ b/src/vncaudio.c
@@ -25,42 +25,42 @@
 
 void vnc_audio_playback_start(VncAudio *aud, VncAudioFormat *format)
 {
-	VNC_AUDIO_GET_INTERFACE(aud)->playback_start(aud, format);
+    VNC_AUDIO_GET_INTERFACE(aud)->playback_start(aud, format);
 }
 
 void vnc_audio_playback_stop(VncAudio *aud)
 {
-	VNC_AUDIO_GET_INTERFACE(aud)->playback_stop(aud);
+    VNC_AUDIO_GET_INTERFACE(aud)->playback_stop(aud);
 }
 
 void vnc_audio_playback_data(VncAudio *aud, VncAudioSample *sample)
 {
-	VNC_AUDIO_GET_INTERFACE(aud)->playback_data(aud, sample);
+    VNC_AUDIO_GET_INTERFACE(aud)->playback_data(aud, sample);
 }
 
 
 GType
 vnc_audio_get_type (void)
 {
-	static GType audio_type = 0;
+    static GType audio_type = 0;
 
-	if (!audio_type) {
-		audio_type =
-			g_type_register_static_simple(G_TYPE_INTERFACE, "VncAudio",
-						      sizeof (VncAudioInterface),
-						      NULL, 0, NULL, 0);
+    if (!audio_type) {
+        audio_type =
+            g_type_register_static_simple(G_TYPE_INTERFACE, "VncAudio",
+                                          sizeof (VncAudioInterface),
+                                          NULL, 0, NULL, 0);
 
-		g_type_interface_add_prerequisite (audio_type, G_TYPE_OBJECT);
-	}
+        g_type_interface_add_prerequisite (audio_type, G_TYPE_OBJECT);
+    }
 
-	return audio_type;
+    return audio_type;
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncaudio.h b/src/vncaudio.h
index 56d8d2e..c92409a 100644
--- a/src/vncaudio.h
+++ b/src/vncaudio.h
@@ -38,20 +38,20 @@ typedef struct _VncAudio VncAudio; /* Dummy object */
 typedef struct _VncAudioInterface VncAudioInterface;
 
 struct _VncAudioInterface {
-	GTypeInterface parent;
+    GTypeInterface parent;
 
-	gboolean (*playback_start)(VncAudio *audio, VncAudioFormat *format);
-	gboolean (*playback_stop)(VncAudio *audio);
-	gboolean (*playback_data)(VncAudio *audio, VncAudioSample *sample);
+    gboolean (*playback_start)(VncAudio *audio, VncAudioFormat *format);
+    gboolean (*playback_stop)(VncAudio *audio);
+    gboolean (*playback_data)(VncAudio *audio, VncAudioSample *sample);
 };
 
 GType vnc_audio_get_type(void) G_GNUC_CONST;
 
 void vnc_audio_playback_start(VncAudio *aud,
-			      VncAudioFormat *format);
+                              VncAudioFormat *format);
 void vnc_audio_playback_stop(VncAudio *aud);
 void vnc_audio_playback_data(VncAudio *aud,
-			     VncAudioSample *sample);
+                             VncAudioSample *sample);
 
 G_END_DECLS
 
@@ -59,8 +59,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncaudioformat.c b/src/vncaudioformat.c
index 8efd2b7..43e31cf 100644
--- a/src/vncaudioformat.c
+++ b/src/vncaudioformat.c
@@ -24,48 +24,48 @@
 
 GType vnc_audio_format_get_type(void)
 {
-	static GType audio_format_type = 0;
+    static GType audio_format_type = 0;
 
-	if (G_UNLIKELY(audio_format_type == 0)) {
-		audio_format_type = g_boxed_type_register_static
-			("VncAudioFormat",
-			 (GBoxedCopyFunc)vnc_audio_format_copy,
-			 (GBoxedFreeFunc)vnc_audio_format_free);
-	}
+    if (G_UNLIKELY(audio_format_type == 0)) {
+        audio_format_type = g_boxed_type_register_static
+            ("VncAudioFormat",
+             (GBoxedCopyFunc)vnc_audio_format_copy,
+             (GBoxedFreeFunc)vnc_audio_format_free);
+    }
 
-	return audio_format_type;
+    return audio_format_type;
 }
 
 
 VncAudioFormat *vnc_audio_format_new(void)
 {
-	VncAudioFormat *format;
+    VncAudioFormat *format;
 
-	format = g_slice_new0(VncAudioFormat);
+    format = g_slice_new0(VncAudioFormat);
 
-	return format;
+    return format;
 }
 
 
 VncAudioFormat *vnc_audio_format_copy(VncAudioFormat *srcFormat)
 {
-	VncAudioFormat *format;
+    VncAudioFormat *format;
 
-	format = g_slice_dup(VncAudioFormat, srcFormat);
+    format = g_slice_dup(VncAudioFormat, srcFormat);
 
-	return format;
+    return format;
 }
 
 
 void vnc_audio_format_free(VncAudioFormat *format)
 {
-	g_slice_free(VncAudioFormat, format);
+    g_slice_free(VncAudioFormat, format);
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncaudioformat.h b/src/vncaudioformat.h
index bbf741e..4de5763 100644
--- a/src/vncaudioformat.h
+++ b/src/vncaudioformat.h
@@ -31,18 +31,18 @@ G_BEGIN_DECLS
 typedef struct _VncAudioFormat VncAudioFormat;
 
 struct _VncAudioFormat {
-	guint8 format;
-	guint8 nchannels;
-	guint32 frequency;
+    guint8 format;
+    guint8 nchannels;
+    guint32 frequency;
 };
 
 typedef enum {
-	VNC_AUDIO_FORMAT_RAW_U8,
-	VNC_AUDIO_FORMAT_RAW_S8,
-	VNC_AUDIO_FORMAT_RAW_U16,
-	VNC_AUDIO_FORMAT_RAW_S16,
-	VNC_AUDIO_FORMAT_RAW_U32,
-	VNC_AUDIO_FORMAT_RAW_S32,
+    VNC_AUDIO_FORMAT_RAW_U8,
+    VNC_AUDIO_FORMAT_RAW_S8,
+    VNC_AUDIO_FORMAT_RAW_U16,
+    VNC_AUDIO_FORMAT_RAW_S16,
+    VNC_AUDIO_FORMAT_RAW_U32,
+    VNC_AUDIO_FORMAT_RAW_S32,
 } VncAudioFormatType;
 
 GType vnc_audio_format_get_type(void);
@@ -57,8 +57,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncaudiopulse.c b/src/vncaudiopulse.c
index b97a0e0..0fb5232 100644
--- a/src/vncaudiopulse.c
+++ b/src/vncaudiopulse.c
@@ -28,11 +28,11 @@
 #include "vncaudiopulse.h"
 #include "vncutil.h"
 
-#define VNC_AUDIO_PULSE_GET_PRIVATE(obj)				\
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_AUDIO_PULSE, VncAudioPulsePrivate))
+#define VNC_AUDIO_PULSE_GET_PRIVATE(obj)                                \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_AUDIO_PULSE, VncAudioPulsePrivate))
 
 struct _VncAudioPulsePrivate {
-	pa_simple *pa;
+    pa_simple *pa;
 };
 
 
@@ -40,128 +40,128 @@ G_DEFINE_TYPE(VncAudioPulse, vnc_audio_pulse, VNC_TYPE_BASE_AUDIO);
 
 
 static gboolean vnc_audio_pulse_playback_start(VncAudio *audio,
-					       VncAudioFormat *format)
+                                               VncAudioFormat *format)
 {
-	VncAudioPulse *pulse = VNC_AUDIO_PULSE(audio);
-	VncAudioPulsePrivate *priv = pulse->priv;
-	pa_sample_spec pulse_spec;
-	pa_buffer_attr buffer_attr;
-
-	if (priv->pa)
-		return FALSE;
-
-	switch (format->format) {
-	case VNC_AUDIO_FORMAT_RAW_U8:
-		pulse_spec.format = PA_SAMPLE_U8;
-		break;
-	case VNC_AUDIO_FORMAT_RAW_S16:
-		pulse_spec.format = PA_SAMPLE_S16LE;
-		break;
-	case VNC_AUDIO_FORMAT_RAW_S32:
-		pulse_spec.format = PA_SAMPLE_S32LE;
-		break;
-
-	case VNC_AUDIO_FORMAT_RAW_S8:
-	case VNC_AUDIO_FORMAT_RAW_U16:
-	case VNC_AUDIO_FORMAT_RAW_U32:
-	default:
-		return FALSE;
-	}
-	pulse_spec.channels = format->nchannels;
-	pulse_spec.rate = format->frequency;
-
-	/* FIXME: we might want customizable latency */
-	memset(&buffer_attr, 0, sizeof(buffer_attr));
-	buffer_attr.maxlength = -1;
-	buffer_attr.tlength = pa_usec_to_bytes(100 * PA_USEC_PER_MSEC, &pulse_spec);
-	buffer_attr.prebuf = -1;
-	buffer_attr.minreq = -1;
-
-	priv->pa = pa_simple_new(NULL, "gvnc", PA_STREAM_PLAYBACK,
-				 NULL, "VNC Remote Desktop",
-				 &pulse_spec, NULL, &buffer_attr, NULL);
-	return TRUE;
+    VncAudioPulse *pulse = VNC_AUDIO_PULSE(audio);
+    VncAudioPulsePrivate *priv = pulse->priv;
+    pa_sample_spec pulse_spec;
+    pa_buffer_attr buffer_attr;
+
+    if (priv->pa)
+        return FALSE;
+
+    switch (format->format) {
+    case VNC_AUDIO_FORMAT_RAW_U8:
+        pulse_spec.format = PA_SAMPLE_U8;
+        break;
+    case VNC_AUDIO_FORMAT_RAW_S16:
+        pulse_spec.format = PA_SAMPLE_S16LE;
+        break;
+    case VNC_AUDIO_FORMAT_RAW_S32:
+        pulse_spec.format = PA_SAMPLE_S32LE;
+        break;
+
+    case VNC_AUDIO_FORMAT_RAW_S8:
+    case VNC_AUDIO_FORMAT_RAW_U16:
+    case VNC_AUDIO_FORMAT_RAW_U32:
+    default:
+        return FALSE;
+    }
+    pulse_spec.channels = format->nchannels;
+    pulse_spec.rate = format->frequency;
+
+    /* FIXME: we might want customizable latency */
+    memset(&buffer_attr, 0, sizeof(buffer_attr));
+    buffer_attr.maxlength = -1;
+    buffer_attr.tlength = pa_usec_to_bytes(100 * PA_USEC_PER_MSEC, &pulse_spec);
+    buffer_attr.prebuf = -1;
+    buffer_attr.minreq = -1;
+
+    priv->pa = pa_simple_new(NULL, "gvnc", PA_STREAM_PLAYBACK,
+                             NULL, "VNC Remote Desktop",
+                             &pulse_spec, NULL, &buffer_attr, NULL);
+    return TRUE;
 }
 
 static gboolean vnc_audio_pulse_playback_stop(VncAudio *audio)
 {
-	VncAudioPulse *pulse = VNC_AUDIO_PULSE(audio);
-	VncAudioPulsePrivate *priv = pulse->priv;
+    VncAudioPulse *pulse = VNC_AUDIO_PULSE(audio);
+    VncAudioPulsePrivate *priv = pulse->priv;
 
-	if (!priv->pa)
-		return FALSE;
+    if (!priv->pa)
+        return FALSE;
 
-	pa_simple_drain(priv->pa, NULL);
-	pa_simple_free(priv->pa);
-        priv->pa = NULL;
+    pa_simple_drain(priv->pa, NULL);
+    pa_simple_free(priv->pa);
+    priv->pa = NULL;
 
-	return TRUE;
+    return TRUE;
 }
 
 static gboolean vnc_audio_pulse_playback_data(VncAudio *audio,
-					      VncAudioSample *sample)
+                                              VncAudioSample *sample)
 {
-	VncAudioPulse *pulse = VNC_AUDIO_PULSE(audio);
-	VncAudioPulsePrivate *priv = pulse->priv;
+    VncAudioPulse *pulse = VNC_AUDIO_PULSE(audio);
+    VncAudioPulsePrivate *priv = pulse->priv;
 
-	if (pa_simple_write(priv->pa, sample->data, sample->length, NULL) < 0)
-		return FALSE;
+    if (pa_simple_write(priv->pa, sample->data, sample->length, NULL) < 0)
+        return FALSE;
 
-	return TRUE;
+    return TRUE;
 }
 
 static void vnc_audio_pulse_finalize(GObject *object)
 {
-	VncAudioPulse *ab = VNC_AUDIO_PULSE(object);
-	VncAudioPulsePrivate *priv = ab->priv;
+    VncAudioPulse *ab = VNC_AUDIO_PULSE(object);
+    VncAudioPulsePrivate *priv = ab->priv;
 
-	VNC_DEBUG("Finalize VncAudioPulse=%p", ab);
+    VNC_DEBUG("Finalize VncAudioPulse=%p", ab);
 
-	if (priv->pa)
-		pa_simple_free(priv->pa);
+    if (priv->pa)
+        pa_simple_free(priv->pa);
 
-	G_OBJECT_CLASS(vnc_audio_pulse_parent_class)->finalize (object);
+    G_OBJECT_CLASS(vnc_audio_pulse_parent_class)->finalize (object);
 }
 
 
 static void vnc_audio_pulse_class_init(VncAudioPulseClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	object_class->finalize = vnc_audio_pulse_finalize;
+    object_class->finalize = vnc_audio_pulse_finalize;
 
-	g_type_class_add_private(klass, sizeof(VncAudioPulsePrivate));
+    g_type_class_add_private(klass, sizeof(VncAudioPulsePrivate));
 }
 
 
 void vnc_audio_pulse_init(VncAudioPulse *fb)
 {
-	VncAudioPulsePrivate *priv;
+    VncAudioPulsePrivate *priv;
 
-	priv = fb->priv = VNC_AUDIO_PULSE_GET_PRIVATE(fb);
+    priv = fb->priv = VNC_AUDIO_PULSE_GET_PRIVATE(fb);
 
-	memset(priv, 0, sizeof(*priv));
+    memset(priv, 0, sizeof(*priv));
 
-	g_signal_connect(G_OBJECT(fb), "vnc-audio-playback-start",
-			 G_CALLBACK(vnc_audio_pulse_playback_start), NULL);
-	g_signal_connect(G_OBJECT(fb), "vnc-audio-playback-stop",
-			 G_CALLBACK(vnc_audio_pulse_playback_stop), NULL);
-	g_signal_connect(G_OBJECT(fb), "vnc-audio-playback-data",
-			 G_CALLBACK(vnc_audio_pulse_playback_data), NULL);
+    g_signal_connect(G_OBJECT(fb), "vnc-audio-playback-start",
+                     G_CALLBACK(vnc_audio_pulse_playback_start), NULL);
+    g_signal_connect(G_OBJECT(fb), "vnc-audio-playback-stop",
+                     G_CALLBACK(vnc_audio_pulse_playback_stop), NULL);
+    g_signal_connect(G_OBJECT(fb), "vnc-audio-playback-data",
+                     G_CALLBACK(vnc_audio_pulse_playback_data), NULL);
 }
 
 
 VncAudioPulse *vnc_audio_pulse_new(void)
 {
-	return VNC_AUDIO_PULSE(g_object_new(VNC_TYPE_AUDIO_PULSE,
-					   NULL));
+    return VNC_AUDIO_PULSE(g_object_new(VNC_TYPE_AUDIO_PULSE,
+                                        NULL));
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncaudiopulse.h b/src/vncaudiopulse.h
index 3543bd4..6f522c0 100644
--- a/src/vncaudiopulse.h
+++ b/src/vncaudiopulse.h
@@ -41,14 +41,14 @@ typedef struct _VncAudioPulseClass VncAudioPulseClass;
 
 struct _VncAudioPulse
 {
-	VncBaseAudio parent;
+    VncBaseAudio parent;
 
-	VncAudioPulsePrivate *priv;
+    VncAudioPulsePrivate *priv;
 };
 
 struct _VncAudioPulseClass
 {
-	VncBaseAudioClass parent_class;
+    VncBaseAudioClass parent_class;
 
 };
 
@@ -63,8 +63,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncaudiosample.c b/src/vncaudiosample.c
index 993a8c3..4796b09 100644
--- a/src/vncaudiosample.c
+++ b/src/vncaudiosample.c
@@ -26,54 +26,54 @@
 
 GType vnc_audio_sample_get_type(void)
 {
-	static GType audio_sample_type = 0;
+    static GType audio_sample_type = 0;
 
-	if (G_UNLIKELY(audio_sample_type == 0)) {
-		audio_sample_type = g_boxed_type_register_static
-			("VncAudioSample",
-			 (GBoxedCopyFunc)vnc_audio_sample_copy,
-			 (GBoxedFreeFunc)vnc_audio_sample_free);
-	}
+    if (G_UNLIKELY(audio_sample_type == 0)) {
+        audio_sample_type = g_boxed_type_register_static
+            ("VncAudioSample",
+             (GBoxedCopyFunc)vnc_audio_sample_copy,
+             (GBoxedFreeFunc)vnc_audio_sample_free);
+    }
 
-	return audio_sample_type;
+    return audio_sample_type;
 }
 
 
 VncAudioSample *vnc_audio_sample_new(guint32 capacity)
 {
-	VncAudioSample *sample;
+    VncAudioSample *sample;
 
-	sample = g_slice_new0(VncAudioSample);
-	sample->length = 0;
-	sample->capacity = capacity;
-	sample->data = g_new0(guint8, capacity);
+    sample = g_slice_new0(VncAudioSample);
+    sample->length = 0;
+    sample->capacity = capacity;
+    sample->data = g_new0(guint8, capacity);
 
-	return sample;
+    return sample;
 }
 
 
 VncAudioSample *vnc_audio_sample_copy(VncAudioSample *srcSample)
 {
-	VncAudioSample *sample;
+    VncAudioSample *sample;
 
-	sample = g_slice_dup(VncAudioSample, srcSample);
-	sample->data = g_new0(guint8, srcSample->capacity);
-	memcpy(sample->data, srcSample->data, srcSample->length);
+    sample = g_slice_dup(VncAudioSample, srcSample);
+    sample->data = g_new0(guint8, srcSample->capacity);
+    memcpy(sample->data, srcSample->data, srcSample->length);
 
-	return sample;
+    return sample;
 }
 
 
 void vnc_audio_sample_free(VncAudioSample *sample)
 {
-        g_free(sample->data);
-	g_slice_free(VncAudioSample, sample);
+    g_free(sample->data);
+    g_slice_free(VncAudioSample, sample);
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncaudiosample.h b/src/vncaudiosample.h
index ad68053..52995cd 100644
--- a/src/vncaudiosample.h
+++ b/src/vncaudiosample.h
@@ -31,9 +31,9 @@ G_BEGIN_DECLS
 typedef struct _VncAudioSample VncAudioSample;
 
 struct _VncAudioSample {
-	guint8 *data;
-	guint32 length;
-	guint32 capacity;
+    guint8 *data;
+    guint32 length;
+    guint32 capacity;
 };
 
 GType vnc_audio_sample_get_type(void);
@@ -48,8 +48,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncbaseaudio.c b/src/vncbaseaudio.c
index 47e81a9..dd01b14 100644
--- a/src/vncbaseaudio.c
+++ b/src/vncbaseaudio.c
@@ -26,16 +26,16 @@
 #include "vncutil.h"
 #include "coroutine.h"
 
-#define VNC_BASE_AUDIO_GET_PRIVATE(obj)				\
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_BASE_AUDIO, VncBaseAudioPrivate))
+#define VNC_BASE_AUDIO_GET_PRIVATE(obj)                                 \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_BASE_AUDIO, VncBaseAudioPrivate))
 
 struct _VncBaseAudioPrivate {
-	gboolean unused;
+    gboolean unused;
 };
 
 
 static void vnc_base_audio_interface_init(gpointer g_iface,
-					  gpointer iface_data);
+                                          gpointer iface_data);
 
 G_DEFINE_TYPE_EXTENDED(VncBaseAudio, vnc_base_audio, G_TYPE_OBJECT, 0,
                        G_IMPLEMENT_INTERFACE(VNC_TYPE_AUDIO, vnc_base_audio_interface_init));
@@ -43,80 +43,80 @@ G_DEFINE_TYPE_EXTENDED(VncBaseAudio, vnc_base_audio, G_TYPE_OBJECT, 0,
 
 static void vnc_base_audio_class_init(VncBaseAudioClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	g_signal_new("vnc-audio-playback-start",
-		     G_OBJECT_CLASS_TYPE (object_class),
-		     G_SIGNAL_RUN_FIRST,
-		     G_STRUCT_OFFSET (VncBaseAudioClass, playback_start),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__BOXED,
-		     G_TYPE_NONE,
-		     1,
-		     VNC_TYPE_AUDIO_FORMAT);
-
-	g_signal_new("vnc-audio-playback-stop",
-		     G_OBJECT_CLASS_TYPE (object_class),
-		     G_SIGNAL_RUN_FIRST,
-		     G_STRUCT_OFFSET (VncBaseAudioClass, playback_stop),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__VOID,
-		     G_TYPE_NONE,
-		     0);
-
-	g_signal_new("vnc-audio-playback-data",
-		     G_OBJECT_CLASS_TYPE (object_class),
-		     G_SIGNAL_RUN_FIRST,
-		     G_STRUCT_OFFSET (VncBaseAudioClass, playback_data),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__BOXED,
-		     G_TYPE_NONE,
-		     1,
-		     VNC_TYPE_AUDIO_SAMPLE);
-
-	g_type_class_add_private(klass, sizeof(VncBaseAudioPrivate));
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    g_signal_new("vnc-audio-playback-start",
+                 G_OBJECT_CLASS_TYPE (object_class),
+                 G_SIGNAL_RUN_FIRST,
+                 G_STRUCT_OFFSET (VncBaseAudioClass, playback_start),
+                 NULL, NULL,
+                 g_cclosure_marshal_VOID__BOXED,
+                 G_TYPE_NONE,
+                 1,
+                 VNC_TYPE_AUDIO_FORMAT);
+
+    g_signal_new("vnc-audio-playback-stop",
+                 G_OBJECT_CLASS_TYPE (object_class),
+                 G_SIGNAL_RUN_FIRST,
+                 G_STRUCT_OFFSET (VncBaseAudioClass, playback_stop),
+                 NULL, NULL,
+                 g_cclosure_marshal_VOID__VOID,
+                 G_TYPE_NONE,
+                 0);
+
+    g_signal_new("vnc-audio-playback-data",
+                 G_OBJECT_CLASS_TYPE (object_class),
+                 G_SIGNAL_RUN_FIRST,
+                 G_STRUCT_OFFSET (VncBaseAudioClass, playback_data),
+                 NULL, NULL,
+                 g_cclosure_marshal_VOID__BOXED,
+                 G_TYPE_NONE,
+                 1,
+                 VNC_TYPE_AUDIO_SAMPLE);
+
+    g_type_class_add_private(klass, sizeof(VncBaseAudioPrivate));
 }
 
 
 void vnc_base_audio_init(VncBaseAudio *fb)
 {
-	VncBaseAudioPrivate *priv;
+    VncBaseAudioPrivate *priv;
 
-	priv = fb->priv = VNC_BASE_AUDIO_GET_PRIVATE(fb);
+    priv = fb->priv = VNC_BASE_AUDIO_GET_PRIVATE(fb);
 
-	memset(priv, 0, sizeof(*priv));
+    memset(priv, 0, sizeof(*priv));
 }
 
 
 VncBaseAudio *vnc_base_audio_new(void)
 {
-	return VNC_BASE_AUDIO(g_object_new(VNC_TYPE_BASE_AUDIO,
-					   NULL));
+    return VNC_BASE_AUDIO(g_object_new(VNC_TYPE_BASE_AUDIO,
+                                       NULL));
 }
 
 
 static gboolean vnc_base_audio_playback_start(VncAudio *audio,
-					      VncAudioFormat *format)
+                                              VncAudioFormat *format)
 {
-	g_signal_emit_by_name(audio, "vnc-audio-playback-start", format);
-	return TRUE;
+    g_signal_emit_by_name(audio, "vnc-audio-playback-start", format);
+    return TRUE;
 }
 
 static gboolean vnc_base_audio_playback_stop(VncAudio *audio)
 {
-	g_signal_emit_by_name(audio, "vnc-audio-playback-stop");
-	return TRUE;
+    g_signal_emit_by_name(audio, "vnc-audio-playback-stop");
+    return TRUE;
 }
 
 static gboolean vnc_base_audio_playback_data(VncAudio *audio,
-					     VncAudioSample *sample)
+                                             VncAudioSample *sample)
 {
-	g_signal_emit_by_name(audio, "vnc-audio-playback-data", sample);
-	return TRUE;
+    g_signal_emit_by_name(audio, "vnc-audio-playback-data", sample);
+    return TRUE;
 }
 
 static void vnc_base_audio_interface_init(gpointer g_iface,
-					  gpointer iface_data G_GNUC_UNUSED)
+                                          gpointer iface_data G_GNUC_UNUSED)
 {
     VncAudioInterface *iface = g_iface;
 
@@ -127,8 +127,8 @@ static void vnc_base_audio_interface_init(gpointer g_iface,
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncbaseaudio.h b/src/vncbaseaudio.h
index 1890226..dd12d81 100644
--- a/src/vncbaseaudio.h
+++ b/src/vncbaseaudio.h
@@ -41,18 +41,18 @@ typedef struct _VncBaseAudioClass VncBaseAudioClass;
 
 struct _VncBaseAudio
 {
-	GObject parent;
+    GObject parent;
 
-	VncBaseAudioPrivate *priv;
+    VncBaseAudioPrivate *priv;
 };
 
 struct _VncBaseAudioClass
 {
-	GObjectClass parent_class;
+    GObjectClass parent_class;
 
-	gboolean (*playback_start)(VncBaseAudio *audio, VncAudioFormat *format);
-	gboolean (*playback_stop)(VncBaseAudio *audio);
-	gboolean (*playback_data)(VncBaseAudio *audio, VncAudioSample *sample);
+    gboolean (*playback_start)(VncBaseAudio *audio, VncAudioFormat *format);
+    gboolean (*playback_stop)(VncBaseAudio *audio);
+    gboolean (*playback_data)(VncBaseAudio *audio, VncAudioSample *sample);
 };
 
 
@@ -66,8 +66,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncbaseframebuffer.c b/src/vncbaseframebuffer.c
index 689b469..283c39a 100644
--- a/src/vncbaseframebuffer.c
+++ b/src/vncbaseframebuffer.c
@@ -27,58 +27,58 @@
 #include "vncutil.h"
 
 typedef void vnc_base_framebuffer_blt_func(VncBaseFramebufferPrivate *priv,
-					   guint8 *src,
-					   int rowstride,
-					   guint16 x, guint16 y,
-					   guint16 widht, guint16 width);
+                                           guint8 *src,
+                                           int rowstride,
+                                           guint16 x, guint16 y,
+                                           guint16 widht, guint16 width);
 typedef void vnc_base_framebuffer_fill_func(VncBaseFramebufferPrivate *priv,
-					    guint8 *src,
-					    guint16 x, guint16 y,
-					    guint16 widht, guint16 width);
+                                            guint8 *src,
+                                            guint16 x, guint16 y,
+                                            guint16 widht, guint16 width);
 typedef void vnc_base_framebuffer_set_pixel_at_func(VncBaseFramebufferPrivate *priv,
-						    guint8 *src,
-						    guint16 x, guint16 y);
+                                                    guint8 *src,
+                                                    guint16 x, guint16 y);
 typedef void vnc_base_framebuffer_rgb24_blt_func(VncBaseFramebufferPrivate *priv,
-						 guint8 *src, int rowstride,
-						 guint16 x, guint16 y,
-						 guint16 width, guint16 height);
+                                                 guint8 *src, int rowstride,
+                                                 guint16 x, guint16 y,
+                                                 guint16 width, guint16 height);
 
 
-#define VNC_BASE_FRAMEBUFFER_GET_PRIVATE(obj)				\
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_BASE_FRAMEBUFFER, VncBaseFramebufferPrivate))
+#define VNC_BASE_FRAMEBUFFER_GET_PRIVATE(obj)                           \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_BASE_FRAMEBUFFER, VncBaseFramebufferPrivate))
 
 struct _VncBaseFramebufferPrivate {
-	guint8 *buffer; /* Owned by caller, so no need to free */
-	guint16 width;
-	guint16 height;
-	int rowstride;
+    guint8 *buffer; /* Owned by caller, so no need to free */
+    guint16 width;
+    guint16 height;
+    int rowstride;
 
-	VncPixelFormat *localFormat;
-	VncPixelFormat *remoteFormat;
+    VncPixelFormat *localFormat;
+    VncPixelFormat *remoteFormat;
 
-	VncColorMap *colorMap;
+    VncColorMap *colorMap;
 
-	/* TRUE if the following derived data needs reinitializing */
-	gboolean reinitRenderFuncs;
+    /* TRUE if the following derived data needs reinitializing */
+    gboolean reinitRenderFuncs;
 
-	/* Derived from above data */
-	int rm, gm, bm;
-        int rrs, grs, brs;
-        int rls, gls, bls;
-	int alpha_mask;
+    /* Derived from above data */
+    int rm, gm, bm;
+    int rrs, grs, brs;
+    int rls, gls, bls;
+    int alpha_mask;
 
-	/* TRUE if localFormat == remoteFormat */
-        gboolean perfect_match;
+    /* TRUE if localFormat == remoteFormat */
+    gboolean perfect_match;
 
-	/* Render function impls for this local+remote format pair */
-        vnc_base_framebuffer_set_pixel_at_func *set_pixel_at;
-        vnc_base_framebuffer_fill_func *fill;
-        vnc_base_framebuffer_blt_func *blt;
-        vnc_base_framebuffer_rgb24_blt_func *rgb24_blt;
+    /* Render function impls for this local+remote format pair */
+    vnc_base_framebuffer_set_pixel_at_func *set_pixel_at;
+    vnc_base_framebuffer_fill_func *fill;
+    vnc_base_framebuffer_blt_func *blt;
+    vnc_base_framebuffer_rgb24_blt_func *rgb24_blt;
 };
 
-#define VNC_BASE_FRAMEBUFFER_AT(priv, x, y) \
-	((priv)->buffer + ((y) * (priv)->rowstride) + ((x) * ((priv)->localFormat->bits_per_pixel/8)))
+#define VNC_BASE_FRAMEBUFFER_AT(priv, x, y)                             \
+    ((priv)->buffer + ((y) * (priv)->rowstride) + ((x) * ((priv)->localFormat->bits_per_pixel/8)))
 
 
 static void vnc_base_framebuffer_interface_init (gpointer g_iface,
@@ -89,419 +89,419 @@ G_DEFINE_TYPE_EXTENDED(VncBaseFramebuffer, vnc_base_framebuffer, G_TYPE_OBJECT,
 
 
 enum {
-	PROP_0,
-	PROP_BUFFER,
-	PROP_WIDTH,
-	PROP_HEIGHT,
-	PROP_ROWSTRIDE,
-	PROP_LOCAL_FORMAT,
-	PROP_REMOTE_FORMAT,
-	PROP_COLOR_MAP,
+    PROP_0,
+    PROP_BUFFER,
+    PROP_WIDTH,
+    PROP_HEIGHT,
+    PROP_ROWSTRIDE,
+    PROP_LOCAL_FORMAT,
+    PROP_REMOTE_FORMAT,
+    PROP_COLOR_MAP,
 };
 
 
 static void vnc_base_framebuffer_get_property(GObject *object,
-					      guint prop_id,
-					      GValue *value,
-					      GParamSpec *pspec)
+                                              guint prop_id,
+                                              GValue *value,
+                                              GParamSpec *pspec)
 {
-	VncBaseFramebuffer *framebuffer = VNC_BASE_FRAMEBUFFER(object);
-	VncBaseFramebufferPrivate *priv = framebuffer->priv;
+    VncBaseFramebuffer *framebuffer = VNC_BASE_FRAMEBUFFER(object);
+    VncBaseFramebufferPrivate *priv = framebuffer->priv;
 
-	switch (prop_id) {
-	case PROP_BUFFER:
-		g_value_set_pointer(value, priv->buffer);
-		break;
+    switch (prop_id) {
+    case PROP_BUFFER:
+        g_value_set_pointer(value, priv->buffer);
+        break;
 
-	case PROP_WIDTH:
-		g_value_set_int(value, priv->width);
-		break;
+    case PROP_WIDTH:
+        g_value_set_int(value, priv->width);
+        break;
 
-	case PROP_HEIGHT:
-		g_value_set_int(value, priv->height);
-		break;
+    case PROP_HEIGHT:
+        g_value_set_int(value, priv->height);
+        break;
 
-	case PROP_ROWSTRIDE:
-		g_value_set_int(value, priv->rowstride);
-		break;
+    case PROP_ROWSTRIDE:
+        g_value_set_int(value, priv->rowstride);
+        break;
 
-	case PROP_LOCAL_FORMAT:
-		g_value_set_boxed(value, priv->localFormat);
-		break;
+    case PROP_LOCAL_FORMAT:
+        g_value_set_boxed(value, priv->localFormat);
+        break;
 
-	case PROP_REMOTE_FORMAT:
-		g_value_set_boxed(value, priv->remoteFormat);
-		break;
+    case PROP_REMOTE_FORMAT:
+        g_value_set_boxed(value, priv->remoteFormat);
+        break;
 
-	case PROP_COLOR_MAP:
-		g_value_set_boxed(value, priv->colorMap);
-		break;
+    case PROP_COLOR_MAP:
+        g_value_set_boxed(value, priv->colorMap);
+        break;
 
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-	}
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 static void vnc_base_framebuffer_set_property(GObject *object,
-					      guint prop_id,
-					      const GValue *value,
-					      GParamSpec *pspec)
+                                              guint prop_id,
+                                              const GValue *value,
+                                              GParamSpec *pspec)
 {
-	VncBaseFramebuffer *framebuffer = VNC_BASE_FRAMEBUFFER(object);
-	VncBaseFramebufferPrivate *priv = framebuffer->priv;
-
-	switch (prop_id){
-	case PROP_BUFFER:
-		priv->buffer = g_value_get_pointer(value);
-		priv->reinitRenderFuncs = TRUE;
-		break;
-
-	case PROP_WIDTH:
-		priv->width = g_value_get_int(value);
-		priv->reinitRenderFuncs = TRUE;
-		break;
-
-	case PROP_HEIGHT:
-		priv->height = g_value_get_int(value);
-		priv->reinitRenderFuncs = TRUE;
-		break;
-
-	case PROP_ROWSTRIDE:
-		priv->rowstride = g_value_get_int(value);
-		priv->reinitRenderFuncs = TRUE;
-		break;
-
-	case PROP_LOCAL_FORMAT:
-		if (priv->localFormat)
-			vnc_pixel_format_free(priv->localFormat);
-		priv->localFormat = g_value_dup_boxed(value);
-		priv->reinitRenderFuncs = TRUE;
-		break;
-
-	case PROP_REMOTE_FORMAT:
-		if (priv->remoteFormat)
-			vnc_pixel_format_free(priv->remoteFormat);
-		priv->remoteFormat = g_value_dup_boxed(value);
-		priv->reinitRenderFuncs = TRUE;
-		break;
-
-	case PROP_COLOR_MAP:
-		if (priv->colorMap)
-			vnc_color_map_free(priv->colorMap);
-		priv->colorMap = g_value_dup_boxed(value);
-		priv->reinitRenderFuncs = TRUE;
-		break;
-
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-        }
+    VncBaseFramebuffer *framebuffer = VNC_BASE_FRAMEBUFFER(object);
+    VncBaseFramebufferPrivate *priv = framebuffer->priv;
+
+    switch (prop_id){
+    case PROP_BUFFER:
+        priv->buffer = g_value_get_pointer(value);
+        priv->reinitRenderFuncs = TRUE;
+        break;
+
+    case PROP_WIDTH:
+        priv->width = g_value_get_int(value);
+        priv->reinitRenderFuncs = TRUE;
+        break;
+
+    case PROP_HEIGHT:
+        priv->height = g_value_get_int(value);
+        priv->reinitRenderFuncs = TRUE;
+        break;
+
+    case PROP_ROWSTRIDE:
+        priv->rowstride = g_value_get_int(value);
+        priv->reinitRenderFuncs = TRUE;
+        break;
+
+    case PROP_LOCAL_FORMAT:
+        if (priv->localFormat)
+            vnc_pixel_format_free(priv->localFormat);
+        priv->localFormat = g_value_dup_boxed(value);
+        priv->reinitRenderFuncs = TRUE;
+        break;
+
+    case PROP_REMOTE_FORMAT:
+        if (priv->remoteFormat)
+            vnc_pixel_format_free(priv->remoteFormat);
+        priv->remoteFormat = g_value_dup_boxed(value);
+        priv->reinitRenderFuncs = TRUE;
+        break;
+
+    case PROP_COLOR_MAP:
+        if (priv->colorMap)
+            vnc_color_map_free(priv->colorMap);
+        priv->colorMap = g_value_dup_boxed(value);
+        priv->reinitRenderFuncs = TRUE;
+        break;
+
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 
 static void vnc_base_framebuffer_finalize(GObject *object)
 {
-	VncBaseFramebuffer *ab = VNC_BASE_FRAMEBUFFER(object);
-	VncBaseFramebufferPrivate *priv = ab->priv;
+    VncBaseFramebuffer *ab = VNC_BASE_FRAMEBUFFER(object);
+    VncBaseFramebufferPrivate *priv = ab->priv;
 
-	VNC_DEBUG("Finalize VncBaseFramebuffer=%p", ab);
+    VNC_DEBUG("Finalize VncBaseFramebuffer=%p", ab);
 
-	if (priv->localFormat)
-		vnc_pixel_format_free(priv->localFormat);
-	if (priv->remoteFormat)
-		vnc_pixel_format_free(priv->remoteFormat);
-	if (priv->colorMap)
-		vnc_color_map_free(priv->colorMap);
+    if (priv->localFormat)
+        vnc_pixel_format_free(priv->localFormat);
+    if (priv->remoteFormat)
+        vnc_pixel_format_free(priv->remoteFormat);
+    if (priv->colorMap)
+        vnc_color_map_free(priv->colorMap);
 
-	G_OBJECT_CLASS(vnc_base_framebuffer_parent_class)->finalize (object);
+    G_OBJECT_CLASS(vnc_base_framebuffer_parent_class)->finalize (object);
 }
 
 
 static void vnc_base_framebuffer_class_init(VncBaseFramebufferClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = vnc_base_framebuffer_finalize;
-	object_class->get_property = vnc_base_framebuffer_get_property;
-	object_class->set_property = vnc_base_framebuffer_set_property;
-
-	g_object_class_install_property(object_class,
-					PROP_BUFFER,
-					g_param_spec_pointer("buffer",
-							     "The framebuffer",
-							     "The framebuffer memory region",
-							     G_PARAM_READABLE |
-							     G_PARAM_WRITABLE |
-							     G_PARAM_CONSTRUCT_ONLY |
-							     G_PARAM_STATIC_NAME |
-							     G_PARAM_STATIC_NICK |
-							     G_PARAM_STATIC_BLURB));
-
-	g_object_class_install_property(object_class,
-					PROP_WIDTH,
-					g_param_spec_int("width",
-							 "Framebuffer width",
-							 "Width of the framebuffer in pixels",
-							 0, 1 << 16, 0,
-							 G_PARAM_READABLE |
-							 G_PARAM_WRITABLE |
-							 G_PARAM_CONSTRUCT_ONLY |
-							 G_PARAM_STATIC_NAME |
-							 G_PARAM_STATIC_NICK |
-							 G_PARAM_STATIC_BLURB));
-
-	g_object_class_install_property(object_class,
-					PROP_HEIGHT,
-					g_param_spec_int("height",
-							 "Framebuffer height",
-							 "Height of the framebuffer in pixels",
-							 0, 1 << 16, 0,
-							 G_PARAM_READABLE |
-							 G_PARAM_WRITABLE |
-							 G_PARAM_CONSTRUCT_ONLY |
-							 G_PARAM_STATIC_NAME |
-							 G_PARAM_STATIC_NICK |
-							 G_PARAM_STATIC_BLURB));
-
-	g_object_class_install_property(object_class,
-					PROP_ROWSTRIDE,
-					g_param_spec_int("rowstride",
-							 "Framebuffer rowstride",
-							 "Size of one framebuffer line in bytes",
-							 0, 1 << 30, 0,
-							 G_PARAM_READABLE |
-							 G_PARAM_WRITABLE |
-							 G_PARAM_CONSTRUCT_ONLY |
-							 G_PARAM_STATIC_NAME |
-							 G_PARAM_STATIC_NICK |
-							 G_PARAM_STATIC_BLURB));
-
-	g_object_class_install_property(object_class,
-					PROP_LOCAL_FORMAT,
-					g_param_spec_boxed("local-format",
-							   "Local pixel format",
-							   "The local pixel format of the framebuffer",
-							   VNC_TYPE_PIXEL_FORMAT,
-							   G_PARAM_READABLE |
-							   G_PARAM_WRITABLE |
-							   G_PARAM_CONSTRUCT_ONLY |
-							   G_PARAM_STATIC_NAME |
-							   G_PARAM_STATIC_NICK |
-							   G_PARAM_STATIC_BLURB));
-
-	g_object_class_install_property(object_class,
-					PROP_REMOTE_FORMAT,
-					g_param_spec_boxed("remote-format",
-							   "Remote pixel format",
-							   "The remote pixel format of the framebuffer",
-							   VNC_TYPE_PIXEL_FORMAT,
-							   G_PARAM_READABLE |
-							   G_PARAM_WRITABLE |
-							   G_PARAM_CONSTRUCT_ONLY |
-							   G_PARAM_STATIC_NAME |
-							   G_PARAM_STATIC_NICK |
-							   G_PARAM_STATIC_BLURB));
-
-	g_object_class_install_property(object_class,
-					PROP_COLOR_MAP,
-					g_param_spec_boxed("color-map",
-							   "Color map",
-							   "The color map",
-							   VNC_TYPE_COLOR_MAP,
-							   G_PARAM_READABLE |
-							   G_PARAM_WRITABLE |
-							   G_PARAM_STATIC_NAME |
-							   G_PARAM_STATIC_NICK |
-							   G_PARAM_STATIC_BLURB));
-
-	g_type_class_add_private(klass, sizeof(VncBaseFramebufferPrivate));
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = vnc_base_framebuffer_finalize;
+    object_class->get_property = vnc_base_framebuffer_get_property;
+    object_class->set_property = vnc_base_framebuffer_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_BUFFER,
+                                    g_param_spec_pointer("buffer",
+                                                         "The framebuffer",
+                                                         "The framebuffer memory region",
+                                                         G_PARAM_READABLE |
+                                                         G_PARAM_WRITABLE |
+                                                         G_PARAM_CONSTRUCT_ONLY |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+
+    g_object_class_install_property(object_class,
+                                    PROP_WIDTH,
+                                    g_param_spec_int("width",
+                                                     "Framebuffer width",
+                                                     "Width of the framebuffer in pixels",
+                                                     0, 1 << 16, 0,
+                                                     G_PARAM_READABLE |
+                                                     G_PARAM_WRITABLE |
+                                                     G_PARAM_CONSTRUCT_ONLY |
+                                                     G_PARAM_STATIC_NAME |
+                                                     G_PARAM_STATIC_NICK |
+                                                     G_PARAM_STATIC_BLURB));
+
+    g_object_class_install_property(object_class,
+                                    PROP_HEIGHT,
+                                    g_param_spec_int("height",
+                                                     "Framebuffer height",
+                                                     "Height of the framebuffer in pixels",
+                                                     0, 1 << 16, 0,
+                                                     G_PARAM_READABLE |
+                                                     G_PARAM_WRITABLE |
+                                                     G_PARAM_CONSTRUCT_ONLY |
+                                                     G_PARAM_STATIC_NAME |
+                                                     G_PARAM_STATIC_NICK |
+                                                     G_PARAM_STATIC_BLURB));
+
+    g_object_class_install_property(object_class,
+                                    PROP_ROWSTRIDE,
+                                    g_param_spec_int("rowstride",
+                                                     "Framebuffer rowstride",
+                                                     "Size of one framebuffer line in bytes",
+                                                     0, 1 << 30, 0,
+                                                     G_PARAM_READABLE |
+                                                     G_PARAM_WRITABLE |
+                                                     G_PARAM_CONSTRUCT_ONLY |
+                                                     G_PARAM_STATIC_NAME |
+                                                     G_PARAM_STATIC_NICK |
+                                                     G_PARAM_STATIC_BLURB));
+
+    g_object_class_install_property(object_class,
+                                    PROP_LOCAL_FORMAT,
+                                    g_param_spec_boxed("local-format",
+                                                       "Local pixel format",
+                                                       "The local pixel format of the framebuffer",
+                                                       VNC_TYPE_PIXEL_FORMAT,
+                                                       G_PARAM_READABLE |
+                                                       G_PARAM_WRITABLE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+    g_object_class_install_property(object_class,
+                                    PROP_REMOTE_FORMAT,
+                                    g_param_spec_boxed("remote-format",
+                                                       "Remote pixel format",
+                                                       "The remote pixel format of the framebuffer",
+                                                       VNC_TYPE_PIXEL_FORMAT,
+                                                       G_PARAM_READABLE |
+                                                       G_PARAM_WRITABLE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+    g_object_class_install_property(object_class,
+                                    PROP_COLOR_MAP,
+                                    g_param_spec_boxed("color-map",
+                                                       "Color map",
+                                                       "The color map",
+                                                       VNC_TYPE_COLOR_MAP,
+                                                       G_PARAM_READABLE |
+                                                       G_PARAM_WRITABLE |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+    g_type_class_add_private(klass, sizeof(VncBaseFramebufferPrivate));
 }
 
 
 void vnc_base_framebuffer_init(VncBaseFramebuffer *fb)
 {
-	VncBaseFramebufferPrivate *priv;
+    VncBaseFramebufferPrivate *priv;
 
-	priv = fb->priv = VNC_BASE_FRAMEBUFFER_GET_PRIVATE(fb);
+    priv = fb->priv = VNC_BASE_FRAMEBUFFER_GET_PRIVATE(fb);
 
-	memset(priv, 0, sizeof(*priv));
-	priv->reinitRenderFuncs = TRUE;
+    memset(priv, 0, sizeof(*priv));
+    priv->reinitRenderFuncs = TRUE;
 
-	priv->localFormat = vnc_pixel_format_new();
-	priv->remoteFormat = vnc_pixel_format_new();
+    priv->localFormat = vnc_pixel_format_new();
+    priv->remoteFormat = vnc_pixel_format_new();
 }
 
 
 VncBaseFramebuffer *vnc_base_framebuffer_new(guint8 *buffer,
-					     guint16 width,
-					     guint16 height,
-					     int rowstride,
-					     const VncPixelFormat *localFormat,
-					     const VncPixelFormat *remoteFormat)
+                                             guint16 width,
+                                             guint16 height,
+                                             int rowstride,
+                                             const VncPixelFormat *localFormat,
+                                             const VncPixelFormat *remoteFormat)
 {
-	return VNC_BASE_FRAMEBUFFER(g_object_new(VNC_TYPE_BASE_FRAMEBUFFER,
-						 "buffer", buffer,
-						 "width", width,
-						 "height", height,
-						 "rowstride", rowstride,
-						 "local-format", localFormat,
-						 "remote-format", remoteFormat,
-						 NULL));
+    return VNC_BASE_FRAMEBUFFER(g_object_new(VNC_TYPE_BASE_FRAMEBUFFER,
+                                             "buffer", buffer,
+                                             "width", width,
+                                             "height", height,
+                                             "rowstride", rowstride,
+                                             "local-format", localFormat,
+                                             "remote-format", remoteFormat,
+                                             NULL));
 }
 
 
 static guint16 vnc_base_framebuffer_get_width(VncFramebuffer *iface)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	return priv->width;
+    return priv->width;
 }
 
 
 static guint16 vnc_base_framebuffer_get_height(VncFramebuffer *iface)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	return priv->height;
+    return priv->height;
 }
 
 
 static int vnc_base_framebuffer_get_rowstride(VncFramebuffer *iface)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	return priv->rowstride;
+    return priv->rowstride;
 }
 
 
 static guint8 *vnc_base_framebuffer_get_buffer(VncFramebuffer *iface)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	return priv->buffer;
+    return priv->buffer;
 }
 
 
 static const VncPixelFormat *vnc_base_framebuffer_get_local_format(VncFramebuffer *iface)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	return priv->localFormat;
+    return priv->localFormat;
 }
 
 
 static const VncPixelFormat *vnc_base_framebuffer_get_remote_format(VncFramebuffer *iface)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	return priv->remoteFormat;
+    return priv->remoteFormat;
 }
 
 
 static gboolean vnc_base_framebuffer_perfect_format_match(VncFramebuffer *iface)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	return priv->perfect_match;
+    return priv->perfect_match;
 }
 
 
 static guint8 vnc_base_framebuffer_swap_img_8(VncBaseFramebufferPrivate *priv G_GNUC_UNUSED, guint8 pixel)
 {
-	return pixel;
+    return pixel;
 }
 
 
 static guint8 vnc_base_framebuffer_swap_rfb_8(VncBaseFramebufferPrivate *priv G_GNUC_UNUSED, guint8 pixel)
 {
-	return pixel;
+    return pixel;
 }
 
 
 /* local host native format -> X server image format */
 static guint16 vnc_base_framebuffer_swap_img_16(VncBaseFramebufferPrivate *priv, guint16 pixel)
 {
-	if (G_BYTE_ORDER != priv->localFormat->byte_order)
-		return  (((pixel >> 8) & 0xFF) << 0) |
-			(((pixel >> 0) & 0xFF) << 8);
-	else
-		return pixel;
+    if (G_BYTE_ORDER != priv->localFormat->byte_order)
+        return  (((pixel >> 8) & 0xFF) << 0) |
+            (((pixel >> 0) & 0xFF) << 8);
+    else
+        return pixel;
 }
 
 
 /* VNC server RFB  format ->  local host native format */
 static guint16 vnc_base_framebuffer_swap_rfb_16(VncBaseFramebufferPrivate *priv, guint16 pixel)
 {
-	if (priv->remoteFormat->byte_order != G_BYTE_ORDER)
-		return  (((pixel >> 8) & 0xFF) << 0) |
-			(((pixel >> 0) & 0xFF) << 8);
-	else
-		return pixel;
+    if (priv->remoteFormat->byte_order != G_BYTE_ORDER)
+        return  (((pixel >> 8) & 0xFF) << 0) |
+            (((pixel >> 0) & 0xFF) << 8);
+    else
+        return pixel;
 }
 
 
 /* local host native format -> X server image format */
 static guint32 vnc_base_framebuffer_swap_img_32(VncBaseFramebufferPrivate *priv, guint32 pixel)
 {
-	if (G_BYTE_ORDER != priv->localFormat->byte_order)
-		return  (((pixel >> 24) & 0xFF) <<  0) |
-			(((pixel >> 16) & 0xFF) <<  8) |
-			(((pixel >>  8) & 0xFF) << 16) |
-			(((pixel >>  0) & 0xFF) << 24);
-	else
-		return pixel;
+    if (G_BYTE_ORDER != priv->localFormat->byte_order)
+        return  (((pixel >> 24) & 0xFF) <<  0) |
+            (((pixel >> 16) & 0xFF) <<  8) |
+            (((pixel >>  8) & 0xFF) << 16) |
+            (((pixel >>  0) & 0xFF) << 24);
+    else
+        return pixel;
 }
 
 
 /* local host native format -> X server image format */
 static guint32 vnc_base_framebuffer_swap_img_64(VncBaseFramebufferPrivate *priv, guint64 pixel)
 {
-	if (G_BYTE_ORDER != priv->localFormat->byte_order)
-		return  (((pixel >> 56) & 0xFF) <<  0) |
-			(((pixel >> 48) & 0xFF) <<  8) |
-			(((pixel >> 40) & 0xFF) << 16) |
-			(((pixel >> 32) & 0xFF) << 24) |
-			(((pixel >> 24) & 0xFF) << 32) |
-			(((pixel >> 16) & 0xFF) << 40) |
-			(((pixel >>  8) & 0xFF) << 48) |
-			(((pixel >>  0) & 0xFF) << 56);
-	else
-		return pixel;
+    if (G_BYTE_ORDER != priv->localFormat->byte_order)
+        return  (((pixel >> 56) & 0xFF) <<  0) |
+            (((pixel >> 48) & 0xFF) <<  8) |
+            (((pixel >> 40) & 0xFF) << 16) |
+            (((pixel >> 32) & 0xFF) << 24) |
+            (((pixel >> 24) & 0xFF) << 32) |
+            (((pixel >> 16) & 0xFF) << 40) |
+            (((pixel >>  8) & 0xFF) << 48) |
+            (((pixel >>  0) & 0xFF) << 56);
+    else
+        return pixel;
 }
 
 
 /* VNC server RFB  format ->  local host native format */
 static guint32 vnc_base_framebuffer_swap_rfb_32(VncBaseFramebufferPrivate *priv, guint32 pixel)
 {
-	if (priv->remoteFormat->byte_order != G_BYTE_ORDER)
-		return  (((pixel >> 24) & 0xFF) <<  0) |
-			(((pixel >> 16) & 0xFF) <<  8) |
-			(((pixel >>  8) & 0xFF) << 16) |
-			(((pixel >>  0) & 0xFF) << 24);
-	else
-		return pixel;
+    if (priv->remoteFormat->byte_order != G_BYTE_ORDER)
+        return  (((pixel >> 24) & 0xFF) <<  0) |
+            (((pixel >> 16) & 0xFF) <<  8) |
+            (((pixel >>  8) & 0xFF) << 16) |
+            (((pixel >>  0) & 0xFF) << 24);
+    else
+        return pixel;
 }
 
 /* VNC server RFB  format ->  local host native format */
 static guint32 vnc_base_framebuffer_swap_rfb_64(VncBaseFramebufferPrivate *priv, guint64 pixel)
 {
-	if (priv->remoteFormat->byte_order != G_BYTE_ORDER)
-		return  (((pixel >> 56) & 0xFF) <<  0) |
-			(((pixel >> 48) & 0xFF) <<  8) |
-			(((pixel >> 40) & 0xFF) << 16) |
-			(((pixel >> 32) & 0xFF) << 24) |
-			(((pixel >> 24) & 0xFF) << 32) |
-			(((pixel >> 16) & 0xFF) << 40) |
-			(((pixel >>  8) & 0xFF) << 48) |
-			(((pixel >>  0) & 0xFF) << 56);
-	else
-		return pixel;
+    if (priv->remoteFormat->byte_order != G_BYTE_ORDER)
+        return  (((pixel >> 56) & 0xFF) <<  0) |
+            (((pixel >> 48) & 0xFF) <<  8) |
+            (((pixel >> 40) & 0xFF) << 16) |
+            (((pixel >> 32) & 0xFF) << 24) |
+            (((pixel >> 24) & 0xFF) << 32) |
+            (((pixel >> 16) & 0xFF) << 40) |
+            (((pixel >>  8) & 0xFF) << 48) |
+            (((pixel >>  0) & 0xFF) << 56);
+    else
+        return pixel;
 }
 
 #define SRC 8
@@ -660,327 +660,327 @@ static guint32 vnc_base_framebuffer_swap_rfb_64(VncBaseFramebufferPrivate *priv,
 #undef COLORMAP
 
 static vnc_base_framebuffer_set_pixel_at_func *vnc_base_framebuffer_set_pixel_at_table[6][4] = {
-        { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x8,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x16,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x32,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x64 },
-        { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x8,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x16,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x32,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x64 },
-        { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x8,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x16,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x32,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x64 },
-        { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x8,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x16,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x32,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x64 },
-        { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x8,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x16,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x32,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x64 },
-        { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x8,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x16,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x32,
-          (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x64 },
+    { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x8,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x16,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x32,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_8x64 },
+    { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x8,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x16,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x32,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_16x64 },
+    { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x8,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x16,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x32,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_32x64 },
+    { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x8,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x16,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x32,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_64x64 },
+    { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x8,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x16,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x32,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap8x64 },
+    { (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x8,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x16,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x32,
+      (vnc_base_framebuffer_set_pixel_at_func *)vnc_base_framebuffer_set_pixel_at_cmap16x64 },
 };
 
 static vnc_base_framebuffer_fill_func *vnc_base_framebuffer_fill_table[6][4] = {
-        { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x8,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x16,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x32,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x64 },
-        { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x8,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x16,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x32,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x64 },
-        { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x8,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x16,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x32,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x64 },
-        { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x8,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x16,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x32,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x64 },
-        { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x8,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x16,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x32,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x64 },
-        { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x8,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x16,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x32,
-          (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x64 },
+    { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x8,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x16,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x32,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_8x64 },
+    { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x8,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x16,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x32,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_16x64 },
+    { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x8,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x16,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x32,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_32x64 },
+    { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x8,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x16,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x32,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_64x64 },
+    { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x8,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x16,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x32,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap8x64 },
+    { (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x8,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x16,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x32,
+      (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_cmap16x64 },
 };
 
 static vnc_base_framebuffer_fill_func *vnc_base_framebuffer_fill_fast_table[4] = {
-	(vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_8x8,
-	(vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_16x16,
-	(vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_32x32,
-	(vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_64x64,
+    (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_8x8,
+    (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_16x16,
+    (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_32x32,
+    (vnc_base_framebuffer_fill_func *)vnc_base_framebuffer_fill_fast_64x64,
 };
 
 static vnc_base_framebuffer_blt_func *vnc_base_framebuffer_blt_table[6][4] = {
-        {  vnc_base_framebuffer_blt_8x8,
-	   vnc_base_framebuffer_blt_8x16,
-	   vnc_base_framebuffer_blt_8x32,
-	   vnc_base_framebuffer_blt_8x64 },
-        { vnc_base_framebuffer_blt_16x8,
-	  vnc_base_framebuffer_blt_16x16,
-	  vnc_base_framebuffer_blt_16x32,
-	  vnc_base_framebuffer_blt_16x64 },
-        { vnc_base_framebuffer_blt_32x8,
-	  vnc_base_framebuffer_blt_32x16,
-	  vnc_base_framebuffer_blt_32x32,
-	  vnc_base_framebuffer_blt_32x64 },
-        { vnc_base_framebuffer_blt_64x8,
-	  vnc_base_framebuffer_blt_64x16,
-	  vnc_base_framebuffer_blt_64x32,
-	  vnc_base_framebuffer_blt_64x64 },
-        { vnc_base_framebuffer_blt_cmap8x8,
-	  vnc_base_framebuffer_blt_cmap8x16,
-	  vnc_base_framebuffer_blt_cmap8x32,
-	  vnc_base_framebuffer_blt_cmap8x64 },
-        { vnc_base_framebuffer_blt_cmap16x8,
-	  vnc_base_framebuffer_blt_cmap16x16,
-	  vnc_base_framebuffer_blt_cmap16x32,
-	  vnc_base_framebuffer_blt_cmap16x64 },
+    {  vnc_base_framebuffer_blt_8x8,
+       vnc_base_framebuffer_blt_8x16,
+       vnc_base_framebuffer_blt_8x32,
+       vnc_base_framebuffer_blt_8x64 },
+    { vnc_base_framebuffer_blt_16x8,
+      vnc_base_framebuffer_blt_16x16,
+      vnc_base_framebuffer_blt_16x32,
+      vnc_base_framebuffer_blt_16x64 },
+    { vnc_base_framebuffer_blt_32x8,
+      vnc_base_framebuffer_blt_32x16,
+      vnc_base_framebuffer_blt_32x32,
+      vnc_base_framebuffer_blt_32x64 },
+    { vnc_base_framebuffer_blt_64x8,
+      vnc_base_framebuffer_blt_64x16,
+      vnc_base_framebuffer_blt_64x32,
+      vnc_base_framebuffer_blt_64x64 },
+    { vnc_base_framebuffer_blt_cmap8x8,
+      vnc_base_framebuffer_blt_cmap8x16,
+      vnc_base_framebuffer_blt_cmap8x32,
+      vnc_base_framebuffer_blt_cmap8x64 },
+    { vnc_base_framebuffer_blt_cmap16x8,
+      vnc_base_framebuffer_blt_cmap16x16,
+      vnc_base_framebuffer_blt_cmap16x32,
+      vnc_base_framebuffer_blt_cmap16x64 },
 };
 
 static vnc_base_framebuffer_rgb24_blt_func *vnc_base_framebuffer_rgb24_blt_table[4] = {
-        (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x8,
-        (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x16,
-        (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x32,
-        (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x64,
+    (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x8,
+    (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x16,
+    (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x32,
+    (vnc_base_framebuffer_rgb24_blt_func *)vnc_base_framebuffer_rgb24_blt_32x64,
 };
 
 
 /* a fast blit for the perfect match scenario */
 static void vnc_base_framebuffer_blt_fast(VncBaseFramebufferPrivate *priv,
-					  guint8 *src, int rowstride,
-					  guint16 x, guint16 y,
-					  guint16 width, guint16 height)
+                                          guint8 *src, int rowstride,
+                                          guint16 x, guint16 y,
+                                          guint16 width, guint16 height)
 {
-        guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
-        guint16 i;
-        for (i = 0; i < height; i++) {
-                memcpy(dst, src, width * (priv->localFormat->bits_per_pixel / 8));
-                dst += priv->rowstride;
-                src += rowstride;
-        }
+    guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
+    guint16 i;
+    for (i = 0; i < height; i++) {
+        memcpy(dst, src, width * (priv->localFormat->bits_per_pixel / 8));
+        dst += priv->rowstride;
+        src += rowstride;
+    }
 }
 
 
 static void vnc_base_framebuffer_reinit_render_funcs(VncBaseFramebuffer *fb)
 {
-	VncBaseFramebufferPrivate *priv = fb->priv;
-	int i, j, n;
-	int depth;
-
-	if (!priv->reinitRenderFuncs)
-		return;
-
-	if (!priv->remoteFormat->true_color_flag) {
-		priv->remoteFormat->red_max = ~(guint16)0;
-		priv->remoteFormat->green_max = ~(guint16)0;
-		priv->remoteFormat->blue_max = ~(guint16)0;
-		priv->remoteFormat->red_shift = 32;
-		priv->remoteFormat->green_shift = 16;
-		priv->remoteFormat->blue_shift = 0;
-		priv->remoteFormat->byte_order = G_BYTE_ORDER;
-	}
-
-	if (priv->remoteFormat->true_color_flag &&
-	    priv->localFormat->bits_per_pixel == priv->remoteFormat->bits_per_pixel &&
-	    priv->localFormat->red_max == priv->remoteFormat->red_max &&
-	    priv->localFormat->green_max == priv->remoteFormat->green_max &&
-	    priv->localFormat->blue_max == priv->remoteFormat->blue_max &&
-	    priv->localFormat->red_shift == priv->remoteFormat->red_shift &&
-	    priv->localFormat->green_shift == priv->remoteFormat->green_shift &&
-	    priv->localFormat->blue_shift == priv->remoteFormat->blue_shift &&
-	    priv->localFormat->byte_order == G_BYTE_ORDER &&
-	    priv->remoteFormat->byte_order == G_BYTE_ORDER)
-		priv->perfect_match = TRUE;
-	else
-		priv->perfect_match = FALSE;
-
-	depth = priv->remoteFormat->depth;
-	if (depth == 32)
-		depth = 24;
-
-	priv->rm = priv->localFormat->red_max & priv->remoteFormat->red_max;
-	priv->gm = priv->localFormat->green_max & priv->remoteFormat->green_max;
-	priv->bm = priv->localFormat->blue_max & priv->remoteFormat->blue_max;
-	VNC_DEBUG("Mask local: %3d %3d %3d\n"
-		   "    remote: %3d %3d %3d\n"
-		   "    merged: %3d %3d %3d",
-		   priv->localFormat->red_max, priv->localFormat->green_max, priv->localFormat->blue_max,
-		   priv->remoteFormat->red_max, priv->remoteFormat->green_max, priv->remoteFormat->blue_max,
-		   priv->rm, priv->gm, priv->bm);
-
-	/* Setup shifts assuming matched bpp (but not necessarily match rgb order)*/
-	priv->rrs = priv->remoteFormat->red_shift;
-	priv->grs = priv->remoteFormat->green_shift;
-	priv->brs = priv->remoteFormat->blue_shift;
-
-	priv->rls = priv->localFormat->red_shift;
-	priv->gls = priv->localFormat->green_shift;
-	priv->bls = priv->localFormat->blue_shift;
-
-	/* This adjusts for remote having more bpp than local */
-	for (n = priv->remoteFormat->red_max; n > priv->localFormat->red_max ; n>>= 1)
-		priv->rrs++;
-	for (n = priv->remoteFormat->green_max; n > priv->localFormat->green_max ; n>>= 1)
-		priv->grs++;
-	for (n = priv->remoteFormat->blue_max; n > priv->localFormat->blue_max ; n>>= 1)
-		priv->brs++;
-
-	/* This adjusts for remote having less bpp than remote */
-	for (n = priv->localFormat->red_max ; n > priv->remoteFormat->red_max ; n>>= 1)
-		priv->rls++;
-	for (n = priv->localFormat->green_max ; n > priv->remoteFormat->green_max ; n>>= 1)
-		priv->gls++;
-	for (n = priv->localFormat->blue_max ; n > priv->remoteFormat->blue_max ; n>>= 1)
-		priv->bls++;
-	VNC_DEBUG("Pixel shifts\n   right: %3d %3d %3d\n    left: %3d %3d %3d",
-		   priv->rrs, priv->grs, priv->brs,
-		   priv->rls, priv->gls, priv->bls);
-
-	i = priv->remoteFormat->bits_per_pixel / 8;
-	j = priv->localFormat->bits_per_pixel / 8;
-	if (i == 4) i = 3;
-	if (j == 4) {
-		j = 3;
-		priv->alpha_mask = 0xff000000;
-	}
-	if (i > 4) i = 4; /* XXX hardcoding int64 */
-	if (j > 4) j = 4; /* XXX hardcoding int64 */
-	if (!priv->remoteFormat->true_color_flag) {
-		if (priv->remoteFormat->bits_per_pixel == 8)
-			i = 5; /* 8bpp colourmap */
-		else
-			i = 6; /* 16bpp colourmap */
-		VNC_DEBUG("BPP i %d %d", priv->remoteFormat->bits_per_pixel, i);
-	}
-
-	priv->set_pixel_at = vnc_base_framebuffer_set_pixel_at_table[i - 1][j - 1];
-
-	if (priv->perfect_match)
-		priv->fill = vnc_base_framebuffer_fill_fast_table[i - 1];
-	else
-		priv->fill = vnc_base_framebuffer_fill_table[i - 1][j - 1];
-
-	if (priv->perfect_match)
-		priv->blt = vnc_base_framebuffer_blt_fast;
-	else
-		priv->blt = vnc_base_framebuffer_blt_table[i - 1][j - 1];
-
-	priv->rgb24_blt = vnc_base_framebuffer_rgb24_blt_table[i - 1];
-
-	priv->reinitRenderFuncs = FALSE;
+    VncBaseFramebufferPrivate *priv = fb->priv;
+    int i, j, n;
+    int depth;
+
+    if (!priv->reinitRenderFuncs)
+        return;
+
+    if (!priv->remoteFormat->true_color_flag) {
+        priv->remoteFormat->red_max = ~(guint16)0;
+        priv->remoteFormat->green_max = ~(guint16)0;
+        priv->remoteFormat->blue_max = ~(guint16)0;
+        priv->remoteFormat->red_shift = 32;
+        priv->remoteFormat->green_shift = 16;
+        priv->remoteFormat->blue_shift = 0;
+        priv->remoteFormat->byte_order = G_BYTE_ORDER;
+    }
+
+    if (priv->remoteFormat->true_color_flag &&
+        priv->localFormat->bits_per_pixel == priv->remoteFormat->bits_per_pixel &&
+        priv->localFormat->red_max == priv->remoteFormat->red_max &&
+        priv->localFormat->green_max == priv->remoteFormat->green_max &&
+        priv->localFormat->blue_max == priv->remoteFormat->blue_max &&
+        priv->localFormat->red_shift == priv->remoteFormat->red_shift &&
+        priv->localFormat->green_shift == priv->remoteFormat->green_shift &&
+        priv->localFormat->blue_shift == priv->remoteFormat->blue_shift &&
+        priv->localFormat->byte_order == G_BYTE_ORDER &&
+        priv->remoteFormat->byte_order == G_BYTE_ORDER)
+        priv->perfect_match = TRUE;
+    else
+        priv->perfect_match = FALSE;
+
+    depth = priv->remoteFormat->depth;
+    if (depth == 32)
+        depth = 24;
+
+    priv->rm = priv->localFormat->red_max & priv->remoteFormat->red_max;
+    priv->gm = priv->localFormat->green_max & priv->remoteFormat->green_max;
+    priv->bm = priv->localFormat->blue_max & priv->remoteFormat->blue_max;
+    VNC_DEBUG("Mask local: %3d %3d %3d\n"
+              "    remote: %3d %3d %3d\n"
+              "    merged: %3d %3d %3d",
+              priv->localFormat->red_max, priv->localFormat->green_max, priv->localFormat->blue_max,
+              priv->remoteFormat->red_max, priv->remoteFormat->green_max, priv->remoteFormat->blue_max,
+              priv->rm, priv->gm, priv->bm);
+
+    /* Setup shifts assuming matched bpp (but not necessarily match rgb order)*/
+    priv->rrs = priv->remoteFormat->red_shift;
+    priv->grs = priv->remoteFormat->green_shift;
+    priv->brs = priv->remoteFormat->blue_shift;
+
+    priv->rls = priv->localFormat->red_shift;
+    priv->gls = priv->localFormat->green_shift;
+    priv->bls = priv->localFormat->blue_shift;
+
+    /* This adjusts for remote having more bpp than local */
+    for (n = priv->remoteFormat->red_max; n > priv->localFormat->red_max ; n>>= 1)
+        priv->rrs++;
+    for (n = priv->remoteFormat->green_max; n > priv->localFormat->green_max ; n>>= 1)
+        priv->grs++;
+    for (n = priv->remoteFormat->blue_max; n > priv->localFormat->blue_max ; n>>= 1)
+        priv->brs++;
+
+    /* This adjusts for remote having less bpp than remote */
+    for (n = priv->localFormat->red_max ; n > priv->remoteFormat->red_max ; n>>= 1)
+        priv->rls++;
+    for (n = priv->localFormat->green_max ; n > priv->remoteFormat->green_max ; n>>= 1)
+        priv->gls++;
+    for (n = priv->localFormat->blue_max ; n > priv->remoteFormat->blue_max ; n>>= 1)
+        priv->bls++;
+    VNC_DEBUG("Pixel shifts\n   right: %3d %3d %3d\n    left: %3d %3d %3d",
+              priv->rrs, priv->grs, priv->brs,
+              priv->rls, priv->gls, priv->bls);
+
+    i = priv->remoteFormat->bits_per_pixel / 8;
+    j = priv->localFormat->bits_per_pixel / 8;
+    if (i == 4) i = 3;
+    if (j == 4) {
+        j = 3;
+        priv->alpha_mask = 0xff000000;
+    }
+    if (i > 4) i = 4; /* XXX hardcoding int64 */
+    if (j > 4) j = 4; /* XXX hardcoding int64 */
+    if (!priv->remoteFormat->true_color_flag) {
+        if (priv->remoteFormat->bits_per_pixel == 8)
+            i = 5; /* 8bpp colourmap */
+        else
+            i = 6; /* 16bpp colourmap */
+        VNC_DEBUG("BPP i %d %d", priv->remoteFormat->bits_per_pixel, i);
+    }
+
+    priv->set_pixel_at = vnc_base_framebuffer_set_pixel_at_table[i - 1][j - 1];
+
+    if (priv->perfect_match)
+        priv->fill = vnc_base_framebuffer_fill_fast_table[i - 1];
+    else
+        priv->fill = vnc_base_framebuffer_fill_table[i - 1][j - 1];
+
+    if (priv->perfect_match)
+        priv->blt = vnc_base_framebuffer_blt_fast;
+    else
+        priv->blt = vnc_base_framebuffer_blt_table[i - 1][j - 1];
+
+    priv->rgb24_blt = vnc_base_framebuffer_rgb24_blt_table[i - 1];
+
+    priv->reinitRenderFuncs = FALSE;
 }
 
 
 static void vnc_base_framebuffer_set_pixel_at(VncFramebuffer *iface,
-					      guint8 *src,
-					      guint16 x, guint16 y)
+                                              guint8 *src,
+                                              guint16 x, guint16 y)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	vnc_base_framebuffer_reinit_render_funcs(fb);
+    vnc_base_framebuffer_reinit_render_funcs(fb);
 
-	priv->set_pixel_at(priv, src, x, y);
+    priv->set_pixel_at(priv, src, x, y);
 }
 
 
 static void vnc_base_framebuffer_fill(VncFramebuffer *iface,
-				      guint8 *src,
-				      guint16 x, guint16 y,
-				      guint16 width, guint16 height)
+                                      guint8 *src,
+                                      guint16 x, guint16 y,
+                                      guint16 width, guint16 height)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	vnc_base_framebuffer_reinit_render_funcs(fb);
+    vnc_base_framebuffer_reinit_render_funcs(fb);
 
-	priv->fill(priv, src, x, y, width, height);
+    priv->fill(priv, src, x, y, width, height);
 }
 
 
 static void vnc_base_framebuffer_copyrect(VncFramebuffer *iface,
-					  guint16 srcx, guint16 srcy,
-					  guint16 dstx, guint16 dsty,
-					  guint16 width, guint16 height)
+                                          guint16 srcx, guint16 srcy,
+                                          guint16 dstx, guint16 dsty,
+                                          guint16 width, guint16 height)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
-	guint8 *dst, *src;
-	int rowstride = priv->rowstride;
-	int i;
-
-	vnc_base_framebuffer_reinit_render_funcs(fb);
-
-	if (srcy < dsty) {
-		rowstride = -rowstride;
-		srcy += (height - 1);
-		dsty += (height - 1);
-	}
-
-	dst = VNC_BASE_FRAMEBUFFER_AT(priv, dstx, dsty);
-	src = VNC_BASE_FRAMEBUFFER_AT(priv, srcx, srcy);
-	for (i = 0; i < height; i++) {
-		memmove(dst, src, width * (priv->localFormat->bits_per_pixel  / 8));
-		dst += rowstride;
-		src += rowstride;
-	}
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
+    guint8 *dst, *src;
+    int rowstride = priv->rowstride;
+    int i;
+
+    vnc_base_framebuffer_reinit_render_funcs(fb);
+
+    if (srcy < dsty) {
+        rowstride = -rowstride;
+        srcy += (height - 1);
+        dsty += (height - 1);
+    }
+
+    dst = VNC_BASE_FRAMEBUFFER_AT(priv, dstx, dsty);
+    src = VNC_BASE_FRAMEBUFFER_AT(priv, srcx, srcy);
+    for (i = 0; i < height; i++) {
+        memmove(dst, src, width * (priv->localFormat->bits_per_pixel  / 8));
+        dst += rowstride;
+        src += rowstride;
+    }
 }
 
 
 static void vnc_base_framebuffer_blt(VncFramebuffer *iface,
-				     guint8 *src,
-				     int rowstride,
-				     guint16 x, guint16 y,
-				     guint16 width, guint16 height)
+                                     guint8 *src,
+                                     int rowstride,
+                                     guint16 x, guint16 y,
+                                     guint16 width, guint16 height)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	vnc_base_framebuffer_reinit_render_funcs(fb);
+    vnc_base_framebuffer_reinit_render_funcs(fb);
 
-	priv->blt(priv, src, rowstride, x, y, width, height);
+    priv->blt(priv, src, rowstride, x, y, width, height);
 }
 
 
 static void vnc_base_framebuffer_rgb24_blt(VncFramebuffer *iface,
-					   guint8 *src,
-					   int rowstride,
-					   guint16 x, guint16 y,
-					   guint16 width, guint16 height)
+                                           guint8 *src,
+                                           int rowstride,
+                                           guint16 x, guint16 y,
+                                           guint16 width, guint16 height)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	vnc_base_framebuffer_reinit_render_funcs(fb);
+    vnc_base_framebuffer_reinit_render_funcs(fb);
 
-	priv->rgb24_blt(priv, src, rowstride, x, y, width, height);
+    priv->rgb24_blt(priv, src, rowstride, x, y, width, height);
 }
 
 
 static void vnc_base_framebuffer_set_color_map(VncFramebuffer *iface,
-					       VncColorMap *map)
+                                               VncColorMap *map)
 {
-	VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
-	VncBaseFramebufferPrivate *priv = fb->priv;
+    VncBaseFramebuffer *fb = VNC_BASE_FRAMEBUFFER(iface);
+    VncBaseFramebufferPrivate *priv = fb->priv;
 
-	if (priv->colorMap)
-		vnc_color_map_free(priv->colorMap);
-	priv->colorMap = vnc_color_map_copy(map);
+    if (priv->colorMap)
+        vnc_color_map_free(priv->colorMap);
+    priv->colorMap = vnc_color_map_copy(map);
 }
 
 
 static void vnc_base_framebuffer_interface_init(gpointer g_iface,
-						gpointer iface_data G_GNUC_UNUSED)
+                                                gpointer iface_data G_GNUC_UNUSED)
 {
     VncFramebufferInterface *iface = g_iface;
 
@@ -1002,8 +1002,8 @@ static void vnc_base_framebuffer_interface_init(gpointer g_iface,
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncbaseframebuffer.h b/src/vncbaseframebuffer.h
index d86127a..07f0ea3 100644
--- a/src/vncbaseframebuffer.h
+++ b/src/vncbaseframebuffer.h
@@ -43,33 +43,33 @@ typedef struct _VncBaseFramebufferClass VncBaseFramebufferClass;
 
 struct _VncBaseFramebuffer
 {
-	GObject parent;
+    GObject parent;
 
-	VncBaseFramebufferPrivate *priv;
+    VncBaseFramebufferPrivate *priv;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 struct _VncBaseFramebufferClass
 {
-	GObjectClass parent_class;
+    GObjectClass parent_class;
 
-	/*
-	 * If adding fields to this struct, remove corresponding
-	 * amount of padding to avoid changing overall struct size
-	 */
-	gpointer _vnc_reserved[VNC_PADDING];
+    /*
+     * If adding fields to this struct, remove corresponding
+     * amount of padding to avoid changing overall struct size
+     */
+    gpointer _vnc_reserved[VNC_PADDING];
 };
 
 
 GType vnc_base_framebuffer_get_type(void) G_GNUC_CONST;
 
 VncBaseFramebuffer *vnc_base_framebuffer_new(guint8 *buffer,
-					     guint16 width,
-					     guint16 height,
-					     int rowstride,
-					     const VncPixelFormat *localFormat,
-					     const VncPixelFormat *remoteFormat);
+                                             guint16 width,
+                                             guint16 height,
+                                             int rowstride,
+                                             const VncPixelFormat *localFormat,
+                                             const VncPixelFormat *remoteFormat);
 
 
 
@@ -79,8 +79,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncbaseframebufferblt.h b/src/vncbaseframebufferblt.h
index 0a7a1c8..92d4a19 100644
--- a/src/vncbaseframebufferblt.h
+++ b/src/vncbaseframebufferblt.h
@@ -50,148 +50,148 @@
 #include <stdio.h>
 #ifdef COLORMAP
 static void SET_PIXEL(VncBaseFramebufferPrivate *priv,
-		      dst_pixel_t *dp, src_pixel_t spidx)
+                      dst_pixel_t *dp, src_pixel_t spidx)
 {
-	guint64 sp;
-	guint16 red = 0;
-	guint16 green = 0;
-	guint16 blue = 0;
-	vnc_color_map_lookup(priv->colorMap,
-			     spidx,
-			     &red, &green, &blue);
-	sp = ((guint64)red << 32) | ((guint64)green << 16) | (guint64)blue;
-	*dp = SWAP_IMG(priv, priv->alpha_mask
-		       | ((sp >> priv->rrs) & priv->rm) << priv->rls
-		       | ((sp >> priv->grs) & priv->gm) << priv->gls
-		       | ((sp >> priv->brs) & priv->bm) << priv->bls);
+    guint64 sp;
+    guint16 red = 0;
+    guint16 green = 0;
+    guint16 blue = 0;
+    vnc_color_map_lookup(priv->colorMap,
+                         spidx,
+                         &red, &green, &blue);
+    sp = ((guint64)red << 32) | ((guint64)green << 16) | (guint64)blue;
+    *dp = SWAP_IMG(priv, priv->alpha_mask
+                   | ((sp >> priv->rrs) & priv->rm) << priv->rls
+                   | ((sp >> priv->grs) & priv->gm) << priv->gls
+                   | ((sp >> priv->brs) & priv->bm) << priv->bls);
 }
 #else
 static void SET_PIXEL(VncBaseFramebufferPrivate *priv,
-		      dst_pixel_t *dp, src_pixel_t sp)
+                      dst_pixel_t *dp, src_pixel_t sp)
 {
-	*dp = SWAP_IMG(priv, priv->alpha_mask
-		       | ((sp >> priv->rrs) & priv->rm) << priv->rls
-		       | ((sp >> priv->grs) & priv->gm) << priv->gls
-		       | ((sp >> priv->brs) & priv->bm) << priv->bls);
+    *dp = SWAP_IMG(priv, priv->alpha_mask
+                   | ((sp >> priv->rrs) & priv->rm) << priv->rls
+                   | ((sp >> priv->grs) & priv->gm) << priv->gls
+                   | ((sp >> priv->brs) & priv->bm) << priv->bls);
 }
 #endif
 
 static void SET_PIXEL_AT(VncBaseFramebufferPrivate *priv,
-			 src_pixel_t *sp,
-			 guint16 x, guint16 y)
+                         src_pixel_t *sp,
+                         guint16 x, guint16 y)
 {
-	dst_pixel_t *dp = (dst_pixel_t *)VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
+    dst_pixel_t *dp = (dst_pixel_t *)VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
 
-	SET_PIXEL(priv, dp, SWAP_RFB(priv, *sp));
+    SET_PIXEL(priv, dp, SWAP_RFB(priv, *sp));
 }
 
 
 #if SRC == DST
 #ifndef COLORMAP
 static void FAST_FILL(VncBaseFramebufferPrivate *priv,
-		      src_pixel_t *sp,
-		      guint16 x, guint16 y,
-		      guint16 width, guint16 height)
+                      src_pixel_t *sp,
+                      guint16 x, guint16 y,
+                      guint16 width, guint16 height)
 {
-	guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
-	int i;
-
-	for (i = 0; i < 1; i++) {
-		int j;
-		dst_pixel_t *dp = (dst_pixel_t *)dst;
-
-		for (j = 0; j < width; j++) {
-			*dp = *sp;
-			dp++;
-		}
-		dst += priv->rowstride;
-	}
-	for (i = 1; i < height; i++) {
-		memcpy(dst, dst - priv->rowstride, width * sizeof(*sp));
-		dst += priv->rowstride;
-	}
+    guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
+    int i;
+
+    for (i = 0; i < 1; i++) {
+        int j;
+        dst_pixel_t *dp = (dst_pixel_t *)dst;
+
+        for (j = 0; j < width; j++) {
+            *dp = *sp;
+            dp++;
+        }
+        dst += priv->rowstride;
+    }
+    for (i = 1; i < height; i++) {
+        memcpy(dst, dst - priv->rowstride, width * sizeof(*sp));
+        dst += priv->rowstride;
+    }
 }
 #endif
 #endif
 
 
 static void FILL(VncBaseFramebufferPrivate *priv,
-		 src_pixel_t *sp,
-		 guint16 x, guint16 y,
-		 guint16 width, guint16 height)
+                 src_pixel_t *sp,
+                 guint16 x, guint16 y,
+                 guint16 width, guint16 height)
 {
-	guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
-	int i;
-
-	for (i = 0; i < 1; i++) {
-		dst_pixel_t *dp = (dst_pixel_t *)dst;
-		int j;
-
-		for (j = 0; j < width; j++) {
-			SET_PIXEL(priv, dp, SWAP_RFB(priv, *sp));
-			dp++;
-		}
-		dst += priv->rowstride;
-	}
-	for (i = 1; i < height; i++) {
-		memcpy(dst, dst - priv->rowstride, width * sizeof(dst_pixel_t));
-		dst += priv->rowstride;
-	}
+    guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
+    int i;
+
+    for (i = 0; i < 1; i++) {
+        dst_pixel_t *dp = (dst_pixel_t *)dst;
+        int j;
+
+        for (j = 0; j < width; j++) {
+            SET_PIXEL(priv, dp, SWAP_RFB(priv, *sp));
+            dp++;
+        }
+        dst += priv->rowstride;
+    }
+    for (i = 1; i < height; i++) {
+        memcpy(dst, dst - priv->rowstride, width * sizeof(dst_pixel_t));
+        dst += priv->rowstride;
+    }
 }
 
 static void BLT(VncBaseFramebufferPrivate *priv,
-		guint8 *src, int rowstride,
-		guint16 x, guint16 y,
-		guint16 width, guint16 height)
+                guint8 *src, int rowstride,
+                guint16 x, guint16 y,
+                guint16 width, guint16 height)
 {
-	guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
-	int i;
-
-	for (i = 0; i < height; i++) {
-		dst_pixel_t *dp = (dst_pixel_t *)dst;
-		src_pixel_t *sp = (src_pixel_t *)src;
-		int j;
-
-		for (j = 0; j < width; j++) {
-			SET_PIXEL(priv, dp, SWAP_RFB(priv, *sp));
-			dp++;
-			sp++;
-		}
-		dst += priv->rowstride;
-		src += rowstride;
-	}
+    guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
+    int i;
+
+    for (i = 0; i < height; i++) {
+        dst_pixel_t *dp = (dst_pixel_t *)dst;
+        src_pixel_t *sp = (src_pixel_t *)src;
+        int j;
+
+        for (j = 0; j < width; j++) {
+            SET_PIXEL(priv, dp, SWAP_RFB(priv, *sp));
+            dp++;
+            sp++;
+        }
+        dst += priv->rowstride;
+        src += rowstride;
+    }
 }
 
 
 #if SRC == 32
 static void RGB24_BLT(VncBaseFramebufferPrivate *priv,
-		      guint8 *src, int rowstride,
-		      guint16 x, gint16 y,
-		      guint16 width, guint16 height)
+                      guint8 *src, int rowstride,
+                      guint16 x, gint16 y,
+                      guint16 width, guint16 height)
 {
-	guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
-	int i, j;
-
-	for (j = 0; j < height; j++) {
-		dst_pixel_t *dp = (dst_pixel_t *)dst;
-		guint8 *sp = src;
-
-		for (i = 0; i < width; i++) {
-			/*
-			 * We use priv->remoteFormat->XXX_shift instead of usual priv->Xls
-			 * because the source pixel component is a full 8 bits in
-			 * size, and so doesn't need the adjusted shift
-			 */
-			*dp = (((sp[0] * priv->remoteFormat->red_max) / 255) << priv->remoteFormat->red_shift) |
-				(((sp[1] * priv->remoteFormat->green_max) / 255) << priv->remoteFormat->green_shift) |
-				(((sp[2] * priv->remoteFormat->blue_max) / 255) << priv->remoteFormat->blue_shift);
-			dp++;
-			sp += 3;
-		}
-
-		dst += priv->rowstride;
-		src += rowstride;
-	}
+    guint8 *dst = VNC_BASE_FRAMEBUFFER_AT(priv, x, y);
+    int i, j;
+
+    for (j = 0; j < height; j++) {
+        dst_pixel_t *dp = (dst_pixel_t *)dst;
+        guint8 *sp = src;
+
+        for (i = 0; i < width; i++) {
+            /*
+             * We use priv->remoteFormat->XXX_shift instead of usual priv->Xls
+             * because the source pixel component is a full 8 bits in
+             * size, and so doesn't need the adjusted shift
+             */
+            *dp = (((sp[0] * priv->remoteFormat->red_max) / 255) << priv->remoteFormat->red_shift) |
+                (((sp[1] * priv->remoteFormat->green_max) / 255) << priv->remoteFormat->green_shift) |
+                (((sp[2] * priv->remoteFormat->blue_max) / 255) << priv->remoteFormat->blue_shift);
+            dp++;
+            sp += 3;
+        }
+
+        dst += priv->rowstride;
+        src += rowstride;
+    }
 }
 #endif
 
@@ -216,8 +216,8 @@ static void RGB24_BLT(VncBaseFramebufferPrivate *priv,
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vnccairoframebuffer.c b/src/vnccairoframebuffer.c
index 48e2f2a..ae61ded 100644
--- a/src/vnccairoframebuffer.c
+++ b/src/vnccairoframebuffer.c
@@ -27,11 +27,11 @@
 #include "vnccairoframebuffer.h"
 #include "vncutil.h"
 
-#define VNC_CAIRO_FRAMEBUFFER_GET_PRIVATE(obj)				\
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_CAIRO_FRAMEBUFFER, VncCairoFramebufferPrivate))
+#define VNC_CAIRO_FRAMEBUFFER_GET_PRIVATE(obj)                          \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_CAIRO_FRAMEBUFFER, VncCairoFramebufferPrivate))
 
 struct _VncCairoFramebufferPrivate {
-	cairo_surface_t *surface;
+    cairo_surface_t *surface;
 };
 
 
@@ -39,140 +39,140 @@ G_DEFINE_TYPE(VncCairoFramebuffer, vnc_cairo_framebuffer, VNC_TYPE_BASE_FRAMEBUF
 
 
 enum {
-	PROP_0,
-	PROP_SURFACE,
+    PROP_0,
+    PROP_SURFACE,
 };
 
 
 static void vnc_cairo_framebuffer_get_property(GObject *object,
-					       guint prop_id,
-					       GValue *value,
-					       GParamSpec *pspec)
+                                               guint prop_id,
+                                               GValue *value,
+                                               GParamSpec *pspec)
 {
-	VncCairoFramebuffer *framebuffer = VNC_CAIRO_FRAMEBUFFER(object);
-	VncCairoFramebufferPrivate *priv = framebuffer->priv;
+    VncCairoFramebuffer *framebuffer = VNC_CAIRO_FRAMEBUFFER(object);
+    VncCairoFramebufferPrivate *priv = framebuffer->priv;
 
-	switch (prop_id) {
-	case PROP_SURFACE:
-		g_value_set_pointer(value, priv->surface);
-		break;
+    switch (prop_id) {
+    case PROP_SURFACE:
+        g_value_set_pointer(value, priv->surface);
+        break;
 
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-	}
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 static void vnc_cairo_framebuffer_set_property(GObject *object,
-					       guint prop_id,
-					       const GValue *value,
-					       GParamSpec *pspec)
+                                               guint prop_id,
+                                               const GValue *value,
+                                               GParamSpec *pspec)
 {
-	VncCairoFramebuffer *framebuffer = VNC_CAIRO_FRAMEBUFFER(object);
-	VncCairoFramebufferPrivate *priv = framebuffer->priv;
+    VncCairoFramebuffer *framebuffer = VNC_CAIRO_FRAMEBUFFER(object);
+    VncCairoFramebufferPrivate *priv = framebuffer->priv;
 
-	switch (prop_id) {
-	case PROP_SURFACE:
-		priv->surface = g_value_get_pointer(value);
-		break;
+    switch (prop_id) {
+    case PROP_SURFACE:
+        priv->surface = g_value_get_pointer(value);
+        break;
 
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-	}
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 static void vnc_cairo_framebuffer_finalize (GObject *object)
 {
-	VncCairoFramebuffer *fb = VNC_CAIRO_FRAMEBUFFER(object);
-	VncCairoFramebufferPrivate *priv = fb->priv;
+    VncCairoFramebuffer *fb = VNC_CAIRO_FRAMEBUFFER(object);
+    VncCairoFramebufferPrivate *priv = fb->priv;
 
-	if (priv->surface)
-		cairo_surface_destroy(priv->surface);
+    if (priv->surface)
+        cairo_surface_destroy(priv->surface);
 
-	G_OBJECT_CLASS(vnc_cairo_framebuffer_parent_class)->finalize (object);
+    G_OBJECT_CLASS(vnc_cairo_framebuffer_parent_class)->finalize (object);
 }
 
 static void vnc_cairo_framebuffer_class_init(VncCairoFramebufferClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = vnc_cairo_framebuffer_finalize;
-	object_class->get_property = vnc_cairo_framebuffer_get_property;
-	object_class->set_property = vnc_cairo_framebuffer_set_property;
-
-	g_object_class_install_property(object_class,
-					PROP_SURFACE,
-					g_param_spec_pointer("surface",
-							     "The cairo surface",
-							     "The cairo surface for the framebuffer",
-							     G_PARAM_READABLE |
-							     G_PARAM_WRITABLE |
-							     G_PARAM_CONSTRUCT_ONLY |
-							     G_PARAM_STATIC_NAME |
-							     G_PARAM_STATIC_NICK |
-							     G_PARAM_STATIC_BLURB));
-
-	g_type_class_add_private(klass, sizeof(VncCairoFramebufferPrivate));
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = vnc_cairo_framebuffer_finalize;
+    object_class->get_property = vnc_cairo_framebuffer_get_property;
+    object_class->set_property = vnc_cairo_framebuffer_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_SURFACE,
+                                    g_param_spec_pointer("surface",
+                                                         "The cairo surface",
+                                                         "The cairo surface for the framebuffer",
+                                                         G_PARAM_READABLE |
+                                                         G_PARAM_WRITABLE |
+                                                         G_PARAM_CONSTRUCT_ONLY |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+
+    g_type_class_add_private(klass, sizeof(VncCairoFramebufferPrivate));
 }
 
 
 void vnc_cairo_framebuffer_init(VncCairoFramebuffer *fb)
 {
-	VncCairoFramebufferPrivate *priv;
+    VncCairoFramebufferPrivate *priv;
 
-	priv = fb->priv = VNC_CAIRO_FRAMEBUFFER_GET_PRIVATE(fb);
+    priv = fb->priv = VNC_CAIRO_FRAMEBUFFER_GET_PRIVATE(fb);
 
-	memset(priv, 0, sizeof(*priv));
+    memset(priv, 0, sizeof(*priv));
 }
 
 
 VncCairoFramebuffer *vnc_cairo_framebuffer_new(guint16 width, guint16 height,
-					       const VncPixelFormat *remoteFormat)
+                                               const VncPixelFormat *remoteFormat)
 {
-	VncPixelFormat localFormat;
-	cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
-	guint8 *pixels;
-
-	VNC_DEBUG("Surface %dx%d", width, height);
-
-	localFormat.red_max = 255;
-	localFormat.green_max = 255;
-	localFormat.blue_max = 255;
-	localFormat.red_shift = 16;
-	localFormat.green_shift = 8;
-	localFormat.blue_shift = 0;
-	localFormat.depth = 32;
-	localFormat.bits_per_pixel = 32;
-	/* XXX is cairo native endian ? */
-	localFormat.byte_order = G_LITTLE_ENDIAN;
-
-	pixels = cairo_image_surface_get_data(surface);
-
-	memset(pixels, 0, width * height * 4);
-
-	return VNC_CAIRO_FRAMEBUFFER(g_object_new(VNC_TYPE_CAIRO_FRAMEBUFFER,
-						  "surface", surface,
-						  "buffer", pixels,
-						  "width", width,
-						  "height", height,
-						  "rowstride", cairo_image_surface_get_stride(surface),
-						  "local-format", &localFormat,
-						  "remote-format", remoteFormat,
-						  NULL));
+    VncPixelFormat localFormat;
+    cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
+    guint8 *pixels;
+
+    VNC_DEBUG("Surface %dx%d", width, height);
+
+    localFormat.red_max = 255;
+    localFormat.green_max = 255;
+    localFormat.blue_max = 255;
+    localFormat.red_shift = 16;
+    localFormat.green_shift = 8;
+    localFormat.blue_shift = 0;
+    localFormat.depth = 32;
+    localFormat.bits_per_pixel = 32;
+    /* XXX is cairo native endian ? */
+    localFormat.byte_order = G_LITTLE_ENDIAN;
+
+    pixels = cairo_image_surface_get_data(surface);
+
+    memset(pixels, 0, width * height * 4);
+
+    return VNC_CAIRO_FRAMEBUFFER(g_object_new(VNC_TYPE_CAIRO_FRAMEBUFFER,
+                                              "surface", surface,
+                                              "buffer", pixels,
+                                              "width", width,
+                                              "height", height,
+                                              "rowstride", cairo_image_surface_get_stride(surface),
+                                              "local-format", &localFormat,
+                                              "remote-format", remoteFormat,
+                                              NULL));
 }
 
 
 cairo_surface_t *vnc_cairo_framebuffer_get_surface(VncCairoFramebuffer *fb)
 {
-	VncCairoFramebufferPrivate *priv = fb->priv;
+    VncCairoFramebufferPrivate *priv = fb->priv;
 
-	return priv->surface;
+    return priv->surface;
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vnccairoframebuffer.h b/src/vnccairoframebuffer.h
index 5d4d675..94b05db 100644
--- a/src/vnccairoframebuffer.h
+++ b/src/vnccairoframebuffer.h
@@ -43,29 +43,29 @@ typedef struct _VncCairoFramebufferClass VncCairoFramebufferClass;
 
 struct _VncCairoFramebuffer
 {
-	VncBaseFramebuffer parent;
+    VncBaseFramebuffer parent;
 
-	VncCairoFramebufferPrivate *priv;
+    VncCairoFramebufferPrivate *priv;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 struct _VncCairoFramebufferClass
 {
-	VncBaseFramebufferClass parent_class;
+    VncBaseFramebufferClass parent_class;
 
-	/*
-	 * If adding fields to this struct, remove corresponding
-	 * amount of padding to avoid changing overall struct size
-	 */
-	gpointer _vnc_reserved[VNC_PADDING];
+    /*
+     * If adding fields to this struct, remove corresponding
+     * amount of padding to avoid changing overall struct size
+     */
+    gpointer _vnc_reserved[VNC_PADDING];
 };
 
 
 GType vnc_cairo_framebuffer_get_type(void) G_GNUC_CONST;
 
 VncCairoFramebuffer *vnc_cairo_framebuffer_new(guint16 width, guint16 height,
-					       const VncPixelFormat *remoteFormat);
+                                               const VncPixelFormat *remoteFormat);
 
 cairo_surface_t *vnc_cairo_framebuffer_get_surface(VncCairoFramebuffer *fb);
 
@@ -76,8 +76,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vnccolormap.c b/src/vnccolormap.c
index 99f6894..222e9e0 100644
--- a/src/vnccolormap.c
+++ b/src/vnccolormap.c
@@ -26,88 +26,88 @@
 
 GType vnc_color_map_get_type(void)
 {
-	static GType color_map_type = 0;
+    static GType color_map_type = 0;
 
-	if (G_UNLIKELY(color_map_type == 0)) {
-		color_map_type = g_boxed_type_register_static
-			("VncColorMap",
-			 (GBoxedCopyFunc)vnc_color_map_copy,
-			 (GBoxedFreeFunc)vnc_color_map_free);
-	}
+    if (G_UNLIKELY(color_map_type == 0)) {
+        color_map_type = g_boxed_type_register_static
+            ("VncColorMap",
+             (GBoxedCopyFunc)vnc_color_map_copy,
+             (GBoxedFreeFunc)vnc_color_map_free);
+    }
 
-	return color_map_type;
+    return color_map_type;
 }
 
 
 VncColorMap *vnc_color_map_new(guint16 offset, guint16 size)
 {
-	VncColorMap *map;
+    VncColorMap *map;
 
-	map = g_slice_new0(VncColorMap);
-	map->offset = offset;
-	map->size = size;
-	map->colors = g_new0(VncColorMapEntry, size);
+    map = g_slice_new0(VncColorMap);
+    map->offset = offset;
+    map->size = size;
+    map->colors = g_new0(VncColorMapEntry, size);
 
-	return map;
+    return map;
 }
 
 
 VncColorMap *vnc_color_map_copy(VncColorMap *srcMap)
 {
-	VncColorMap *map;
+    VncColorMap *map;
 
-	map = g_slice_dup(VncColorMap, srcMap);
-	map->colors = g_new0(VncColorMapEntry, srcMap->size);
-	memcpy(map->colors, srcMap->colors,
-	       sizeof(VncColorMapEntry) * map->size);
+    map = g_slice_dup(VncColorMap, srcMap);
+    map->colors = g_new0(VncColorMapEntry, srcMap->size);
+    memcpy(map->colors, srcMap->colors,
+           sizeof(VncColorMapEntry) * map->size);
 
-	return map;
+    return map;
 }
 
 
 void vnc_color_map_free(VncColorMap *map)
 {
-	g_slice_free(VncColorMap, map);
+    g_slice_free(VncColorMap, map);
 }
 
 
 gboolean vnc_color_map_set(VncColorMap *map,
-			   guint16 idx,
-			   guint16 red,
-			   guint16 green,
-			   guint16 blue)
+                           guint16 idx,
+                           guint16 red,
+                           guint16 green,
+                           guint16 blue)
 {
-	if (idx >= (map->size + map->offset))
-		return FALSE;
+    if (idx >= (map->size + map->offset))
+        return FALSE;
 
-	map->colors[idx - map->offset].red = red;
-	map->colors[idx - map->offset].green = green;
-	map->colors[idx - map->offset].blue = blue;
+    map->colors[idx - map->offset].red = red;
+    map->colors[idx - map->offset].green = green;
+    map->colors[idx - map->offset].blue = blue;
 
-	return TRUE;
+    return TRUE;
 }
 
 
 gboolean vnc_color_map_lookup(VncColorMap *map,
-			      guint16 idx,
-			      guint16 *red,
-			      guint16 *green,
-			      guint16 *blue)
+                              guint16 idx,
+                              guint16 *red,
+                              guint16 *green,
+                              guint16 *blue)
 {
-	if (idx >= (map->size + map->offset))
-		return FALSE;
+    if (idx >= (map->size + map->offset))
+        return FALSE;
 
-	*red = map->colors[idx - map->offset].red;
-	*green = map->colors[idx - map->offset].green;
-	*blue = map->colors[idx - map->offset].blue;
+    *red = map->colors[idx - map->offset].red;
+    *green = map->colors[idx - map->offset].green;
+    *blue = map->colors[idx - map->offset].blue;
 
-	return TRUE;
+    return TRUE;
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vnccolormap.h b/src/vnccolormap.h
index debbf97..3bbe77a 100644
--- a/src/vnccolormap.h
+++ b/src/vnccolormap.h
@@ -33,19 +33,19 @@ typedef struct _VncColorMap VncColorMap;
 typedef struct _VncColorMapEntry VncColorMapEntry;
 
 struct _VncColorMap {
-	guint16 offset;
-	guint16 size;
-	VncColorMapEntry *colors;
+    guint16 offset;
+    guint16 size;
+    VncColorMapEntry *colors;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 struct _VncColorMapEntry {
-	guint16 red;
-	guint16 green;
-	guint16 blue;
+    guint16 red;
+    guint16 green;
+    guint16 blue;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 
@@ -56,16 +56,16 @@ VncColorMap *vnc_color_map_copy(VncColorMap *map);
 void vnc_color_map_free(VncColorMap *map);
 
 gboolean vnc_color_map_set(VncColorMap *map,
-			   guint16 idx,
-			   guint16 red,
-			   guint16 green,
-			   guint16 blue);
+                           guint16 idx,
+                           guint16 red,
+                           guint16 green,
+                           guint16 blue);
 
 gboolean vnc_color_map_lookup(VncColorMap *map,
-			      guint16 idx,
-			      guint16 *red,
-			      guint16 *green,
-			      guint16 *blue);
+                              guint16 idx,
+                              guint16 *red,
+                              guint16 *green,
+                              guint16 *blue);
 
 
 G_END_DECLS
@@ -74,8 +74,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncconnection.c b/src/vncconnection.c
index ebfcc27..0addf82 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -58,17 +58,17 @@
 
 struct wait_queue
 {
-	gboolean waiting;
-	struct coroutine *context;
+    gboolean waiting;
+    struct coroutine *context;
 };
 
 
 typedef void vnc_connection_rich_cursor_blt_func(VncConnection *conn, guint8 *, guint8 *,
-						  guint8 *, int, guint16, guint16);
+                                                 guint8 *, int, guint16, guint16);
 
 typedef void vnc_connection_tight_compute_predicted_func(VncConnection *conn, guint8 *,
-							  guint8 *, guint8 *,
-							  guint8 *);
+                                                         guint8 *, guint8 *,
+                                                         guint8 *);
 
 typedef void vnc_connection_tight_sum_pixel_func(VncConnection *conn, guint8 *, guint8 *);
 static void vnc_connection_close(VncConnection *conn);
@@ -86,198 +86,198 @@ typedef gboolean (*g_condition_wait_func)(gpointer);
 
 struct g_condition_wait_source
 {
-        GSource src;
-        struct coroutine *co;
-	g_condition_wait_func func;
-	gpointer data;
+    GSource src;
+    struct coroutine *co;
+    g_condition_wait_func func;
+    gpointer data;
 };
 
-#define VNC_CONNECTION_GET_PRIVATE(obj)				\
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_CONNECTION, VncConnectionPrivate))
+#define VNC_CONNECTION_GET_PRIVATE(obj)                                 \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_CONNECTION, VncConnectionPrivate))
 
 
 struct _VncConnectionPrivate
 {
-	struct coroutine coroutine;
-	guint open_id;
-	GSocket *sock;
-	int fd;
-	char *host;
-	char *port;
-	VncPixelFormat fmt;
-	gboolean has_error;
-	int width;
-	int height;
-	char *name;
-
-	int major;
-	int minor;
-	gnutls_session_t tls_session;
-
-	/* Auth related params */
-	unsigned int auth_type;
-	unsigned int auth_subtype;
-	char *cred_username;
-	char *cred_password;
-	char *cred_x509_cacert;
-	char *cred_x509_cacrl;
-	char *cred_x509_cert;
-	char *cred_x509_key;
-	gboolean want_cred_username;
-	gboolean want_cred_password;
-	gboolean want_cred_x509;
+    struct coroutine coroutine;
+    guint open_id;
+    GSocket *sock;
+    int fd;
+    char *host;
+    char *port;
+    VncPixelFormat fmt;
+    gboolean has_error;
+    int width;
+    int height;
+    char *name;
+
+    int major;
+    int minor;
+    gnutls_session_t tls_session;
+
+    /* Auth related params */
+    unsigned int auth_type;
+    unsigned int auth_subtype;
+    char *cred_username;
+    char *cred_password;
+    char *cred_x509_cacert;
+    char *cred_x509_cacrl;
+    char *cred_x509_cert;
+    char *cred_x509_key;
+    gboolean want_cred_username;
+    gboolean want_cred_password;
+    gboolean want_cred_x509;
 
 #if HAVE_SASL
-	sasl_conn_t *saslconn;      /* SASL context */
-	const char *saslDecoded;
-	unsigned int saslDecodedLength;
-	unsigned int saslDecodedOffset;
+    sasl_conn_t *saslconn;      /* SASL context */
+    const char *saslDecoded;
+    unsigned int saslDecodedLength;
+    unsigned int saslDecodedOffset;
 #endif
 
-	char read_buffer[4096];
-	size_t read_offset;
-	size_t read_size;
+    char read_buffer[4096];
+    size_t read_offset;
+    size_t read_size;
 
-	char write_buffer[4096];
-	size_t write_offset;
+    char write_buffer[4096];
+    size_t write_offset;
 
-	VncFramebuffer *fb;
-	gboolean fbSwapRemote;
+    VncFramebuffer *fb;
+    gboolean fbSwapRemote;
 
-	VncCursor *cursor;
-	gboolean absPointer;
-	gboolean sharedFlag;
+    VncCursor *cursor;
+    gboolean absPointer;
+    gboolean sharedFlag;
 
-	vnc_connection_rich_cursor_blt_func *rich_cursor_blt;
-	vnc_connection_tight_compute_predicted_func *tight_compute_predicted;
-	vnc_connection_tight_sum_pixel_func *tight_sum_pixel;
+    vnc_connection_rich_cursor_blt_func *rich_cursor_blt;
+    vnc_connection_tight_compute_predicted_func *tight_compute_predicted;
+    vnc_connection_tight_sum_pixel_func *tight_sum_pixel;
 
-	int wait_interruptable;
-	struct wait_queue wait;
+    int wait_interruptable;
+    struct wait_queue wait;
 
-	char *xmit_buffer;
-	int xmit_buffer_capacity;
-	int xmit_buffer_size;
+    char *xmit_buffer;
+    int xmit_buffer_capacity;
+    int xmit_buffer_size;
 
-	z_stream *strm;
-	z_stream streams[5];
+    z_stream *strm;
+    z_stream streams[5];
 
-	size_t uncompressed_length;
-	guint8 uncompressed_buffer[4096];
+    size_t uncompressed_length;
+    guint8 uncompressed_buffer[4096];
 
-	size_t compressed_length;
-	guint8 *compressed_buffer;
+    size_t compressed_length;
+    guint8 *compressed_buffer;
 
-	guint8 zrle_pi;
-	int zrle_pi_bits;
+    guint8 zrle_pi;
+    int zrle_pi_bits;
 
-	gboolean has_ext_key_event;
+    gboolean has_ext_key_event;
 
-	struct {
-		gboolean incremental;
-		guint16 x;
-		guint16 y;
-		guint16 width;
-		guint16 height;
-	} lastUpdateRequest;
+    struct {
+        gboolean incremental;
+        guint16 x;
+        guint16 y;
+        guint16 width;
+        guint16 height;
+    } lastUpdateRequest;
 
-	gboolean has_audio;
-	gboolean audio_format_pending;
-	gboolean audio_enable_pending;
-	gboolean audio_disable_pending;
-	VncAudioFormat audio_format;
-	VncAudio *audio;
-	VncAudioSample *audio_sample;
-	guint audio_timer;
+    gboolean has_audio;
+    gboolean audio_format_pending;
+    gboolean audio_enable_pending;
+    gboolean audio_disable_pending;
+    VncAudioFormat audio_format;
+    VncAudio *audio;
+    VncAudioSample *audio_sample;
+    guint audio_timer;
 };
 
 G_DEFINE_TYPE(VncConnection, vnc_connection, G_TYPE_OBJECT);
 
 
 enum {
-	VNC_CURSOR_CHANGED,
-	VNC_POINTER_MODE_CHANGED,
-	VNC_BELL,
-	VNC_SERVER_CUT_TEXT,
-	VNC_FRAMEBUFFER_UPDATE,
-	VNC_DESKTOP_RESIZE,
-	VNC_PIXEL_FORMAT_CHANGED,
-
-	VNC_AUTH_FAILURE,
-	VNC_AUTH_UNSUPPORTED,
-	VNC_AUTH_CREDENTIAL,
-	VNC_AUTH_CHOOSE_TYPE,
-	VNC_AUTH_CHOOSE_SUBTYPE,
-
-	VNC_CONNECTED,
-	VNC_INITIALIZED,
-	VNC_DISCONNECTED,
-
-	VNC_LAST_SIGNAL,
+    VNC_CURSOR_CHANGED,
+    VNC_POINTER_MODE_CHANGED,
+    VNC_BELL,
+    VNC_SERVER_CUT_TEXT,
+    VNC_FRAMEBUFFER_UPDATE,
+    VNC_DESKTOP_RESIZE,
+    VNC_PIXEL_FORMAT_CHANGED,
+
+    VNC_AUTH_FAILURE,
+    VNC_AUTH_UNSUPPORTED,
+    VNC_AUTH_CREDENTIAL,
+    VNC_AUTH_CHOOSE_TYPE,
+    VNC_AUTH_CHOOSE_SUBTYPE,
+
+    VNC_CONNECTED,
+    VNC_INITIALIZED,
+    VNC_DISCONNECTED,
+
+    VNC_LAST_SIGNAL,
 };
 
 static guint signals[VNC_LAST_SIGNAL] = { 0, 0, 0, 0,
-					  0, 0, 0, 0,
-					  0, 0, 0, 0,
-					  0, 0, 0 };
+                                          0, 0, 0, 0,
+                                          0, 0, 0, 0,
+                                          0, 0, 0 };
 
 #define nibhi(a) (((a) >> 4) & 0x0F)
 #define niblo(a) ((a) & 0x0F)
 
 /* Main loop helper functions */
 static gboolean g_io_wait_helper(GSocket *sock G_GNUC_UNUSED,
-				 GIOCondition cond,
-				 gpointer data)
+                                 GIOCondition cond,
+                                 gpointer data)
 {
-	struct coroutine *to = data;
-	coroutine_yieldto(to, &cond);
-	return FALSE;
+    struct coroutine *to = data;
+    coroutine_yieldto(to, &cond);
+    return FALSE;
 }
 
 static GIOCondition g_io_wait(GSocket *sock, GIOCondition cond)
 {
-	GIOCondition *ret;
-	GSource *src = g_socket_create_source(sock,
-					      cond | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-					      NULL);
-	g_source_set_callback(src, (GSourceFunc)g_io_wait_helper, coroutine_self(), NULL);
-	g_source_attach(src, NULL);
-	ret = coroutine_yield(NULL);
-	g_source_unref(src);
-	return *ret;
+    GIOCondition *ret;
+    GSource *src = g_socket_create_source(sock,
+                                          cond | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                                          NULL);
+    g_source_set_callback(src, (GSourceFunc)g_io_wait_helper, coroutine_self(), NULL);
+    g_source_attach(src, NULL);
+    ret = coroutine_yield(NULL);
+    g_source_unref(src);
+    return *ret;
 }
 
 
 static GIOCondition g_io_wait_interruptable(struct wait_queue *wait,
-					    GSocket *sock,
-					    GIOCondition cond)
-{
-	GIOCondition *ret;
-	gint id;
-
-	wait->context = coroutine_self();
-	GSource *src = g_socket_create_source(sock,
-					      cond | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-					      NULL);
-	g_source_set_callback(src, (GSourceFunc)g_io_wait_helper,
-			      wait->context, NULL);
-	id = g_source_attach(src, NULL);
-	wait->waiting = TRUE;
-	ret = coroutine_yield(NULL);
-	g_source_unref(src);
-	wait->waiting = FALSE;
-
-	if (ret == NULL) {
-		g_source_remove(id);
-		return 0;
-	} else
-		return *ret;
+                                            GSocket *sock,
+                                            GIOCondition cond)
+{
+    GIOCondition *ret;
+    gint id;
+
+    wait->context = coroutine_self();
+    GSource *src = g_socket_create_source(sock,
+                                          cond | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                                          NULL);
+    g_source_set_callback(src, (GSourceFunc)g_io_wait_helper,
+                          wait->context, NULL);
+    id = g_source_attach(src, NULL);
+    wait->waiting = TRUE;
+    ret = coroutine_yield(NULL);
+    g_source_unref(src);
+    wait->waiting = FALSE;
+
+    if (ret == NULL) {
+        g_source_remove(id);
+        return 0;
+    } else
+        return *ret;
 }
 
 static void g_io_wakeup(struct wait_queue *wait)
 {
-	if (wait->waiting)
-		coroutine_yieldto(wait->context, NULL);
+    if (wait->waiting)
+        coroutine_yieldto(wait->context, NULL);
 }
 
 
@@ -286,10 +286,10 @@ static void g_io_wakeup(struct wait_queue *wait)
  * true if the condition we're checking is ready for dispatch
  */
 static gboolean g_condition_wait_prepare(GSource *src,
-					 int *timeout) {
-        struct g_condition_wait_source *vsrc = (struct g_condition_wait_source *)src;
-        *timeout = -1;
-        return vsrc->func(vsrc->data);
+                                         int *timeout) {
+    struct g_condition_wait_source *vsrc = (struct g_condition_wait_source *)src;
+    *timeout = -1;
+    return vsrc->func(vsrc->data);
 }
 
 /*
@@ -298,309 +298,309 @@ static gboolean g_condition_wait_prepare(GSource *src,
  */
 static gboolean g_condition_wait_check(GSource *src)
 {
-        struct g_condition_wait_source *vsrc = (struct g_condition_wait_source *)src;
-        return vsrc->func(vsrc->data);
+    struct g_condition_wait_source *vsrc = (struct g_condition_wait_source *)src;
+    return vsrc->func(vsrc->data);
 }
 
 static gboolean g_condition_wait_dispatch(GSource *src G_GNUC_UNUSED,
-					  GSourceFunc cb,
-					  gpointer data) {
-        return cb(data);
+                                          GSourceFunc cb,
+                                          gpointer data) {
+    return cb(data);
 }
 
 GSourceFuncs waitFuncs = {
-        .prepare = g_condition_wait_prepare,
-        .check = g_condition_wait_check,
-        .dispatch = g_condition_wait_dispatch,
+    .prepare = g_condition_wait_prepare,
+    .check = g_condition_wait_check,
+    .dispatch = g_condition_wait_dispatch,
 };
 
 static gboolean g_condition_wait_helper(gpointer data)
 {
-        struct coroutine *co = (struct coroutine *)data;
-        coroutine_yieldto(co, NULL);
-        return FALSE;
+    struct coroutine *co = (struct coroutine *)data;
+    coroutine_yieldto(co, NULL);
+    return FALSE;
 }
 
 static gboolean g_condition_wait(g_condition_wait_func func, gpointer data)
 {
-	GSource *src;
-	struct g_condition_wait_source *vsrc;
+    GSource *src;
+    struct g_condition_wait_source *vsrc;
 
-	/* Short-circuit check in case we've got it ahead of time */
-	if (func(data)) {
-		return TRUE;
-	}
+    /* Short-circuit check in case we've got it ahead of time */
+    if (func(data)) {
+        return TRUE;
+    }
 
-	/*
-	 * Don't have it, so yield to the main loop, checking the condition
-	 * on each iteration of the main loop
-	 */
-	src = g_source_new(&waitFuncs, sizeof(struct g_condition_wait_source));
-	vsrc = (struct g_condition_wait_source *)src;
+    /*
+     * Don't have it, so yield to the main loop, checking the condition
+     * on each iteration of the main loop
+     */
+    src = g_source_new(&waitFuncs, sizeof(struct g_condition_wait_source));
+    vsrc = (struct g_condition_wait_source *)src;
 
-	vsrc->func = func;
-	vsrc->data = data;
-	vsrc->co = coroutine_self();
+    vsrc->func = func;
+    vsrc->data = data;
+    vsrc->co = coroutine_self();
 
-	g_source_attach(src, NULL);
-	g_source_set_callback(src, g_condition_wait_helper, coroutine_self(), NULL);
-	coroutine_yield(NULL);
-	g_source_unref(src);
+    g_source_attach(src, NULL);
+    g_source_set_callback(src, g_condition_wait_helper, coroutine_self(), NULL);
+    coroutine_yield(NULL);
+    g_source_unref(src);
 
-	return TRUE;
+    return TRUE;
 }
 
 
 enum {
-	PROP_0,
-	PROP_FRAMEBUFFER,
+    PROP_0,
+    PROP_FRAMEBUFFER,
 };
 
 
 static void vnc_connection_get_property(GObject *object,
-					guint prop_id,
-					GValue *value,
-					GParamSpec *pspec)
+                                        guint prop_id,
+                                        GValue *value,
+                                        GParamSpec *pspec)
 {
-	VncConnection *conn = VNC_CONNECTION(object);
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnection *conn = VNC_CONNECTION(object);
+    VncConnectionPrivate *priv = conn->priv;
 
-	switch (prop_id) {
-	case PROP_FRAMEBUFFER:
-		g_value_set_object(value, priv->fb);
-		break;
+    switch (prop_id) {
+    case PROP_FRAMEBUFFER:
+        g_value_set_object(value, priv->fb);
+        break;
 
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-	}
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 static void vnc_connection_set_property(GObject *object,
-					guint prop_id,
-					const GValue *value,
-					GParamSpec *pspec)
+                                        guint prop_id,
+                                        const GValue *value,
+                                        GParamSpec *pspec)
 {
-	VncConnection *conn = VNC_CONNECTION(object);
+    VncConnection *conn = VNC_CONNECTION(object);
 
-	switch (prop_id) {
-	case PROP_FRAMEBUFFER:
-		vnc_connection_set_framebuffer(conn, g_value_get_object(value));
-		break;
+    switch (prop_id) {
+    case PROP_FRAMEBUFFER:
+        vnc_connection_set_framebuffer(conn, g_value_get_object(value));
+        break;
 
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-        }
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 struct signal_data
 {
-	VncConnection *conn;
-	struct coroutine *caller;
-
-	int signum;
-
-	union {
-		VncCursor *cursor;
-		gboolean absPointer;
-		const char *text;
-		struct {
-			int x;
-			int y;
-			int width;
-			int height;
-		} area;
-		struct {
-			int width;
-			int height;
-		} size;
-		VncPixelFormat *pixelFormat;
-		const char *authReason;
-		unsigned int authUnsupported;
-		GValueArray *authCred;
-		GValueArray *authTypes;
-	} params;
+    VncConnection *conn;
+    struct coroutine *caller;
+
+    int signum;
+
+    union {
+        VncCursor *cursor;
+        gboolean absPointer;
+        const char *text;
+        struct {
+            int x;
+            int y;
+            int width;
+            int height;
+        } area;
+        struct {
+            int width;
+            int height;
+        } size;
+        VncPixelFormat *pixelFormat;
+        const char *authReason;
+        unsigned int authUnsupported;
+        GValueArray *authCred;
+        GValueArray *authTypes;
+    } params;
 };
 
 static gboolean do_vnc_connection_emit_main_context(gpointer opaque)
 {
-	struct signal_data *data = opaque;
-
-	VNC_DEBUG("Emit main context %d", data->signum);
-	switch (data->signum) {
-	case VNC_CURSOR_CHANGED:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.cursor);
-		break;
-
-	case VNC_POINTER_MODE_CHANGED:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.absPointer);
-		break;
-
-	case VNC_BELL:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0);
-		break;
-
-	case VNC_SERVER_CUT_TEXT:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.text);
-		break;
-
-	case VNC_FRAMEBUFFER_UPDATE:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.area.x,
-			      data->params.area.y,
-			      data->params.area.width,
-			      data->params.area.height);
-		break;
-
-	case VNC_DESKTOP_RESIZE:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.size.width,
-			      data->params.size.height);
-		break;
-
-	case VNC_PIXEL_FORMAT_CHANGED:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.pixelFormat);
-		break;
-
-	case VNC_AUTH_FAILURE:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.authReason);
-		break;
-
-	case VNC_AUTH_UNSUPPORTED:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.authUnsupported);
-		break;
-
-	case VNC_AUTH_CREDENTIAL:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.authCred);
-		break;
-
-	case VNC_AUTH_CHOOSE_TYPE:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->params.authTypes);
-		break;
-
-	case VNC_AUTH_CHOOSE_SUBTYPE:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0,
-			      data->conn->priv->auth_type,
-			      data->params.authTypes);
-		break;
-
-	case VNC_CONNECTED:
-	case VNC_INITIALIZED:
-	case VNC_DISCONNECTED:
-		g_signal_emit(G_OBJECT(data->conn),
-			      signals[data->signum],
-			      0);
-		break;
-	}
-
-	coroutine_yieldto(data->caller, NULL);
-
-	return FALSE;
+    struct signal_data *data = opaque;
+
+    VNC_DEBUG("Emit main context %d", data->signum);
+    switch (data->signum) {
+    case VNC_CURSOR_CHANGED:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.cursor);
+        break;
+
+    case VNC_POINTER_MODE_CHANGED:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.absPointer);
+        break;
+
+    case VNC_BELL:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0);
+        break;
+
+    case VNC_SERVER_CUT_TEXT:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.text);
+        break;
+
+    case VNC_FRAMEBUFFER_UPDATE:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.area.x,
+                      data->params.area.y,
+                      data->params.area.width,
+                      data->params.area.height);
+        break;
+
+    case VNC_DESKTOP_RESIZE:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.size.width,
+                      data->params.size.height);
+        break;
+
+    case VNC_PIXEL_FORMAT_CHANGED:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.pixelFormat);
+        break;
+
+    case VNC_AUTH_FAILURE:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.authReason);
+        break;
+
+    case VNC_AUTH_UNSUPPORTED:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.authUnsupported);
+        break;
+
+    case VNC_AUTH_CREDENTIAL:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.authCred);
+        break;
+
+    case VNC_AUTH_CHOOSE_TYPE:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->params.authTypes);
+        break;
+
+    case VNC_AUTH_CHOOSE_SUBTYPE:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0,
+                      data->conn->priv->auth_type,
+                      data->params.authTypes);
+        break;
+
+    case VNC_CONNECTED:
+    case VNC_INITIALIZED:
+    case VNC_DISCONNECTED:
+        g_signal_emit(G_OBJECT(data->conn),
+                      signals[data->signum],
+                      0);
+        break;
+    }
+
+    coroutine_yieldto(data->caller, NULL);
+
+    return FALSE;
 }
 
 static void vnc_connection_emit_main_context(VncConnection *conn,
-					     int signum,
-					     struct signal_data *data)
+                                             int signum,
+                                             struct signal_data *data)
 {
-	data->conn = conn;
-	data->caller = coroutine_self();
-	data->signum = signum;
+    data->conn = conn;
+    data->caller = coroutine_self();
+    data->signum = signum;
 
-	g_idle_add(do_vnc_connection_emit_main_context, data);
+    g_idle_add(do_vnc_connection_emit_main_context, data);
 
-	/* This switches to the system coroutine context, lets
-	 * the idle function run to dispatch the signal, and
-	 * finally returns once complete. ie this is synchronous
-	 * from the POV of the VNC coroutine despite there being
-	 * an idle function involved
-	 */
-	coroutine_yield(NULL);
+    /* This switches to the system coroutine context, lets
+     * the idle function run to dispatch the signal, and
+     * finally returns once complete. ie this is synchronous
+     * from the POV of the VNC coroutine despite there being
+     * an idle function involved
+     */
+    coroutine_yield(NULL);
 }
 
 
 static gboolean vnc_connection_use_compression(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->compressed_buffer != NULL;
+    return priv->compressed_buffer != NULL;
 }
 
 static int vnc_connection_zread(VncConnection *conn, void *buffer, size_t size)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	char *ptr = buffer;
-	size_t offset = 0;
-
-	while (offset < size) {
-		/* if data is available in the uncompressed buffer, then
-		 * copy */
-		if (priv->uncompressed_length) {
-			size_t len = MIN(priv->uncompressed_length,
-					 size - offset);
-
-			memcpy(ptr + offset,
-			       priv->uncompressed_buffer,
-			       len);
-
-			priv->uncompressed_length -= len;
-			if (priv->uncompressed_length)
-				memmove(priv->uncompressed_buffer,
-					priv->uncompressed_buffer + len,
-					priv->uncompressed_length);
-			offset += len;
-		} else {
-			int err;
-
-			priv->strm->next_in = priv->compressed_buffer;
-			priv->strm->avail_in = priv->compressed_length;
-			priv->strm->next_out = priv->uncompressed_buffer;
-			priv->strm->avail_out = sizeof(priv->uncompressed_buffer);
-
-			/* inflate as much as possible */
-			err = inflate(priv->strm, Z_SYNC_FLUSH);
-			if (err != Z_OK) {
-				errno = EIO;
-				return -1;
-			}
-
-			priv->uncompressed_length = (guint8 *)priv->strm->next_out - priv->uncompressed_buffer;
-			priv->compressed_length -= (guint8 *)priv->strm->next_in - priv->compressed_buffer;
-			priv->compressed_buffer = priv->strm->next_in;
-		}
-	}
-
-	return offset;
+    VncConnectionPrivate *priv = conn->priv;
+    char *ptr = buffer;
+    size_t offset = 0;
+
+    while (offset < size) {
+        /* if data is available in the uncompressed buffer, then
+         * copy */
+        if (priv->uncompressed_length) {
+            size_t len = MIN(priv->uncompressed_length,
+                             size - offset);
+
+            memcpy(ptr + offset,
+                   priv->uncompressed_buffer,
+                   len);
+
+            priv->uncompressed_length -= len;
+            if (priv->uncompressed_length)
+                memmove(priv->uncompressed_buffer,
+                        priv->uncompressed_buffer + len,
+                        priv->uncompressed_length);
+            offset += len;
+        } else {
+            int err;
+
+            priv->strm->next_in = priv->compressed_buffer;
+            priv->strm->avail_in = priv->compressed_length;
+            priv->strm->next_out = priv->uncompressed_buffer;
+            priv->strm->avail_out = sizeof(priv->uncompressed_buffer);
+
+            /* inflate as much as possible */
+            err = inflate(priv->strm, Z_SYNC_FLUSH);
+            if (err != Z_OK) {
+                errno = EIO;
+                return -1;
+            }
+
+            priv->uncompressed_length = (guint8 *)priv->strm->next_out - priv->uncompressed_buffer;
+            priv->compressed_length -= (guint8 *)priv->strm->next_in - priv->compressed_buffer;
+            priv->compressed_buffer = priv->strm->next_in;
+        }
+    }
+
+    return offset;
 }
 
 /* IO functions */
@@ -612,63 +612,63 @@ static int vnc_connection_zread(VncConnection *conn, void *buffer, size_t size)
  */
 static int vnc_connection_read_wire(VncConnection *conn, void *data, size_t len)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int ret;
-	gboolean blocking = FALSE;
+    VncConnectionPrivate *priv = conn->priv;
+    int ret;
+    gboolean blocking = FALSE;
 
  reread:
 
-	if (priv->has_error) return -EINVAL;
-
-	if (priv->tls_session) {
-		ret = gnutls_read(priv->tls_session, data, len);
-		if (ret < 0) {
-			if (ret == GNUTLS_E_AGAIN)
-				blocking = TRUE;
-			ret = -1;
-		}
-	} else {
-		GError *error = NULL;
-		ret = g_socket_receive(priv->sock,
-				       data, len,
-				       NULL, &error);
-		if (ret < 0) {
-			if (error) {
-				if (error->code == G_IO_ERROR_WOULD_BLOCK)
-					blocking = TRUE;
-				g_error_free(error);
-			} else {
-				VNC_DEBUG("Read error %s", error->message);
-			}
-			ret = -1;
-		}
-	}
-
-	if (ret == -1) {
-		if (blocking) {
-			if (priv->wait_interruptable) {
-				if (!g_io_wait_interruptable(&priv->wait,
-							     priv->sock, G_IO_IN)) {
-					//VNC_DEBUG("Read blocking interrupted %d", priv->has_error);
-					return -EAGAIN;
-				}
-			} else {
-				g_io_wait(priv->sock, G_IO_IN);
-			}
-			goto reread;
-		} else {
-			priv->has_error = TRUE;
-			return -errno;
-		}
-	}
-	if (ret == 0) {
-		VNC_DEBUG("Closing the connection: vnc_connection_read() - ret=0");
-		priv->has_error = TRUE;
-		return -EPIPE;
-	}
-	//VNC_DEBUG("Read wire %p %d -> %d", data, len, ret);
-
-	return ret;
+    if (priv->has_error) return -EINVAL;
+
+    if (priv->tls_session) {
+        ret = gnutls_read(priv->tls_session, data, len);
+        if (ret < 0) {
+            if (ret == GNUTLS_E_AGAIN)
+                blocking = TRUE;
+            ret = -1;
+        }
+    } else {
+        GError *error = NULL;
+        ret = g_socket_receive(priv->sock,
+                               data, len,
+                               NULL, &error);
+        if (ret < 0) {
+            if (error) {
+                if (error->code == G_IO_ERROR_WOULD_BLOCK)
+                    blocking = TRUE;
+                g_error_free(error);
+            } else {
+                VNC_DEBUG("Read error %s", error->message);
+            }
+            ret = -1;
+        }
+    }
+
+    if (ret == -1) {
+        if (blocking) {
+            if (priv->wait_interruptable) {
+                if (!g_io_wait_interruptable(&priv->wait,
+                                             priv->sock, G_IO_IN)) {
+                    //VNC_DEBUG("Read blocking interrupted %d", priv->has_error);
+                    return -EAGAIN;
+                }
+            } else {
+                g_io_wait(priv->sock, G_IO_IN);
+            }
+            goto reread;
+        } else {
+            priv->has_error = TRUE;
+            return -errno;
+        }
+    }
+    if (ret == 0) {
+        VNC_DEBUG("Closing the connection: vnc_connection_read() - ret=0");
+        priv->has_error = TRUE;
+        return -EPIPE;
+    }
+    //VNC_DEBUG("Read wire %p %d -> %d", data, len, ret);
+
+    return ret;
 }
 
 
@@ -679,46 +679,46 @@ static int vnc_connection_read_wire(VncConnection *conn, void *data, size_t len)
  */
 static int vnc_connection_read_sasl(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	size_t want;
-
-	//VNC_DEBUG("Read SASL %p size %d offset %d", priv->saslDecoded,
-	//	   priv->saslDecodedLength, priv->saslDecodedOffset);
-	if (priv->saslDecoded == NULL) {
-		char encoded[8192];
-		int encodedLen = sizeof(encoded);
-		int err, ret;
-
-		ret = vnc_connection_read_wire(conn, encoded, encodedLen);
-		if (ret < 0) {
-			return ret;
-		}
-
-		err = sasl_decode(priv->saslconn, encoded, ret,
-				  &priv->saslDecoded, &priv->saslDecodedLength);
-		if (err != SASL_OK) {
-			VNC_DEBUG("Failed to decode SASL data %s",
-				   sasl_errstring(err, NULL, NULL));
-			priv->has_error = TRUE;
-			return -EINVAL;
-		}
-		priv->saslDecodedOffset = 0;
-	}
-
-	want = priv->saslDecodedLength - priv->saslDecodedOffset;
-	if (want > sizeof(priv->read_buffer))
-		want = sizeof(priv->read_buffer);
-
-	memcpy(priv->read_buffer,
-	       priv->saslDecoded + priv->saslDecodedOffset,
-	       want);
-	priv->saslDecodedOffset += want;
-	if (priv->saslDecodedOffset == priv->saslDecodedLength) {
-		priv->saslDecodedLength = priv->saslDecodedOffset = 0;
-		priv->saslDecoded = NULL;
-	}
-	//VNC_DEBUG("Done read write %d - %d", want, priv->has_error);
-	return want;
+    VncConnectionPrivate *priv = conn->priv;
+    size_t want;
+
+    //VNC_DEBUG("Read SASL %p size %d offset %d", priv->saslDecoded,
+    //           priv->saslDecodedLength, priv->saslDecodedOffset);
+    if (priv->saslDecoded == NULL) {
+        char encoded[8192];
+        int encodedLen = sizeof(encoded);
+        int err, ret;
+
+        ret = vnc_connection_read_wire(conn, encoded, encodedLen);
+        if (ret < 0) {
+            return ret;
+        }
+
+        err = sasl_decode(priv->saslconn, encoded, ret,
+                          &priv->saslDecoded, &priv->saslDecodedLength);
+        if (err != SASL_OK) {
+            VNC_DEBUG("Failed to decode SASL data %s",
+                      sasl_errstring(err, NULL, NULL));
+            priv->has_error = TRUE;
+            return -EINVAL;
+        }
+        priv->saslDecodedOffset = 0;
+    }
+
+    want = priv->saslDecodedLength - priv->saslDecodedOffset;
+    if (want > sizeof(priv->read_buffer))
+        want = sizeof(priv->read_buffer);
+
+    memcpy(priv->read_buffer,
+           priv->saslDecoded + priv->saslDecodedOffset,
+           want);
+    priv->saslDecodedOffset += want;
+    if (priv->saslDecodedOffset == priv->saslDecodedLength) {
+        priv->saslDecodedLength = priv->saslDecodedOffset = 0;
+        priv->saslDecoded = NULL;
+    }
+    //VNC_DEBUG("Done read write %d - %d", want, priv->has_error);
+    return want;
 }
 #endif
 
@@ -729,10 +729,10 @@ static int vnc_connection_read_sasl(VncConnection *conn)
  */
 static int vnc_connection_read_plain(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	//VNC_DEBUG("Read plain %d", sizeof(priv->read_buffer));
-	return vnc_connection_read_wire(conn, priv->read_buffer, sizeof(priv->read_buffer));
+    //VNC_DEBUG("Read plain %d", sizeof(priv->read_buffer));
+    return vnc_connection_read_wire(conn, priv->read_buffer, sizeof(priv->read_buffer));
 }
 
 /*
@@ -741,14 +741,14 @@ static int vnc_connection_read_plain(VncConnection *conn)
 static int vnc_connection_read_buf(VncConnection *conn)
 {
 #if HAVE_SASL
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	//VNC_DEBUG("Start read %d", priv->has_error);
-	if (priv->saslconn)
-		return vnc_connection_read_sasl(conn);
-	else
+    //VNC_DEBUG("Start read %d", priv->has_error);
+    if (priv->saslconn)
+        return vnc_connection_read_sasl(conn);
+    else
 #endif
-		return vnc_connection_read_plain(conn);
+        return vnc_connection_read_plain(conn);
 }
 
 /*
@@ -758,44 +758,44 @@ static int vnc_connection_read_buf(VncConnection *conn)
  */
 static int vnc_connection_read(VncConnection *conn, void *data, size_t len)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	char *ptr = data;
-	size_t offset = 0;
-
-	if (priv->has_error) return -EINVAL;
+    VncConnectionPrivate *priv = conn->priv;
+    char *ptr = data;
+    size_t offset = 0;
 
-	while (offset < len) {
-		size_t tmp;
+    if (priv->has_error) return -EINVAL;
 
-		/* compressed data is buffered independently of the read buffer
-		 * so we must by-pass it */
-		if (vnc_connection_use_compression(conn)) {
-			int ret = vnc_connection_zread(conn, ptr + offset, len);
-			if (ret == -1) {
-				VNC_DEBUG("Closing the connection: vnc_connection_read() - zread() failed");
-				priv->has_error = TRUE;
-				return -errno;
-			}
-			offset += ret;
-			continue;
-		} else if (priv->read_offset == priv->read_size) {
-			int ret = vnc_connection_read_buf(conn);
+    while (offset < len) {
+        size_t tmp;
 
-			if (ret < 0)
-				return ret;
-			priv->read_offset = 0;
-			priv->read_size = ret;
-		}
+        /* compressed data is buffered independently of the read buffer
+         * so we must by-pass it */
+        if (vnc_connection_use_compression(conn)) {
+            int ret = vnc_connection_zread(conn, ptr + offset, len);
+            if (ret == -1) {
+                VNC_DEBUG("Closing the connection: vnc_connection_read() - zread() failed");
+                priv->has_error = TRUE;
+                return -errno;
+            }
+            offset += ret;
+            continue;
+        } else if (priv->read_offset == priv->read_size) {
+            int ret = vnc_connection_read_buf(conn);
+
+            if (ret < 0)
+                return ret;
+            priv->read_offset = 0;
+            priv->read_size = ret;
+        }
 
-		tmp = MIN(priv->read_size - priv->read_offset, len - offset);
+        tmp = MIN(priv->read_size - priv->read_offset, len - offset);
 
-		memcpy(ptr + offset, priv->read_buffer + priv->read_offset, tmp);
+        memcpy(ptr + offset, priv->read_buffer + priv->read_offset, tmp);
 
-		priv->read_offset += tmp;
-		offset += tmp;
-	}
+        priv->read_offset += tmp;
+        offset += tmp;
+    }
 
-	return 0;
+    return 0;
 }
 
 /*
@@ -803,59 +803,59 @@ static int vnc_connection_read(VncConnection *conn, void *data, size_t len)
  * the wire
  */
 static void vnc_connection_flush_wire(VncConnection *conn,
-				      const void *data,
-				      size_t datalen)
-{
-	VncConnectionPrivate *priv = conn->priv;
-	const char *ptr = data;
-	size_t offset = 0;
-	//VNC_DEBUG("Flush write %p %d", data, datalen);
-	while (offset < datalen) {
-		int ret;
-		gboolean blocking = FALSE;
-
-		if (priv->has_error) return;
-
-		if (priv->tls_session) {
-			ret = gnutls_write(priv->tls_session,
-					   ptr+offset,
-					   datalen-offset);
-			if (ret < 0) {
-				if (ret == GNUTLS_E_AGAIN)
-					blocking = TRUE;
-				ret = -1;
-			}
-		} else {
-			GError *error = NULL;
-			ret = g_socket_send(priv->sock,
-					    ptr+offset,
-					    datalen-offset,
-					    NULL, &error);
-			if (ret < 0) {
-				if (error) {
-					if (error->code == G_IO_ERROR_WOULD_BLOCK)
-						blocking = TRUE;
-					g_error_free(error);
-				}
-				ret = -1;
-			}
-		}
-		if (ret == -1) {
-			if (blocking) {
-				g_io_wait(priv->sock, G_IO_OUT);
-			} else {
-				VNC_DEBUG("Closing the connection: vnc_connection_flush %d", errno);
-				priv->has_error = TRUE;
-				return;
-			}
-		}
-		if (ret == 0) {
-			VNC_DEBUG("Closing the connection: vnc_connection_flush");
-			priv->has_error = TRUE;
-			return;
-		}
-		offset += ret;
-	}
+                                      const void *data,
+                                      size_t datalen)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    const char *ptr = data;
+    size_t offset = 0;
+    //VNC_DEBUG("Flush write %p %d", data, datalen);
+    while (offset < datalen) {
+        int ret;
+        gboolean blocking = FALSE;
+
+        if (priv->has_error) return;
+
+        if (priv->tls_session) {
+            ret = gnutls_write(priv->tls_session,
+                               ptr+offset,
+                               datalen-offset);
+            if (ret < 0) {
+                if (ret == GNUTLS_E_AGAIN)
+                    blocking = TRUE;
+                ret = -1;
+            }
+        } else {
+            GError *error = NULL;
+            ret = g_socket_send(priv->sock,
+                                ptr+offset,
+                                datalen-offset,
+                                NULL, &error);
+            if (ret < 0) {
+                if (error) {
+                    if (error->code == G_IO_ERROR_WOULD_BLOCK)
+                        blocking = TRUE;
+                    g_error_free(error);
+                }
+                ret = -1;
+            }
+        }
+        if (ret == -1) {
+            if (blocking) {
+                g_io_wait(priv->sock, G_IO_OUT);
+            } else {
+                VNC_DEBUG("Closing the connection: vnc_connection_flush %d", errno);
+                priv->has_error = TRUE;
+                return;
+            }
+        }
+        if (ret == 0) {
+            VNC_DEBUG("Closing the connection: vnc_connection_flush");
+            priv->has_error = TRUE;
+            return;
+        }
+        offset += ret;
+    }
 }
 
 
@@ -866,23 +866,23 @@ static void vnc_connection_flush_wire(VncConnection *conn,
  */
 static void vnc_connection_flush_sasl(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	const char *output;
-	unsigned int outputlen;
-	int err;
-
-	err = sasl_encode(priv->saslconn,
-			  priv->write_buffer,
-			  priv->write_offset,
-			  &output, &outputlen);
-	if (err != SASL_OK) {
-		VNC_DEBUG("Failed to encode SASL data %s",
-			   sasl_errstring(err, NULL, NULL));
-		priv->has_error = TRUE;
-		return;
-	}
-	//VNC_DEBUG("Flush SASL %d: %p %d", priv->write_offset, output, outputlen);
-	vnc_connection_flush_wire(conn, output, outputlen);
+    VncConnectionPrivate *priv = conn->priv;
+    const char *output;
+    unsigned int outputlen;
+    int err;
+
+    err = sasl_encode(priv->saslconn,
+                      priv->write_buffer,
+                      priv->write_offset,
+                      &output, &outputlen);
+    if (err != SASL_OK) {
+        VNC_DEBUG("Failed to encode SASL data %s",
+                  sasl_errstring(err, NULL, NULL));
+        priv->has_error = TRUE;
+        return;
+    }
+    //VNC_DEBUG("Flush SASL %d: %p %d", priv->write_offset, output, outputlen);
+    vnc_connection_flush_wire(conn, output, outputlen);
 }
 #endif
 
@@ -891,12 +891,12 @@ static void vnc_connection_flush_sasl(VncConnection *conn)
  */
 static void vnc_connection_flush_plain(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	//VNC_DEBUG("Flush plain %d", priv->write_offset);
-	vnc_connection_flush_wire(conn,
-				  priv->write_buffer,
-				  priv->write_offset);
+    //VNC_DEBUG("Flush plain %d", priv->write_offset);
+    vnc_connection_flush_wire(conn,
+                              priv->write_buffer,
+                              priv->write_offset);
 }
 
 
@@ -905,16 +905,16 @@ static void vnc_connection_flush_plain(VncConnection *conn)
  */
 static void vnc_connection_flush(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	//VNC_DEBUG("Start flush write %d", priv->has_error);
+    //VNC_DEBUG("Start flush write %d", priv->has_error);
 #if HAVE_SASL
-	if (priv->saslconn)
-		vnc_connection_flush_sasl(conn);
-	else
+    if (priv->saslconn)
+        vnc_connection_flush_sasl(conn);
+    else
 #endif
-		vnc_connection_flush_plain(conn);
-	priv->write_offset = 0;
+        vnc_connection_flush_plain(conn);
+    priv->write_offset = 0;
 }
 
 
@@ -923,89 +923,89 @@ static void vnc_connection_flush(VncConnection *conn)
  */
 static void vnc_connection_write(VncConnection *conn, const void *data, size_t len)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	const char *ptr = data;
-	size_t offset = 0;
+    VncConnectionPrivate *priv = conn->priv;
+    const char *ptr = data;
+    size_t offset = 0;
 
-	while (offset < len) {
-		ssize_t tmp;
+    while (offset < len) {
+        ssize_t tmp;
 
-		if (priv->write_offset == sizeof(priv->write_buffer)) {
-			vnc_connection_flush(conn);
-		}
+        if (priv->write_offset == sizeof(priv->write_buffer)) {
+            vnc_connection_flush(conn);
+        }
 
-		tmp = MIN(sizeof(priv->write_buffer), len - offset);
+        tmp = MIN(sizeof(priv->write_buffer), len - offset);
 
-		memcpy(priv->write_buffer+priv->write_offset, ptr + offset, tmp);
+        memcpy(priv->write_buffer+priv->write_offset, ptr + offset, tmp);
 
-		priv->write_offset += tmp;
-		offset += tmp;
-	}
+        priv->write_offset += tmp;
+        offset += tmp;
+    }
 }
 
 
 static ssize_t vnc_connection_tls_push(gnutls_transport_ptr_t transport,
-				       const void *data,
-				       size_t len) {
-	VncConnection *conn = transport;
-	VncConnectionPrivate *priv = conn->priv;
-	int ret;
-	GError *error = NULL;
-
-	if (!priv->sock) {
-		VNC_DEBUG("Unexpected TLS push on closed socket");
-		errno = EBADF;
-		return -1;
-	}
-
-	ret = g_socket_send(priv->sock, data, len, NULL, &error);
-	if (ret < 0) {
-		if (error) {
-			if (error->code == G_IO_ERROR_WOULD_BLOCK)
-				errno = EAGAIN; /* For gnutls compat */
-			else
-				VNC_DEBUG("Read error %s", error->message);
-			g_error_free(error);
-		}
-		return -1;
-	}
-	return ret;
+                                       const void *data,
+                                       size_t len) {
+    VncConnection *conn = transport;
+    VncConnectionPrivate *priv = conn->priv;
+    int ret;
+    GError *error = NULL;
+
+    if (!priv->sock) {
+        VNC_DEBUG("Unexpected TLS push on closed socket");
+        errno = EBADF;
+        return -1;
+    }
+
+    ret = g_socket_send(priv->sock, data, len, NULL, &error);
+    if (ret < 0) {
+        if (error) {
+            if (error->code == G_IO_ERROR_WOULD_BLOCK)
+                errno = EAGAIN; /* For gnutls compat */
+            else
+                VNC_DEBUG("Read error %s", error->message);
+            g_error_free(error);
+        }
+        return -1;
+    }
+    return ret;
 }
 
 
 static ssize_t vnc_connection_tls_pull(gnutls_transport_ptr_t transport,
-				       void *data,
-				       size_t len) {
-	VncConnection *conn = transport;
-	VncConnectionPrivate *priv = conn->priv;
-	int ret;
-	GError *error = NULL;
-
-	if (!priv->sock) {
-		VNC_DEBUG("Unexpected TLS pull on closed socket");
-		errno = EBADF;
-		return -1;
-	}
-
-	ret = g_socket_receive(priv->sock, data, len, NULL, &error);
-	if (ret < 0) {
-		if (error) {
-			if (error->code == G_IO_ERROR_WOULD_BLOCK)
-				errno = EAGAIN; /* For gnutls compat */
-			else
-				VNC_DEBUG("Read error %s", error->message);
-			g_error_free(error);
-		}
-		return -1;
-	}
-	return ret;
+                                       void *data,
+                                       size_t len) {
+    VncConnection *conn = transport;
+    VncConnectionPrivate *priv = conn->priv;
+    int ret;
+    GError *error = NULL;
+
+    if (!priv->sock) {
+        VNC_DEBUG("Unexpected TLS pull on closed socket");
+        errno = EBADF;
+        return -1;
+    }
+
+    ret = g_socket_receive(priv->sock, data, len, NULL, &error);
+    if (ret < 0) {
+        if (error) {
+            if (error->code == G_IO_ERROR_WOULD_BLOCK)
+                errno = EAGAIN; /* For gnutls compat */
+            else
+                VNC_DEBUG("Read error %s", error->message);
+            g_error_free(error);
+        }
+        return -1;
+    }
+    return ret;
 }
 
 static size_t vnc_connection_pixel_size(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->fmt.bits_per_pixel / 8;
+    return priv->fmt.bits_per_pixel / 8;
 }
 
 /*
@@ -1013,7 +1013,7 @@ static size_t vnc_connection_pixel_size(VncConnection *conn)
  */
 static void vnc_connection_read_pixel(VncConnection *conn, guint8 *pixel)
 {
-	vnc_connection_read(conn, pixel, vnc_connection_pixel_size(conn));
+    vnc_connection_read(conn, pixel, vnc_connection_pixel_size(conn));
 }
 
 /*
@@ -1021,9 +1021,9 @@ static void vnc_connection_read_pixel(VncConnection *conn, guint8 *pixel)
  */
 static guint8 vnc_connection_read_u8(VncConnection *conn)
 {
-	guint8 value = 0;
-	vnc_connection_read(conn, &value, sizeof(value));
-	return value;
+    guint8 value = 0;
+    vnc_connection_read(conn, &value, sizeof(value));
+    return value;
 }
 
 /*
@@ -1031,14 +1031,14 @@ static guint8 vnc_connection_read_u8(VncConnection *conn)
  */
 static int vnc_connection_read_u8_interruptable(VncConnection *conn, guint8 *value)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int ret;
+    VncConnectionPrivate *priv = conn->priv;
+    int ret;
 
-	priv->wait_interruptable = 1;
-	ret = vnc_connection_read(conn, value, sizeof(*value));
-	priv->wait_interruptable = 0;
+    priv->wait_interruptable = 1;
+    ret = vnc_connection_read(conn, value, sizeof(*value));
+    priv->wait_interruptable = 0;
 
-	return ret;
+    return ret;
 }
 
 /*
@@ -1046,9 +1046,9 @@ static int vnc_connection_read_u8_interruptable(VncConnection *conn, guint8 *val
  */
 static guint16 vnc_connection_read_u16(VncConnection *conn)
 {
-	guint16 value = 0;
-	vnc_connection_read(conn, &value, sizeof(value));
-	return g_ntohs(value);
+    guint16 value = 0;
+    vnc_connection_read(conn, &value, sizeof(value));
+    return g_ntohs(value);
 }
 
 /*
@@ -1056,9 +1056,9 @@ static guint16 vnc_connection_read_u16(VncConnection *conn)
  */
 static guint32 vnc_connection_read_u32(VncConnection *conn)
 {
-	guint32 value = 0;
-	vnc_connection_read(conn, &value, sizeof(value));
-	return g_ntohl(value);
+    guint32 value = 0;
+    vnc_connection_read(conn, &value, sizeof(value));
+    return g_ntohl(value);
 }
 
 /*
@@ -1066,9 +1066,9 @@ static guint32 vnc_connection_read_u32(VncConnection *conn)
  */
 static gint32 vnc_connection_read_s32(VncConnection *conn)
 {
-	gint32 value = 0;
-	vnc_connection_read(conn, &value, sizeof(value));
-	return g_ntohl(value);
+    gint32 value = 0;
+    vnc_connection_read(conn, &value, sizeof(value));
+    return g_ntohl(value);
 }
 
 /*
@@ -1076,7 +1076,7 @@ static gint32 vnc_connection_read_s32(VncConnection *conn)
  */
 static void vnc_connection_write_u8(VncConnection *conn, guint8 value)
 {
-	vnc_connection_write(conn, &value, sizeof(value));
+    vnc_connection_write(conn, &value, sizeof(value));
 }
 
 /*
@@ -1084,8 +1084,8 @@ static void vnc_connection_write_u8(VncConnection *conn, guint8 value)
  */
 static void vnc_connection_write_u16(VncConnection *conn, guint16 value)
 {
-	value = g_htons(value);
-	vnc_connection_write(conn, &value, sizeof(value));
+    value = g_htons(value);
+    vnc_connection_write(conn, &value, sizeof(value));
 }
 
 /*
@@ -1093,8 +1093,8 @@ static void vnc_connection_write_u16(VncConnection *conn, guint16 value)
  */
 static void vnc_connection_write_u32(VncConnection *conn, guint32 value)
 {
-	value = g_htonl(value);
-	vnc_connection_write(conn, &value, sizeof(value));
+    value = g_htonl(value);
+    vnc_connection_write(conn, &value, sizeof(value));
 }
 
 #define DH_BITS 1024
@@ -1102,7 +1102,7 @@ static gnutls_dh_params_t dh_params;
 
 #if 0
 static void vnc_connection_debug_gnutls_log(int level, const char* str) {
-	VNC_DEBUG("%d %s", level, str);
+    VNC_DEBUG("%d %s", level, str);
 }
 #endif
 
@@ -1148,252 +1148,252 @@ static struct gcry_thread_cbs gvnc_thread_impl = {
 
 static gboolean vnc_connection_tls_initialize(void)
 {
-	static int tlsinitialized = 0;
+    static int tlsinitialized = 0;
 
-	if (tlsinitialized)
-		return TRUE;
+    if (tlsinitialized)
+        return TRUE;
 
-	if (g_thread_supported()) {
-		gcry_control(GCRYCTL_SET_THREAD_CBS, &gvnc_thread_impl);
-		gcry_check_version(NULL);
-	}
+    if (g_thread_supported()) {
+        gcry_control(GCRYCTL_SET_THREAD_CBS, &gvnc_thread_impl);
+        gcry_check_version(NULL);
+    }
 
-	if (gnutls_global_init () < 0)
-		return FALSE;
+    if (gnutls_global_init () < 0)
+        return FALSE;
 
-	if (gnutls_dh_params_init (&dh_params) < 0)
-		return FALSE;
-	if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0)
-		return FALSE;
+    if (gnutls_dh_params_init (&dh_params) < 0)
+        return FALSE;
+    if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0)
+        return FALSE;
 
 #if 0
-	if (debug_enabled) {
-		gnutls_global_set_log_level(10);
-		gnutls_global_set_log_function(vnc_connection_debug_gnutls_log);
-	}
+    if (debug_enabled) {
+        gnutls_global_set_log_level(10);
+        gnutls_global_set_log_function(vnc_connection_debug_gnutls_log);
+    }
 #endif
 
-	tlsinitialized = TRUE;
+    tlsinitialized = TRUE;
 
-	return TRUE;
+    return TRUE;
 }
 
 static gnutls_anon_client_credentials vnc_connection_tls_initialize_anon_cred(void)
 {
-	gnutls_anon_client_credentials anon_cred;
-	int ret;
+    gnutls_anon_client_credentials anon_cred;
+    int ret;
 
-	if ((ret = gnutls_anon_allocate_client_credentials(&anon_cred)) < 0) {
-		VNC_DEBUG("Cannot allocate credentials %s", gnutls_strerror(ret));
-		return NULL;
-	}
+    if ((ret = gnutls_anon_allocate_client_credentials(&anon_cred)) < 0) {
+        VNC_DEBUG("Cannot allocate credentials %s", gnutls_strerror(ret));
+        return NULL;
+    }
 
-	return anon_cred;
+    return anon_cred;
 }
 
 static gnutls_certificate_credentials_t vnc_connection_tls_initialize_cert_cred(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	gnutls_certificate_credentials_t x509_cred;
-	int ret;
-
-	if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) {
-		VNC_DEBUG("Cannot allocate credentials %s", gnutls_strerror(ret));
-		return NULL;
-	}
-	if (priv->cred_x509_cacert) {
-		if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred,
-								  priv->cred_x509_cacert,
-								  GNUTLS_X509_FMT_PEM)) < 0) {
-			VNC_DEBUG("Cannot load CA certificate %s", gnutls_strerror(ret));
-			return NULL;
-		}
-	} else {
-		VNC_DEBUG("No CA certificate provided");
-		return NULL;
-	}
-
-	if (priv->cred_x509_cert && priv->cred_x509_key) {
-		if ((ret = gnutls_certificate_set_x509_key_file (x509_cred,
-								 priv->cred_x509_cert,
-								 priv->cred_x509_key,
-								 GNUTLS_X509_FMT_PEM)) < 0) {
-			VNC_DEBUG("Cannot load certificate & key %s", gnutls_strerror(ret));
-			return NULL;
-		}
-	} else {
-		VNC_DEBUG("No client cert or key provided");
-	}
-
-	if (priv->cred_x509_cacrl) {
-		if ((ret = gnutls_certificate_set_x509_crl_file(x509_cred,
-								priv->cred_x509_cacrl,
-								GNUTLS_X509_FMT_PEM)) < 0) {
-			VNC_DEBUG("Cannot load CRL %s", gnutls_strerror(ret));
-			return NULL;
-		}
-	} else {
-		VNC_DEBUG("No CA revocation list provided");
-	}
-
-	gnutls_certificate_set_dh_params (x509_cred, dh_params);
-
-	return x509_cred;
+    VncConnectionPrivate *priv = conn->priv;
+    gnutls_certificate_credentials_t x509_cred;
+    int ret;
+
+    if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) {
+        VNC_DEBUG("Cannot allocate credentials %s", gnutls_strerror(ret));
+        return NULL;
+    }
+    if (priv->cred_x509_cacert) {
+        if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred,
+                                                          priv->cred_x509_cacert,
+                                                          GNUTLS_X509_FMT_PEM)) < 0) {
+            VNC_DEBUG("Cannot load CA certificate %s", gnutls_strerror(ret));
+            return NULL;
+        }
+    } else {
+        VNC_DEBUG("No CA certificate provided");
+        return NULL;
+    }
+
+    if (priv->cred_x509_cert && priv->cred_x509_key) {
+        if ((ret = gnutls_certificate_set_x509_key_file (x509_cred,
+                                                         priv->cred_x509_cert,
+                                                         priv->cred_x509_key,
+                                                         GNUTLS_X509_FMT_PEM)) < 0) {
+            VNC_DEBUG("Cannot load certificate & key %s", gnutls_strerror(ret));
+            return NULL;
+        }
+    } else {
+        VNC_DEBUG("No client cert or key provided");
+    }
+
+    if (priv->cred_x509_cacrl) {
+        if ((ret = gnutls_certificate_set_x509_crl_file(x509_cred,
+                                                        priv->cred_x509_cacrl,
+                                                        GNUTLS_X509_FMT_PEM)) < 0) {
+            VNC_DEBUG("Cannot load CRL %s", gnutls_strerror(ret));
+            return NULL;
+        }
+    } else {
+        VNC_DEBUG("No CA revocation list provided");
+    }
+
+    gnutls_certificate_set_dh_params (x509_cred, dh_params);
+
+    return x509_cred;
 }
 
 static int vnc_connection_validate_certificate(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int ret;
-	unsigned int status;
-	const gnutls_datum_t *certs;
-	unsigned int nCerts, i;
-	time_t now;
-
-	VNC_DEBUG("Validating");
-	if ((ret = gnutls_certificate_verify_peers2 (priv->tls_session, &status)) < 0) {
-		VNC_DEBUG("Verify failed %s", gnutls_strerror(ret));
-		return FALSE;
-	}
-
-	if ((now = time(NULL)) == ((time_t)-1)) {
-		return FALSE;
-	}
-
-	if (status != 0) {
-		if (status & GNUTLS_CERT_INVALID)
-			VNC_DEBUG ("The certificate is not trusted.");
-
-		if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
-			VNC_DEBUG ("The certificate hasn't got a known issuer.");
-
-		if (status & GNUTLS_CERT_REVOKED)
-			VNC_DEBUG ("The certificate has been revoked.");
-
-		if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
-			VNC_DEBUG ("The certificate uses an insecure algorithm");
-
-		return FALSE;
-	} else {
-		VNC_DEBUG("Certificate is valid.");
-	}
-
-	if (gnutls_certificate_type_get(priv->tls_session) != GNUTLS_CRT_X509)
-		return FALSE;
-
-	if (!(certs = gnutls_certificate_get_peers(priv->tls_session, &nCerts)))
-		return FALSE;
-
-	for (i = 0 ; i < nCerts ; i++) {
-		gnutls_x509_crt_t cert;
-		VNC_DEBUG ("Checking chain %d", i);
-		if (gnutls_x509_crt_init (&cert) < 0)
-			return FALSE;
-
-		if (gnutls_x509_crt_import(cert, &certs[i], GNUTLS_X509_FMT_DER) < 0) {
-			gnutls_x509_crt_deinit (cert);
-			return FALSE;
-		}
-
-		if (gnutls_x509_crt_get_expiration_time (cert) < now) {
-			VNC_DEBUG("The certificate has expired");
-			gnutls_x509_crt_deinit (cert);
-			return FALSE;
-		}
-
-		if (gnutls_x509_crt_get_activation_time (cert) > now) {
-			VNC_DEBUG("The certificate is not yet activated");
-			gnutls_x509_crt_deinit (cert);
-			return FALSE;
-		}
-
-		if (gnutls_x509_crt_get_activation_time (cert) > now) {
-			VNC_DEBUG("The certificate is not yet activated");
-			gnutls_x509_crt_deinit (cert);
-			return FALSE;
-		}
-
-		if (i == 0) {
-			if (!priv->host) {
-				VNC_DEBUG ("No hostname provided for certificate verification");
-				gnutls_x509_crt_deinit (cert);
-				return FALSE;
-			}
-			if (!gnutls_x509_crt_check_hostname (cert, priv->host)) {
-				VNC_DEBUG ("The certificate's owner does not match hostname '%s'",
-					    priv->host);
-				gnutls_x509_crt_deinit (cert);
-				return FALSE;
-			}
-		}
-	}
-
-	return TRUE;
+    VncConnectionPrivate *priv = conn->priv;
+    int ret;
+    unsigned int status;
+    const gnutls_datum_t *certs;
+    unsigned int nCerts, i;
+    time_t now;
+
+    VNC_DEBUG("Validating");
+    if ((ret = gnutls_certificate_verify_peers2 (priv->tls_session, &status)) < 0) {
+        VNC_DEBUG("Verify failed %s", gnutls_strerror(ret));
+        return FALSE;
+    }
+
+    if ((now = time(NULL)) == ((time_t)-1)) {
+        return FALSE;
+    }
+
+    if (status != 0) {
+        if (status & GNUTLS_CERT_INVALID)
+            VNC_DEBUG ("The certificate is not trusted.");
+
+        if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
+            VNC_DEBUG ("The certificate hasn't got a known issuer.");
+
+        if (status & GNUTLS_CERT_REVOKED)
+            VNC_DEBUG ("The certificate has been revoked.");
+
+        if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
+            VNC_DEBUG ("The certificate uses an insecure algorithm");
+
+        return FALSE;
+    } else {
+        VNC_DEBUG("Certificate is valid.");
+    }
+
+    if (gnutls_certificate_type_get(priv->tls_session) != GNUTLS_CRT_X509)
+        return FALSE;
+
+    if (!(certs = gnutls_certificate_get_peers(priv->tls_session, &nCerts)))
+        return FALSE;
+
+    for (i = 0 ; i < nCerts ; i++) {
+        gnutls_x509_crt_t cert;
+        VNC_DEBUG ("Checking chain %d", i);
+        if (gnutls_x509_crt_init (&cert) < 0)
+            return FALSE;
+
+        if (gnutls_x509_crt_import(cert, &certs[i], GNUTLS_X509_FMT_DER) < 0) {
+            gnutls_x509_crt_deinit (cert);
+            return FALSE;
+        }
+
+        if (gnutls_x509_crt_get_expiration_time (cert) < now) {
+            VNC_DEBUG("The certificate has expired");
+            gnutls_x509_crt_deinit (cert);
+            return FALSE;
+        }
+
+        if (gnutls_x509_crt_get_activation_time (cert) > now) {
+            VNC_DEBUG("The certificate is not yet activated");
+            gnutls_x509_crt_deinit (cert);
+            return FALSE;
+        }
+
+        if (gnutls_x509_crt_get_activation_time (cert) > now) {
+            VNC_DEBUG("The certificate is not yet activated");
+            gnutls_x509_crt_deinit (cert);
+            return FALSE;
+        }
+
+        if (i == 0) {
+            if (!priv->host) {
+                VNC_DEBUG ("No hostname provided for certificate verification");
+                gnutls_x509_crt_deinit (cert);
+                return FALSE;
+            }
+            if (!gnutls_x509_crt_check_hostname (cert, priv->host)) {
+                VNC_DEBUG ("The certificate's owner does not match hostname '%s'",
+                           priv->host);
+                gnutls_x509_crt_deinit (cert);
+                return FALSE;
+            }
+        }
+    }
+
+    return TRUE;
 }
 
 
 static void vnc_connection_read_pixel_format(VncConnection *conn, VncPixelFormat *fmt)
 {
-	guint8 pad[3];
+    guint8 pad[3];
 
-	fmt->bits_per_pixel  = vnc_connection_read_u8(conn);
-	fmt->depth           = vnc_connection_read_u8(conn);
-	fmt->byte_order      = vnc_connection_read_u8(conn) ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
-	fmt->true_color_flag = vnc_connection_read_u8(conn);
+    fmt->bits_per_pixel  = vnc_connection_read_u8(conn);
+    fmt->depth           = vnc_connection_read_u8(conn);
+    fmt->byte_order      = vnc_connection_read_u8(conn) ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+    fmt->true_color_flag = vnc_connection_read_u8(conn);
 
-	fmt->red_max         = vnc_connection_read_u16(conn);
-	fmt->green_max       = vnc_connection_read_u16(conn);
-	fmt->blue_max        = vnc_connection_read_u16(conn);
+    fmt->red_max         = vnc_connection_read_u16(conn);
+    fmt->green_max       = vnc_connection_read_u16(conn);
+    fmt->blue_max        = vnc_connection_read_u16(conn);
 
-	fmt->red_shift       = vnc_connection_read_u8(conn);
-	fmt->green_shift     = vnc_connection_read_u8(conn);
-	fmt->blue_shift      = vnc_connection_read_u8(conn);
+    fmt->red_shift       = vnc_connection_read_u8(conn);
+    fmt->green_shift     = vnc_connection_read_u8(conn);
+    fmt->blue_shift      = vnc_connection_read_u8(conn);
 
-	vnc_connection_read(conn, pad, 3);
+    vnc_connection_read(conn, pad, 3);
 
-	VNC_DEBUG("Pixel format BPP: %d,  Depth: %d, Byte order: %d, True color: %d\n"
-		   "             Mask  red: %3d, green: %3d, blue: %3d\n"
-		   "             Shift red: %3d, green: %3d, blue: %3d",
-		   fmt->bits_per_pixel, fmt->depth, fmt->byte_order, fmt->true_color_flag,
-		   fmt->red_max, fmt->green_max, fmt->blue_max,
-		   fmt->red_shift, fmt->green_shift, fmt->blue_shift);
+    VNC_DEBUG("Pixel format BPP: %d,  Depth: %d, Byte order: %d, True color: %d\n"
+              "             Mask  red: %3d, green: %3d, blue: %3d\n"
+              "             Shift red: %3d, green: %3d, blue: %3d",
+              fmt->bits_per_pixel, fmt->depth, fmt->byte_order, fmt->true_color_flag,
+              fmt->red_max, fmt->green_max, fmt->blue_max,
+              fmt->red_shift, fmt->green_shift, fmt->blue_shift);
 }
 
 /* initialize function */
 
 gboolean vnc_connection_has_error(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->has_error;
+    return priv->has_error;
 }
 
 const VncPixelFormat *vnc_connection_get_pixel_format(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return &priv->fmt;
+    return &priv->fmt;
 }
 
 
 gboolean vnc_connection_set_shared(VncConnection *conn, gboolean sharedFlag)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (vnc_connection_is_open(conn))
-		return FALSE;
+    if (vnc_connection_is_open(conn))
+        return FALSE;
 
-	priv->sharedFlag = sharedFlag;
+    priv->sharedFlag = sharedFlag;
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 gboolean vnc_connection_get_shared(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->sharedFlag;
+    return priv->sharedFlag;
 }
 
 
@@ -1402,21 +1402,21 @@ gboolean vnc_connection_get_shared(VncConnection *conn)
  */
 static void vnc_connection_buffered_write(VncConnection *conn, const void *data, size_t size)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	size_t left;
+    VncConnectionPrivate *priv = conn->priv;
+    size_t left;
 
-	left = priv->xmit_buffer_capacity - priv->xmit_buffer_size;
-	if (left < size) {
-		priv->xmit_buffer_capacity += size + 4095;
-		priv->xmit_buffer_capacity &= ~4095;
+    left = priv->xmit_buffer_capacity - priv->xmit_buffer_size;
+    if (left < size) {
+        priv->xmit_buffer_capacity += size + 4095;
+        priv->xmit_buffer_capacity &= ~4095;
 
-		priv->xmit_buffer = g_realloc(priv->xmit_buffer, priv->xmit_buffer_capacity);
-	}
+        priv->xmit_buffer = g_realloc(priv->xmit_buffer, priv->xmit_buffer_capacity);
+    }
 
-	memcpy(&priv->xmit_buffer[priv->xmit_buffer_size],
-	       data, size);
+    memcpy(&priv->xmit_buffer[priv->xmit_buffer_size],
+           data, size);
 
-	priv->xmit_buffer_size += size;
+    priv->xmit_buffer_size += size;
 }
 
 /*
@@ -1424,7 +1424,7 @@ static void vnc_connection_buffered_write(VncConnection *conn, const void *data,
  */
 static void vnc_connection_buffered_write_u8(VncConnection *conn, guint8 value)
 {
-	vnc_connection_buffered_write(conn, &value, 1);
+    vnc_connection_buffered_write(conn, &value, 1);
 }
 
 /*
@@ -1432,8 +1432,8 @@ static void vnc_connection_buffered_write_u8(VncConnection *conn, guint8 value)
  */
 static void vnc_connection_buffered_write_u16(VncConnection *conn, guint16 value)
 {
-	value = g_htons(value);
-	vnc_connection_buffered_write(conn, &value, 2);
+    value = g_htons(value);
+    vnc_connection_buffered_write(conn, &value, 2);
 }
 
 /*
@@ -1441,8 +1441,8 @@ static void vnc_connection_buffered_write_u16(VncConnection *conn, guint16 value
  */
 static void vnc_connection_buffered_write_u32(VncConnection *conn, guint32 value)
 {
-	value = g_htonl(value);
-	vnc_connection_buffered_write(conn, &value, 4);
+    value = g_htonl(value);
+    vnc_connection_buffered_write(conn, &value, 4);
 }
 
 /*
@@ -1450,8 +1450,8 @@ static void vnc_connection_buffered_write_u32(VncConnection *conn, guint32 value
  */
 static void vnc_connection_buffered_write_s32(VncConnection *conn, gint32 value)
 {
-	value = g_htonl(value);
-	vnc_connection_buffered_write(conn, &value, 4);
+    value = g_htonl(value);
+    vnc_connection_buffered_write(conn, &value, 4);
 }
 
 /*
@@ -1459,198 +1459,198 @@ static void vnc_connection_buffered_write_s32(VncConnection *conn, gint32 value)
  */
 static void vnc_connection_buffered_flush(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	g_io_wakeup(&priv->wait);
+    g_io_wakeup(&priv->wait);
 }
 
 gboolean vnc_connection_set_pixel_format(VncConnection *conn,
-					 const VncPixelFormat *fmt)
+                                         const VncPixelFormat *fmt)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 pad[3] = {0};
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 pad[3] = {0};
 
-	vnc_connection_buffered_write_u8(conn, 0);
-	vnc_connection_buffered_write(conn, pad, 3);
+    vnc_connection_buffered_write_u8(conn, 0);
+    vnc_connection_buffered_write(conn, pad, 3);
 
-	vnc_connection_buffered_write_u8(conn, fmt->bits_per_pixel);
-	vnc_connection_buffered_write_u8(conn, fmt->depth);
-	vnc_connection_buffered_write_u8(conn, fmt->byte_order == G_BIG_ENDIAN ? 1 : 0);
-	vnc_connection_buffered_write_u8(conn, fmt->true_color_flag);
+    vnc_connection_buffered_write_u8(conn, fmt->bits_per_pixel);
+    vnc_connection_buffered_write_u8(conn, fmt->depth);
+    vnc_connection_buffered_write_u8(conn, fmt->byte_order == G_BIG_ENDIAN ? 1 : 0);
+    vnc_connection_buffered_write_u8(conn, fmt->true_color_flag);
 
-	vnc_connection_buffered_write_u16(conn, fmt->red_max);
-	vnc_connection_buffered_write_u16(conn, fmt->green_max);
-	vnc_connection_buffered_write_u16(conn, fmt->blue_max);
+    vnc_connection_buffered_write_u16(conn, fmt->red_max);
+    vnc_connection_buffered_write_u16(conn, fmt->green_max);
+    vnc_connection_buffered_write_u16(conn, fmt->blue_max);
 
-	vnc_connection_buffered_write_u8(conn, fmt->red_shift);
-	vnc_connection_buffered_write_u8(conn, fmt->green_shift);
-	vnc_connection_buffered_write_u8(conn, fmt->blue_shift);
+    vnc_connection_buffered_write_u8(conn, fmt->red_shift);
+    vnc_connection_buffered_write_u8(conn, fmt->green_shift);
+    vnc_connection_buffered_write_u8(conn, fmt->blue_shift);
 
-	vnc_connection_buffered_write(conn, pad, 3);
-	vnc_connection_buffered_flush(conn);
+    vnc_connection_buffered_write(conn, pad, 3);
+    vnc_connection_buffered_flush(conn);
 
-	memcpy(&priv->fmt, fmt, sizeof(*fmt));
+    memcpy(&priv->fmt, fmt, sizeof(*fmt));
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 gboolean vnc_connection_set_audio(VncConnection *conn,
-				  VncAudio *audio)
+                                  VncAudio *audio)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->audio)
-		g_object_unref(priv->audio);
-	priv->audio = audio;
-	if (priv->audio)
-		g_object_ref(priv->audio);
+    if (priv->audio)
+        g_object_unref(priv->audio);
+    priv->audio = audio;
+    if (priv->audio)
+        g_object_ref(priv->audio);
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 static void vnc_connection_send_audio_format(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	vnc_connection_buffered_write_u8(conn,  255);
-	vnc_connection_buffered_write_u8(conn,  1); /* VNC_CONNECTION_QEMU_AUDIO */
-	vnc_connection_buffered_write_u16(conn, 2); /* VNC_CONNECTION_QEMU_AUDIO_SET_FORMAT */
+    vnc_connection_buffered_write_u8(conn,  255);
+    vnc_connection_buffered_write_u8(conn,  1); /* VNC_CONNECTION_QEMU_AUDIO */
+    vnc_connection_buffered_write_u16(conn, 2); /* VNC_CONNECTION_QEMU_AUDIO_SET_FORMAT */
 
-	vnc_connection_buffered_write_u8(conn,  priv->audio_format.format);
-	vnc_connection_buffered_write_u8(conn,  priv->audio_format.nchannels);
-	vnc_connection_buffered_write_u32(conn, priv->audio_format.frequency);
-	vnc_connection_buffered_flush(conn);
-	priv->audio_format_pending=FALSE;
+    vnc_connection_buffered_write_u8(conn,  priv->audio_format.format);
+    vnc_connection_buffered_write_u8(conn,  priv->audio_format.nchannels);
+    vnc_connection_buffered_write_u32(conn, priv->audio_format.frequency);
+    vnc_connection_buffered_flush(conn);
+    priv->audio_format_pending=FALSE;
 }
 
 gboolean vnc_connection_set_audio_format(VncConnection *conn,
-					 const VncAudioFormat *fmt)
+                                         const VncAudioFormat *fmt)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	memcpy(&priv->audio_format, fmt, sizeof(*fmt));
-	priv->audio_format_pending = TRUE;
+    memcpy(&priv->audio_format, fmt, sizeof(*fmt));
+    priv->audio_format_pending = TRUE;
 
-	if (priv->has_audio)
-		vnc_connection_send_audio_format(conn);
+    if (priv->has_audio)
+        vnc_connection_send_audio_format(conn);
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 const VncAudioFormat *vnc_connection_get_audio_format(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	return &priv->audio_format;
+    VncConnectionPrivate *priv = conn->priv;
+    return &priv->audio_format;
 }
 
 
 gboolean vnc_connection_audio_enable(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->has_audio)
-	{
-		vnc_connection_buffered_write_u8(conn,  255); /* QEMU message */
-		vnc_connection_buffered_write_u8(conn,  1);   /* VNC_CONNECTION_QEMU_AUDIO */
-		vnc_connection_buffered_write_u16(conn, 0);   /* VNC_CONNECTION_QEMU_AUDIO_ENABLE */
-		vnc_connection_buffered_flush(conn);
-		priv->audio_enable_pending=FALSE;
-	}
-	else
-		priv->audio_enable_pending=TRUE;
-	return !vnc_connection_has_error(conn);
+    if (priv->has_audio)
+        {
+            vnc_connection_buffered_write_u8(conn,  255); /* QEMU message */
+            vnc_connection_buffered_write_u8(conn,  1);   /* VNC_CONNECTION_QEMU_AUDIO */
+            vnc_connection_buffered_write_u16(conn, 0);   /* VNC_CONNECTION_QEMU_AUDIO_ENABLE */
+            vnc_connection_buffered_flush(conn);
+            priv->audio_enable_pending=FALSE;
+        }
+    else
+        priv->audio_enable_pending=TRUE;
+    return !vnc_connection_has_error(conn);
 }
 
 gboolean vnc_connection_audio_disable(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	priv->audio_disable_pending=TRUE;
+    VncConnectionPrivate *priv = conn->priv;
+    priv->audio_disable_pending=TRUE;
 
-	if (priv->has_audio)
-	{
-		vnc_connection_buffered_write_u8(conn,  255); /* QEMU message */
-		vnc_connection_buffered_write_u8(conn,  1);   /* VNC_CONNECTION_QEMU_AUDIO */
-		vnc_connection_buffered_write_u16(conn, 1);  /* VNC_CONNECTION_QEMU_AUDIO_ENABLE */
-		vnc_connection_buffered_flush(conn);
-		priv->audio_disable_pending=FALSE;
-	}
-	else
-		priv->audio_disable_pending=TRUE;
-	return !vnc_connection_has_error(conn);
+    if (priv->has_audio)
+        {
+            vnc_connection_buffered_write_u8(conn,  255); /* QEMU message */
+            vnc_connection_buffered_write_u8(conn,  1);   /* VNC_CONNECTION_QEMU_AUDIO */
+            vnc_connection_buffered_write_u16(conn, 1);  /* VNC_CONNECTION_QEMU_AUDIO_ENABLE */
+            vnc_connection_buffered_flush(conn);
+            priv->audio_disable_pending=FALSE;
+        }
+    else
+        priv->audio_disable_pending=TRUE;
+    return !vnc_connection_has_error(conn);
 }
 
 
 gboolean vnc_connection_set_encodings(VncConnection *conn, int n_encoding, gint32 *encoding)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 pad[1] = {0};
-	int i, skip_zrle=0;
-
-	/*
-	 * RealVNC server is broken for ZRLE in some pixel formats.
-	 * Specifically if you have a format with either R, G or B
-	 * components with a max value > 255, it still uses a CPIXEL
-	 * of 3 bytes, even though the colour requirs 4 bytes. It
-	 * thus messes up the colours of the server in a way we can't
-	 * recover from on the client. Most VNC clients don't see this
-	 * problem since they send a 'set pixel format' message instead
-	 * of running with the server's default format.
-	 *
-	 * So we kill off ZRLE encoding for problematic pixel formats
-	 */
-	for (i = 0; i < n_encoding; i++)
-		if (priv->fmt.depth == 32 &&
-		    (priv->fmt.red_max > 255 ||
-		     priv->fmt.blue_max > 255 ||
-		     priv->fmt.green_max > 255) &&
-		    encoding[i] == VNC_CONNECTION_ENCODING_ZRLE) {
-			VNC_DEBUG("Dropping ZRLE encoding for broken pixel format");
-			skip_zrle++;
-		}
-
-	priv->has_ext_key_event = FALSE;
-	priv->has_audio = FALSE;
-	vnc_connection_buffered_write_u8(conn, 2);
-	vnc_connection_buffered_write(conn, pad, 1);
-	vnc_connection_buffered_write_u16(conn, n_encoding - skip_zrle);
-	for (i = 0; i < n_encoding; i++) {
-		if (skip_zrle && encoding[i] == VNC_CONNECTION_ENCODING_ZRLE)
-			continue;
-		vnc_connection_buffered_write_s32(conn, encoding[i]);
-	}
-	vnc_connection_buffered_flush(conn);
-	return !vnc_connection_has_error(conn);
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 pad[1] = {0};
+    int i, skip_zrle=0;
+
+    /*
+     * RealVNC server is broken for ZRLE in some pixel formats.
+     * Specifically if you have a format with either R, G or B
+     * components with a max value > 255, it still uses a CPIXEL
+     * of 3 bytes, even though the colour requirs 4 bytes. It
+     * thus messes up the colours of the server in a way we can't
+     * recover from on the client. Most VNC clients don't see this
+     * problem since they send a 'set pixel format' message instead
+     * of running with the server's default format.
+     *
+     * So we kill off ZRLE encoding for problematic pixel formats
+     */
+    for (i = 0; i < n_encoding; i++)
+        if (priv->fmt.depth == 32 &&
+            (priv->fmt.red_max > 255 ||
+             priv->fmt.blue_max > 255 ||
+             priv->fmt.green_max > 255) &&
+            encoding[i] == VNC_CONNECTION_ENCODING_ZRLE) {
+            VNC_DEBUG("Dropping ZRLE encoding for broken pixel format");
+            skip_zrle++;
+        }
+
+    priv->has_ext_key_event = FALSE;
+    priv->has_audio = FALSE;
+    vnc_connection_buffered_write_u8(conn, 2);
+    vnc_connection_buffered_write(conn, pad, 1);
+    vnc_connection_buffered_write_u16(conn, n_encoding - skip_zrle);
+    for (i = 0; i < n_encoding; i++) {
+        if (skip_zrle && encoding[i] == VNC_CONNECTION_ENCODING_ZRLE)
+            continue;
+        vnc_connection_buffered_write_s32(conn, encoding[i]);
+    }
+    vnc_connection_buffered_flush(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 gboolean vnc_connection_framebuffer_update_request(VncConnection *conn,
-						   gboolean incremental,
-						   guint16 x, guint16 y,
-						   guint16 width, guint16 height)
+                                                   gboolean incremental,
+                                                   guint16 x, guint16 y,
+                                                   guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Requesting framebuffer update at %d,%d size %dx%d, incremental %d",
-		  x, y, width, height, (int)incremental);
+    VNC_DEBUG("Requesting framebuffer update at %d,%d size %dx%d, incremental %d",
+              x, y, width, height, (int)incremental);
 
-	priv->lastUpdateRequest.incremental = incremental;
-	priv->lastUpdateRequest.x = x;
-	priv->lastUpdateRequest.y = y;
-	priv->lastUpdateRequest.width = width;
-	priv->lastUpdateRequest.height = height;
+    priv->lastUpdateRequest.incremental = incremental;
+    priv->lastUpdateRequest.x = x;
+    priv->lastUpdateRequest.y = y;
+    priv->lastUpdateRequest.width = width;
+    priv->lastUpdateRequest.height = height;
 
-	vnc_connection_buffered_write_u8(conn, 3);
-	vnc_connection_buffered_write_u8(conn, incremental ? 1 : 0);
-	vnc_connection_buffered_write_u16(conn, x);
-	vnc_connection_buffered_write_u16(conn, y);
-	vnc_connection_buffered_write_u16(conn, width);
-	vnc_connection_buffered_write_u16(conn, height);
-	vnc_connection_buffered_flush(conn);
+    vnc_connection_buffered_write_u8(conn, 3);
+    vnc_connection_buffered_write_u8(conn, incremental ? 1 : 0);
+    vnc_connection_buffered_write_u16(conn, x);
+    vnc_connection_buffered_write_u16(conn, y);
+    vnc_connection_buffered_write_u16(conn, width);
+    vnc_connection_buffered_write_u16(conn, height);
+    vnc_connection_buffered_flush(conn);
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
@@ -1661,117 +1661,117 @@ gboolean vnc_connection_framebuffer_update_request(VncConnection *conn,
 static gboolean
 vnc_connection_resend_framebuffer_update_request(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Re-requesting framebuffer update at %d,%d size %dx%d, incremental %d",
-		  priv->lastUpdateRequest.x,
-		  priv->lastUpdateRequest.y,
-		  priv->lastUpdateRequest.width,
-		  priv->lastUpdateRequest.height,
-		  (int)priv->lastUpdateRequest.incremental);
+    VNC_DEBUG("Re-requesting framebuffer update at %d,%d size %dx%d, incremental %d",
+              priv->lastUpdateRequest.x,
+              priv->lastUpdateRequest.y,
+              priv->lastUpdateRequest.width,
+              priv->lastUpdateRequest.height,
+              (int)priv->lastUpdateRequest.incremental);
 
-	vnc_connection_write_u8(conn, 3);
-	vnc_connection_write_u8(conn, priv->lastUpdateRequest.incremental ? 1 : 0);
-	vnc_connection_write_u16(conn, priv->lastUpdateRequest.x);
-	vnc_connection_write_u16(conn, priv->lastUpdateRequest.y);
-	vnc_connection_write_u16(conn, priv->lastUpdateRequest.width);
-	vnc_connection_write_u16(conn, priv->lastUpdateRequest.height);
-	vnc_connection_flush(conn);
+    vnc_connection_write_u8(conn, 3);
+    vnc_connection_write_u8(conn, priv->lastUpdateRequest.incremental ? 1 : 0);
+    vnc_connection_write_u16(conn, priv->lastUpdateRequest.x);
+    vnc_connection_write_u16(conn, priv->lastUpdateRequest.y);
+    vnc_connection_write_u16(conn, priv->lastUpdateRequest.width);
+    vnc_connection_write_u16(conn, priv->lastUpdateRequest.height);
+    vnc_connection_flush(conn);
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 gboolean vnc_connection_key_event(VncConnection *conn, gboolean down_flag,
-				  guint32 key, guint16 scancode)
+                                  guint32 key, guint16 scancode)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 pad[2] = {0};
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 pad[2] = {0};
 
-	VNC_DEBUG("Key event %d %d %d Extended: %d", key, scancode, down_flag, priv->has_ext_key_event);
-	if (priv->has_ext_key_event) {
-		vnc_connection_buffered_write_u8(conn, 255);
-		vnc_connection_buffered_write_u8(conn, 0);
-		vnc_connection_buffered_write_u16(conn, down_flag ? 1 : 0);
-		vnc_connection_buffered_write_u32(conn, key);
-		vnc_connection_buffered_write_u32(conn, scancode);
-	} else {
-		vnc_connection_buffered_write_u8(conn, 4);
-		vnc_connection_buffered_write_u8(conn, down_flag ? 1 : 0);
-		vnc_connection_buffered_write(conn, pad, 2);
-		vnc_connection_buffered_write_u32(conn, key);
-	}
+    VNC_DEBUG("Key event %d %d %d Extended: %d", key, scancode, down_flag, priv->has_ext_key_event);
+    if (priv->has_ext_key_event) {
+        vnc_connection_buffered_write_u8(conn, 255);
+        vnc_connection_buffered_write_u8(conn, 0);
+        vnc_connection_buffered_write_u16(conn, down_flag ? 1 : 0);
+        vnc_connection_buffered_write_u32(conn, key);
+        vnc_connection_buffered_write_u32(conn, scancode);
+    } else {
+        vnc_connection_buffered_write_u8(conn, 4);
+        vnc_connection_buffered_write_u8(conn, down_flag ? 1 : 0);
+        vnc_connection_buffered_write(conn, pad, 2);
+        vnc_connection_buffered_write_u32(conn, key);
+    }
 
-	vnc_connection_buffered_flush(conn);
-	return !vnc_connection_has_error(conn);
+    vnc_connection_buffered_flush(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 gboolean vnc_connection_pointer_event(VncConnection *conn, guint8 button_mask,
-				      guint16 x, guint16 y)
+                                      guint16 x, guint16 y)
 {
-	vnc_connection_buffered_write_u8(conn, 5);
-	vnc_connection_buffered_write_u8(conn, button_mask);
-	vnc_connection_buffered_write_u16(conn, x);
-	vnc_connection_buffered_write_u16(conn, y);
-	vnc_connection_buffered_flush(conn);
-	return !vnc_connection_has_error(conn);
+    vnc_connection_buffered_write_u8(conn, 5);
+    vnc_connection_buffered_write_u8(conn, button_mask);
+    vnc_connection_buffered_write_u16(conn, x);
+    vnc_connection_buffered_write_u16(conn, y);
+    vnc_connection_buffered_flush(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 gboolean vnc_connection_client_cut_text(VncConnection *conn,
-					const void *data, size_t length)
+                                        const void *data, size_t length)
 {
-	guint8 pad[3] = {0};
+    guint8 pad[3] = {0};
 
-	vnc_connection_buffered_write_u8(conn, 6);
-	vnc_connection_buffered_write(conn, pad, 3);
-	vnc_connection_buffered_write_u32(conn, length);
-	vnc_connection_buffered_write(conn, data, length);
-	vnc_connection_buffered_flush(conn);
-	return !vnc_connection_has_error(conn);
+    vnc_connection_buffered_write_u8(conn, 6);
+    vnc_connection_buffered_write(conn, pad, 3);
+    vnc_connection_buffered_write_u32(conn, length);
+    vnc_connection_buffered_write(conn, data, length);
+    vnc_connection_buffered_flush(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 static inline guint8 *vnc_connection_get_local(VncConnection *conn, int x, int y)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	const VncPixelFormat *local = vnc_framebuffer_get_local_format(priv->fb);
-	int rowstride = vnc_framebuffer_get_rowstride(priv->fb);
+    VncConnectionPrivate *priv = conn->priv;
+    const VncPixelFormat *local = vnc_framebuffer_get_local_format(priv->fb);
+    int rowstride = vnc_framebuffer_get_rowstride(priv->fb);
 
-	return vnc_framebuffer_get_buffer(priv->fb) +
-		(y * rowstride) +
-		(x * (local->bits_per_pixel / 8));
+    return vnc_framebuffer_get_buffer(priv->fb) +
+        (y * rowstride) +
+        (x * (local->bits_per_pixel / 8));
 }
 
 
 static guint8 vnc_connection_swap_rfb_8(VncConnection *conn G_GNUC_UNUSED, guint8 pixel)
 {
-	return pixel;
+    return pixel;
 }
 
 /* VNC server RFB  format ->  local host native format */
 static guint16 vnc_connection_swap_rfb_16(VncConnection *conn, guint16 pixel)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->fbSwapRemote)
-		return  (((pixel >> 8) & 0xFF) << 0) |
-			(((pixel >> 0) & 0xFF) << 8);
-	else
-		return pixel;
+    if (priv->fbSwapRemote)
+        return  (((pixel >> 8) & 0xFF) << 0) |
+            (((pixel >> 0) & 0xFF) << 8);
+    else
+        return pixel;
 }
 
 /* VNC server RFB  format ->  local host native format */
 static guint32 vnc_connection_swap_rfb_32(VncConnection *conn, guint32 pixel)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->fbSwapRemote)
-		return  (((pixel >> 24) & 0xFF) <<  0) |
-			(((pixel >> 16) & 0xFF) <<  8) |
-			(((pixel >>  8) & 0xFF) << 16) |
-			(((pixel >>  0) & 0xFF) << 24);
-	else
-		return pixel;
+    if (priv->fbSwapRemote)
+        return  (((pixel >> 24) & 0xFF) <<  0) |
+            (((pixel >> 16) & 0xFF) <<  8) |
+            (((pixel >>  8) & 0xFF) << 16) |
+            (((pixel >>  0) & 0xFF) << 24);
+    else
+        return pixel;
 }
 
 #define SRC 8
@@ -1831,1441 +1831,1441 @@ static guint32 vnc_connection_swap_rfb_32(VncConnection *conn, guint32 pixel)
 #undef DST
 
 static vnc_connection_rich_cursor_blt_func *vnc_connection_rich_cursor_blt_table[3] = {
-	vnc_connection_rich_cursor_blt_8x32,
-	vnc_connection_rich_cursor_blt_16x32,
-	vnc_connection_rich_cursor_blt_32x32,
+    vnc_connection_rich_cursor_blt_8x32,
+    vnc_connection_rich_cursor_blt_16x32,
+    vnc_connection_rich_cursor_blt_32x32,
 };
 
 static vnc_connection_tight_compute_predicted_func *vnc_connection_tight_compute_predicted_table[3] = {
-	(vnc_connection_tight_compute_predicted_func *)vnc_connection_tight_compute_predicted_8x8,
-	(vnc_connection_tight_compute_predicted_func *)vnc_connection_tight_compute_predicted_16x16,
-	(vnc_connection_tight_compute_predicted_func *)vnc_connection_tight_compute_predicted_32x32,
+    (vnc_connection_tight_compute_predicted_func *)vnc_connection_tight_compute_predicted_8x8,
+    (vnc_connection_tight_compute_predicted_func *)vnc_connection_tight_compute_predicted_16x16,
+    (vnc_connection_tight_compute_predicted_func *)vnc_connection_tight_compute_predicted_32x32,
 };
 
 static vnc_connection_tight_sum_pixel_func *vnc_connection_tight_sum_pixel_table[3] = {
-	(vnc_connection_tight_sum_pixel_func *)vnc_connection_tight_sum_pixel_8x8,
-	(vnc_connection_tight_sum_pixel_func *)vnc_connection_tight_sum_pixel_16x16,
-	(vnc_connection_tight_sum_pixel_func *)vnc_connection_tight_sum_pixel_32x32,
+    (vnc_connection_tight_sum_pixel_func *)vnc_connection_tight_sum_pixel_8x8,
+    (vnc_connection_tight_sum_pixel_func *)vnc_connection_tight_sum_pixel_16x16,
+    (vnc_connection_tight_sum_pixel_func *)vnc_connection_tight_sum_pixel_32x32,
 };
 
 
 static void vnc_connection_raw_update(VncConnection *conn,
-				      guint16 x, guint16 y,
-				      guint16 width, guint16 height)
-{
-	VncConnectionPrivate *priv = conn->priv;
-
-	/* optimize for perfect match between server/client
-	   FWIW, in the local case, we ought to be doing a write
-	   directly from the source framebuffer and a read directly
-	   into the client framebuffer
-	*/
-	if (vnc_framebuffer_perfect_format_match(priv->fb)) {
-		int i;
-		int rowstride = vnc_framebuffer_get_rowstride(priv->fb);
-		guint8 *dst = vnc_framebuffer_get_buffer(priv->fb);
-
-		dst += (y * rowstride) + (x * (priv->fmt.bits_per_pixel/8));
-
-		for (i = 0; i < height; i++) {
-			vnc_connection_read(conn, dst,
-					    width * (priv->fmt.bits_per_pixel/8));
-			dst += rowstride;
-		}
-	} else {
-		guint8 *dst;
-		int i;
-
-		dst = g_malloc(width * (priv->fmt.bits_per_pixel / 8));
-		for (i = 0; i < height; i++) {
-			vnc_connection_read(conn, dst, width * (priv->fmt.bits_per_pixel / 8));
-			vnc_framebuffer_blt(priv->fb, dst, 0, x, y + i, width, 1);
-		}
-		g_free(dst);
-	}
+                                      guint16 x, guint16 y,
+                                      guint16 width, guint16 height)
+{
+    VncConnectionPrivate *priv = conn->priv;
+
+    /* optimize for perfect match between server/client
+       FWIW, in the local case, we ought to be doing a write
+       directly from the source framebuffer and a read directly
+       into the client framebuffer
+    */
+    if (vnc_framebuffer_perfect_format_match(priv->fb)) {
+        int i;
+        int rowstride = vnc_framebuffer_get_rowstride(priv->fb);
+        guint8 *dst = vnc_framebuffer_get_buffer(priv->fb);
+
+        dst += (y * rowstride) + (x * (priv->fmt.bits_per_pixel/8));
+
+        for (i = 0; i < height; i++) {
+            vnc_connection_read(conn, dst,
+                                width * (priv->fmt.bits_per_pixel/8));
+            dst += rowstride;
+        }
+    } else {
+        guint8 *dst;
+        int i;
+
+        dst = g_malloc(width * (priv->fmt.bits_per_pixel / 8));
+        for (i = 0; i < height; i++) {
+            vnc_connection_read(conn, dst, width * (priv->fmt.bits_per_pixel / 8));
+            vnc_framebuffer_blt(priv->fb, dst, 0, x, y + i, width, 1);
+        }
+        g_free(dst);
+    }
 }
 
 static void vnc_connection_copyrect_update(VncConnection *conn,
-					   guint16 dst_x, guint16 dst_y,
-					   guint16 width, guint16 height)
+                                           guint16 dst_x, guint16 dst_y,
+                                           guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int src_x, src_y;
+    VncConnectionPrivate *priv = conn->priv;
+    int src_x, src_y;
 
-	src_x = vnc_connection_read_u16(conn);
-	src_y = vnc_connection_read_u16(conn);
+    src_x = vnc_connection_read_u16(conn);
+    src_y = vnc_connection_read_u16(conn);
 
-	vnc_framebuffer_copyrect(priv->fb,
-				 src_x, src_y,
-				 dst_x, dst_y,
-				 width, height);
+    vnc_framebuffer_copyrect(priv->fb,
+                             src_x, src_y,
+                             dst_x, dst_y,
+                             width, height);
 }
 
 static void vnc_connection_hextile_rect(VncConnection *conn,
-					guint8 flags,
-					guint16 x, guint16 y,
-					guint16 width, guint16 height,
-					guint8 *fg, guint8 *bg)
+                                        guint8 flags,
+                                        guint16 x, guint16 y,
+                                        guint16 width, guint16 height,
+                                        guint8 *fg, guint8 *bg)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int i;
+    VncConnectionPrivate *priv = conn->priv;
+    int i;
 
-	if (flags & 0x01) {
-		vnc_connection_raw_update(conn, x, y, width, height);
-	} else {
-		/* Background Specified */
-		if (flags & 0x02)
-			vnc_connection_read_pixel(conn, bg);
+    if (flags & 0x01) {
+        vnc_connection_raw_update(conn, x, y, width, height);
+    } else {
+        /* Background Specified */
+        if (flags & 0x02)
+            vnc_connection_read_pixel(conn, bg);
 
-		/* Foreground Specified */
-		if (flags & 0x04)
-			vnc_connection_read_pixel(conn, fg);
+        /* Foreground Specified */
+        if (flags & 0x04)
+            vnc_connection_read_pixel(conn, fg);
 
-		vnc_framebuffer_fill(priv->fb, bg, x, y, width, height);
+        vnc_framebuffer_fill(priv->fb, bg, x, y, width, height);
 
-		/* AnySubrects */
-		if (flags & 0x08) {
-			guint8 n_rects = vnc_connection_read_u8(conn);
+        /* AnySubrects */
+        if (flags & 0x08) {
+            guint8 n_rects = vnc_connection_read_u8(conn);
 
-			for (i = 0; i < n_rects; i++) {
-				guint8 xy, wh;
+            for (i = 0; i < n_rects; i++) {
+                guint8 xy, wh;
 
-				/* SubrectsColored */
-				if (flags & 0x10)
-					vnc_connection_read_pixel(conn, fg);
+                /* SubrectsColored */
+                if (flags & 0x10)
+                    vnc_connection_read_pixel(conn, fg);
 
-				xy = vnc_connection_read_u8(conn);
-				wh = vnc_connection_read_u8(conn);
+                xy = vnc_connection_read_u8(conn);
+                wh = vnc_connection_read_u8(conn);
 
-				vnc_framebuffer_fill(priv->fb, fg,
-						     x + nibhi(xy), y + niblo(xy),
-						     nibhi(wh) + 1, niblo(wh) + 1);
-			}
-		}
-	}
+                vnc_framebuffer_fill(priv->fb, fg,
+                                     x + nibhi(xy), y + niblo(xy),
+                                     nibhi(wh) + 1, niblo(wh) + 1);
+            }
+        }
+    }
 }
 
 
 static void vnc_connection_hextile_update(VncConnection *conn,
-					  guint16 x, guint16 y,
-					  guint16 width, guint16 height)
-{
-	guint8 fg[4];
-	guint8 bg[4];
-
-	int j;
-	for (j = 0; j < height; j += 16) {
-		int i;
-		for (i = 0; i < width; i += 16) {
-			guint8 flags;
-			int w = MIN(16, width - i);
-			int h = MIN(16, height - j);
-
-			flags = vnc_connection_read_u8(conn);
-			vnc_connection_hextile_rect(conn, flags,
-						    x + i, y + j,
-						    w, h,
-						    fg, bg);
-		}
-	}
+                                          guint16 x, guint16 y,
+                                          guint16 width, guint16 height)
+{
+    guint8 fg[4];
+    guint8 bg[4];
+
+    int j;
+    for (j = 0; j < height; j += 16) {
+        int i;
+        for (i = 0; i < width; i += 16) {
+            guint8 flags;
+            int w = MIN(16, width - i);
+            int h = MIN(16, height - j);
+
+            flags = vnc_connection_read_u8(conn);
+            vnc_connection_hextile_rect(conn, flags,
+                                        x + i, y + j,
+                                        w, h,
+                                        fg, bg);
+        }
+    }
 }
 
 static void vnc_connection_rre_update(VncConnection *conn,
-				      guint16 x, guint16 y,
-				      guint16 width, guint16 height)
+                                      guint16 x, guint16 y,
+                                      guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 bg[4];
-	guint32 num;
-	guint32 i;
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 bg[4];
+    guint32 num;
+    guint32 i;
 
-	num = vnc_connection_read_u32(conn);
-	vnc_connection_read_pixel(conn, bg);
-	vnc_framebuffer_fill(priv->fb, bg, x, y, width, height);
+    num = vnc_connection_read_u32(conn);
+    vnc_connection_read_pixel(conn, bg);
+    vnc_framebuffer_fill(priv->fb, bg, x, y, width, height);
 
-	for (i = 0; i < num; i++) {
-		guint8 fg[4];
-		guint16 sub_x, sub_y, sub_w, sub_h;
+    for (i = 0; i < num; i++) {
+        guint8 fg[4];
+        guint16 sub_x, sub_y, sub_w, sub_h;
 
-		vnc_connection_read_pixel(conn, fg);
-		sub_x = vnc_connection_read_u16(conn);
-		sub_y = vnc_connection_read_u16(conn);
-		sub_w = vnc_connection_read_u16(conn);
-		sub_h = vnc_connection_read_u16(conn);
+        vnc_connection_read_pixel(conn, fg);
+        sub_x = vnc_connection_read_u16(conn);
+        sub_y = vnc_connection_read_u16(conn);
+        sub_w = vnc_connection_read_u16(conn);
+        sub_h = vnc_connection_read_u16(conn);
 
-		vnc_framebuffer_fill(priv->fb, fg,
-				     x + sub_x, y + sub_y, sub_w, sub_h);
-	}
+        vnc_framebuffer_fill(priv->fb, fg,
+                             x + sub_x, y + sub_y, sub_w, sub_h);
+    }
 }
 
 /* CPIXELs are optimized slightly.  32-bit pixel values are packed into 24-bit
  * values. */
 static void vnc_connection_read_cpixel(VncConnection *conn, guint8 *pixel)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int bpp = vnc_connection_pixel_size(conn);
-
-	memset(pixel, 0, bpp);
-
-	if (bpp == 4 && priv->fmt.true_color_flag) {
-		int fitsInMSB = ((priv->fmt.red_shift > 7) &&
-				 (priv->fmt.green_shift > 7) &&
-				 (priv->fmt.blue_shift > 7));
-		int fitsInLSB = (((priv->fmt.red_max << priv->fmt.red_shift) < (1 << 24)) &&
-				 ((priv->fmt.green_max << priv->fmt.green_shift) < (1 << 24)) &&
-				 ((priv->fmt.blue_max << priv->fmt.blue_shift) < (1 << 24)));
-
-		/*
-		 * We need to analyse the shifts to see if they fit in 3 bytes,
-		 * rather than looking at the declared  'depth' for the format
-		 * because despite what the RFB spec says, this is what RealVNC
-		 * server actually does in practice.
-		 */
-		if (fitsInMSB || fitsInLSB) {
-			bpp = 3;
-			if (priv->fmt.depth == 24 &&
-			    priv->fmt.byte_order == G_BIG_ENDIAN)
-				pixel++;
-		}
-	}
+    VncConnectionPrivate *priv = conn->priv;
+    int bpp = vnc_connection_pixel_size(conn);
+
+    memset(pixel, 0, bpp);
+
+    if (bpp == 4 && priv->fmt.true_color_flag) {
+        int fitsInMSB = ((priv->fmt.red_shift > 7) &&
+                         (priv->fmt.green_shift > 7) &&
+                         (priv->fmt.blue_shift > 7));
+        int fitsInLSB = (((priv->fmt.red_max << priv->fmt.red_shift) < (1 << 24)) &&
+                         ((priv->fmt.green_max << priv->fmt.green_shift) < (1 << 24)) &&
+                         ((priv->fmt.blue_max << priv->fmt.blue_shift) < (1 << 24)));
+
+        /*
+         * We need to analyse the shifts to see if they fit in 3 bytes,
+         * rather than looking at the declared  'depth' for the format
+         * because despite what the RFB spec says, this is what RealVNC
+         * server actually does in practice.
+         */
+        if (fitsInMSB || fitsInLSB) {
+            bpp = 3;
+            if (priv->fmt.depth == 24 &&
+                priv->fmt.byte_order == G_BIG_ENDIAN)
+                pixel++;
+        }
+    }
 
-	vnc_connection_read(conn, pixel, bpp);
+    vnc_connection_read(conn, pixel, bpp);
 }
 
 static void vnc_connection_zrle_update_tile_blit(VncConnection *conn,
-						 guint16 x, guint16 y,
-						 guint16 width, guint16 height)
+                                                 guint16 x, guint16 y,
+                                                 guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 blit_data[4 * 64 * 64];
-	int i, bpp;
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 blit_data[4 * 64 * 64];
+    int i, bpp;
 
-	bpp = vnc_connection_pixel_size(conn);
+    bpp = vnc_connection_pixel_size(conn);
 
-	for (i = 0; i < width * height; i++)
-		vnc_connection_read_cpixel(conn, blit_data + (i * bpp));
+    for (i = 0; i < width * height; i++)
+        vnc_connection_read_cpixel(conn, blit_data + (i * bpp));
 
-	vnc_framebuffer_blt(priv->fb, blit_data, width * bpp, x, y, width, height);
+    vnc_framebuffer_blt(priv->fb, blit_data, width * bpp, x, y, width, height);
 }
 
 static guint8 vnc_connection_read_zrle_pi(VncConnection *conn, int palette_size)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 pi = 0;
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 pi = 0;
 
-	if (priv->zrle_pi_bits == 0) {
-		priv->zrle_pi = vnc_connection_read_u8(conn);
-		priv->zrle_pi_bits = 8;
-	}
-	if ( palette_size == 2) {
-		pi = (priv->zrle_pi >> (priv->zrle_pi_bits - 1)) & 1;
-		priv->zrle_pi_bits -= 1;
-	} else if ((palette_size == 3) || (palette_size == 4)) {
-		pi = (priv->zrle_pi >> (priv->zrle_pi_bits - 2)) & 3;
-		priv->zrle_pi_bits -= 2;
-	} else if ((palette_size >=5) && (palette_size <=16)){
-		pi = (priv->zrle_pi >> (priv->zrle_pi_bits - 4)) & 15;
-		priv->zrle_pi_bits -= 4;
-	}
+    if (priv->zrle_pi_bits == 0) {
+        priv->zrle_pi = vnc_connection_read_u8(conn);
+        priv->zrle_pi_bits = 8;
+    }
+    if ( palette_size == 2) {
+        pi = (priv->zrle_pi >> (priv->zrle_pi_bits - 1)) & 1;
+        priv->zrle_pi_bits -= 1;
+    } else if ((palette_size == 3) || (palette_size == 4)) {
+        pi = (priv->zrle_pi >> (priv->zrle_pi_bits - 2)) & 3;
+        priv->zrle_pi_bits -= 2;
+    } else if ((palette_size >=5) && (palette_size <=16)){
+        pi = (priv->zrle_pi >> (priv->zrle_pi_bits - 4)) & 15;
+        priv->zrle_pi_bits -= 4;
+    }
 
-	return pi;
+    return pi;
 }
 
 static void vnc_connection_zrle_update_tile_palette(VncConnection *conn,
-						    guint8 palette_size,
-						    guint16 x, guint16 y,
-						    guint16 width, guint16 height)
+                                                    guint8 palette_size,
+                                                    guint16 x, guint16 y,
+                                                    guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 palette[128][4];
-	int i, j;
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 palette[128][4];
+    int i, j;
 
-	for (i = 0; i < palette_size; i++)
-		vnc_connection_read_cpixel(conn, palette[i]);
+    for (i = 0; i < palette_size; i++)
+        vnc_connection_read_cpixel(conn, palette[i]);
 
-	for (j = 0; j < height; j++) {
-		/* discard any padding bits */
-		priv->zrle_pi_bits = 0;
+    for (j = 0; j < height; j++) {
+        /* discard any padding bits */
+        priv->zrle_pi_bits = 0;
 
-		for (i = 0; i < width; i++) {
-			int ind = vnc_connection_read_zrle_pi(conn, palette_size);
+        for (i = 0; i < width; i++) {
+            int ind = vnc_connection_read_zrle_pi(conn, palette_size);
 
-			vnc_framebuffer_set_pixel_at(priv->fb, palette[ind & 0x7F],
-						     x + i, y + j);
-		}
-	}
+            vnc_framebuffer_set_pixel_at(priv->fb, palette[ind & 0x7F],
+                                         x + i, y + j);
+        }
+    }
 }
 
 static int vnc_connection_read_zrle_rl(VncConnection *conn)
 {
-	int rl = 1;
-	guint8 b;
+    int rl = 1;
+    guint8 b;
 
-	do {
-		b = vnc_connection_read_u8(conn);
-		rl += b;
-	} while (!vnc_connection_has_error(conn) && b == 255);
+    do {
+        b = vnc_connection_read_u8(conn);
+        rl += b;
+    } while (!vnc_connection_has_error(conn) && b == 255);
 
-	return rl;
+    return rl;
 }
 
 static void vnc_connection_zrle_update_tile_rle(VncConnection *conn,
-						guint16 x, guint16 y,
-						guint16 width, guint16 height)
-{
-	VncConnectionPrivate *priv = conn->priv;
-	int i, j, rl = 0;
-	guint8 pixel[4];
-
-	for (j = 0; j < height; j++) {
-		for (i = 0; i < width; i++) {
-			if (rl == 0) {
-				vnc_connection_read_cpixel(conn, pixel);
-				rl = vnc_connection_read_zrle_rl(conn);
-			}
-			vnc_framebuffer_set_pixel_at(priv->fb, pixel, x + i, y + j);
-			rl -= 1;
-		}
-	}
+                                                guint16 x, guint16 y,
+                                                guint16 width, guint16 height)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    int i, j, rl = 0;
+    guint8 pixel[4];
+
+    for (j = 0; j < height; j++) {
+        for (i = 0; i < width; i++) {
+            if (rl == 0) {
+                vnc_connection_read_cpixel(conn, pixel);
+                rl = vnc_connection_read_zrle_rl(conn);
+            }
+            vnc_framebuffer_set_pixel_at(priv->fb, pixel, x + i, y + j);
+            rl -= 1;
+        }
+    }
 }
 
 static void vnc_connection_zrle_update_tile_prle(VncConnection *conn,
-						 guint8 palette_size,
-						 guint16 x, guint16 y,
-						 guint16 width, guint16 height)
-{
-	VncConnectionPrivate *priv = conn->priv;
-	int i, j, rl = 0;
-	guint8 palette[128][4];
-	guint8 pi = 0;
-
-	for (i = 0; i < palette_size; i++)
-		vnc_connection_read_cpixel(conn, palette[i]);
-
-	for (j = 0; j < height; j++) {
-		for (i = 0; i < width; i++) {
-			if (rl == 0) {
-				pi = vnc_connection_read_u8(conn);
-				if (pi & 0x80) {
-					rl = vnc_connection_read_zrle_rl(conn);
-					pi &= 0x7F;
-				} else
-					rl = 1;
-			}
-
-			vnc_framebuffer_set_pixel_at(priv->fb, palette[pi], x + i, y + j);
-			rl -= 1;
-		}
-	}
+                                                 guint8 palette_size,
+                                                 guint16 x, guint16 y,
+                                                 guint16 width, guint16 height)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    int i, j, rl = 0;
+    guint8 palette[128][4];
+    guint8 pi = 0;
+
+    for (i = 0; i < palette_size; i++)
+        vnc_connection_read_cpixel(conn, palette[i]);
+
+    for (j = 0; j < height; j++) {
+        for (i = 0; i < width; i++) {
+            if (rl == 0) {
+                pi = vnc_connection_read_u8(conn);
+                if (pi & 0x80) {
+                    rl = vnc_connection_read_zrle_rl(conn);
+                    pi &= 0x7F;
+                } else
+                    rl = 1;
+            }
+
+            vnc_framebuffer_set_pixel_at(priv->fb, palette[pi], x + i, y + j);
+            rl -= 1;
+        }
+    }
 }
 
 static void vnc_connection_zrle_update_tile(VncConnection *conn, guint16 x, guint16 y,
-					    guint16 width, guint16 height)
-{
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 subencoding = vnc_connection_read_u8(conn);
-	guint8 pixel[4];
-
-	if (subencoding == 0 ) {
-		/* Raw pixel data */
-		vnc_connection_zrle_update_tile_blit(conn, x, y, width, height);
-	} else if (subencoding == 1) {
-		/* Solid tile of a single color */
-		vnc_connection_read_cpixel(conn, pixel);
-		vnc_framebuffer_fill(priv->fb, pixel, x, y, width, height);
-	} else if ((subencoding >= 2) && (subencoding <= 16)) {
-		/* Packed palette types */
-		vnc_connection_zrle_update_tile_palette(conn, subencoding,
-							x, y, width, height);
-	} else if ((subencoding >= 17) && (subencoding <= 127)) {
-		/* FIXME raise error? */
-	} else if (subencoding == 128) {
-		/* Plain RLE */
-		vnc_connection_zrle_update_tile_rle(conn, x, y, width, height);
-	} else if (subencoding == 129) {
-
-	} else if (subencoding >= 130) {
-		/* Palette RLE */
-		vnc_connection_zrle_update_tile_prle(conn, subencoding - 128,
-						     x, y, width, height);
-	}
+                                            guint16 width, guint16 height)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 subencoding = vnc_connection_read_u8(conn);
+    guint8 pixel[4];
+
+    if (subencoding == 0 ) {
+        /* Raw pixel data */
+        vnc_connection_zrle_update_tile_blit(conn, x, y, width, height);
+    } else if (subencoding == 1) {
+        /* Solid tile of a single color */
+        vnc_connection_read_cpixel(conn, pixel);
+        vnc_framebuffer_fill(priv->fb, pixel, x, y, width, height);
+    } else if ((subencoding >= 2) && (subencoding <= 16)) {
+        /* Packed palette types */
+        vnc_connection_zrle_update_tile_palette(conn, subencoding,
+                                                x, y, width, height);
+    } else if ((subencoding >= 17) && (subencoding <= 127)) {
+        /* FIXME raise error? */
+    } else if (subencoding == 128) {
+        /* Plain RLE */
+        vnc_connection_zrle_update_tile_rle(conn, x, y, width, height);
+    } else if (subencoding == 129) {
+
+    } else if (subencoding >= 130) {
+        /* Palette RLE */
+        vnc_connection_zrle_update_tile_prle(conn, subencoding - 128,
+                                             x, y, width, height);
+    }
 }
 
 static void vnc_connection_zrle_update(VncConnection *conn,
-				       guint16 x, guint16 y,
-				       guint16 width, guint16 height)
-{
-	VncConnectionPrivate *priv = conn->priv;
-	guint32 length;
-	guint16 i, j;
-	guint8 *zlib_data;
-
-	length = vnc_connection_read_u32(conn);
-	zlib_data = g_malloc(length);
-	vnc_connection_read(conn, zlib_data, length);
-
-	/* setup subsequent calls to vnc_connection_read*() to use the compressed data */
-	priv->uncompressed_length = 0;
-	priv->compressed_length = length;
-	priv->compressed_buffer = zlib_data;
-	priv->strm = &priv->streams[0];
-
-	for (j = 0; j < height; j += 64) {
-		for (i = 0; i < width; i += 64) {
-			guint16 w, h;
-
-			w = MIN(width - i, 64);
-			h = MIN(height - j, 64);
-			vnc_connection_zrle_update_tile(conn, x + i, y + j, w, h);
-		}
-	}
+                                       guint16 x, guint16 y,
+                                       guint16 width, guint16 height)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    guint32 length;
+    guint16 i, j;
+    guint8 *zlib_data;
+
+    length = vnc_connection_read_u32(conn);
+    zlib_data = g_malloc(length);
+    vnc_connection_read(conn, zlib_data, length);
+
+    /* setup subsequent calls to vnc_connection_read*() to use the compressed data */
+    priv->uncompressed_length = 0;
+    priv->compressed_length = length;
+    priv->compressed_buffer = zlib_data;
+    priv->strm = &priv->streams[0];
+
+    for (j = 0; j < height; j += 64) {
+        for (i = 0; i < width; i += 64) {
+            guint16 w, h;
+
+            w = MIN(width - i, 64);
+            h = MIN(height - j, 64);
+            vnc_connection_zrle_update_tile(conn, x + i, y + j, w, h);
+        }
+    }
 
-	priv->strm = NULL;
-	priv->uncompressed_length = 0;
-	priv->compressed_length = 0;
-	priv->compressed_buffer = NULL;
+    priv->strm = NULL;
+    priv->uncompressed_length = 0;
+    priv->compressed_length = 0;
+    priv->compressed_buffer = NULL;
 
-	g_free(zlib_data);
+    g_free(zlib_data);
 }
 
 static guint32 vnc_connection_read_cint(VncConnection *conn)
 {
-	guint32 value = 0;
-	guint8 val;
+    guint32 value = 0;
+    guint8 val;
 
-	val = vnc_connection_read_u8(conn);
-	value = (val & 0x7F);
-	if (!(val & 0x80))
-		return value;
+    val = vnc_connection_read_u8(conn);
+    value = (val & 0x7F);
+    if (!(val & 0x80))
+        return value;
 
-	val = vnc_connection_read_u8(conn);
-	value |= (val & 0x7F) << 7;
+    val = vnc_connection_read_u8(conn);
+    value |= (val & 0x7F) << 7;
 
-	if (!(val & 0x80))
-		return value;
+    if (!(val & 0x80))
+        return value;
 
-	value |= vnc_connection_read_u8(conn) << 14;
+    value |= vnc_connection_read_u8(conn) << 14;
 
-	return value;
+    return value;
 }
 
 static int vnc_connection_tpixel_size(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->fmt.depth == 24)
-		return 3;
-	return priv->fmt.bits_per_pixel / 8;
+    if (priv->fmt.depth == 24)
+        return 3;
+    return priv->fmt.bits_per_pixel / 8;
 }
 
 static void vnc_connection_read_tpixel(VncConnection *conn, guint8 *pixel)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->fmt.depth == 24) {
-		guint32 val;
-		vnc_connection_read(conn, pixel, 3);
-		val = (pixel[0] << priv->fmt.red_shift)
-			| (pixel[1] << priv->fmt.green_shift)
-			| (pixel[2] << priv->fmt.blue_shift);
+    if (priv->fmt.depth == 24) {
+        guint32 val;
+        vnc_connection_read(conn, pixel, 3);
+        val = (pixel[0] << priv->fmt.red_shift)
+            | (pixel[1] << priv->fmt.green_shift)
+            | (pixel[2] << priv->fmt.blue_shift);
 
-		if (priv->fmt.byte_order != G_BYTE_ORDER)
-			val =   (((val >>  0) & 0xFF) << 24) |
-				(((val >>  8) & 0xFF) << 16) |
-				(((val >> 16) & 0xFF) << 8) |
-				(((val >> 24) & 0xFF) << 0);
+        if (priv->fmt.byte_order != G_BYTE_ORDER)
+            val =   (((val >>  0) & 0xFF) << 24) |
+                (((val >>  8) & 0xFF) << 16) |
+                (((val >> 16) & 0xFF) << 8) |
+                (((val >> 24) & 0xFF) << 0);
 
-		memcpy(pixel, &val, 4);
-	} else
-		vnc_connection_read_pixel(conn, pixel);
+        memcpy(pixel, &val, 4);
+    } else
+        vnc_connection_read_pixel(conn, pixel);
 }
 
 static void vnc_connection_tight_update_copy(VncConnection *conn,
-					     guint16 x, guint16 y,
-					     guint16 width, guint16 height)
+                                             guint16 x, guint16 y,
+                                             guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 pixel[4];
-	int i, j;
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 pixel[4];
+    int i, j;
 
-	for (j = 0; j < height; j++) {
-		for (i = 0; i < width; i++) {
-			vnc_connection_read_tpixel(conn, pixel);
-			vnc_framebuffer_set_pixel_at(priv->fb, pixel, x + i, y + j);
-		}
-	}
+    for (j = 0; j < height; j++) {
+        for (i = 0; i < width; i++) {
+            vnc_connection_read_tpixel(conn, pixel);
+            vnc_framebuffer_set_pixel_at(priv->fb, pixel, x + i, y + j);
+        }
+    }
 }
 
 static int vnc_connection_tight_get_pi(VncConnection *conn, guint8 *ra,
-				       int i, guint8 palette_size)
+                                       int i, guint8 palette_size)
 {
-	if (palette_size == 2) {
-		if ((i % 8) == 0)
-			*ra = vnc_connection_read_u8(conn);
-		return (*ra >> (7 - (i % 8))) & 1;
-	}
+    if (palette_size == 2) {
+        if ((i % 8) == 0)
+            *ra = vnc_connection_read_u8(conn);
+        return (*ra >> (7 - (i % 8))) & 1;
+    }
 
-	return vnc_connection_read_u8(conn);
+    return vnc_connection_read_u8(conn);
 }
 
 static void vnc_connection_tight_update_palette(VncConnection *conn,
-						int palette_size, guint8 *palette,
-						guint16 x, guint16 y,
-						guint16 width, guint16 height)
+                                                int palette_size, guint8 *palette,
+                                                guint16 x, guint16 y,
+                                                guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int i, j;
+    VncConnectionPrivate *priv = conn->priv;
+    int i, j;
 
-	for (j = 0; j < height; j++) {
-		guint8 ra = 0;
+    for (j = 0; j < height; j++) {
+        guint8 ra = 0;
 
-		for (i = 0; i < width; i++) {
-			guint8 ind;
+        for (i = 0; i < width; i++) {
+            guint8 ind;
 
-			ind = vnc_connection_tight_get_pi(conn, &ra, i, palette_size);
-			vnc_framebuffer_set_pixel_at(priv->fb, &palette[ind * 4], x + i, y + j);
-		}
-	}
+            ind = vnc_connection_tight_get_pi(conn, &ra, i, palette_size);
+            vnc_framebuffer_set_pixel_at(priv->fb, &palette[ind * 4], x + i, y + j);
+        }
+    }
 }
 
 static void vnc_connection_tight_compute_predicted(VncConnection *conn, guint8 *ppixel,
-						   guint8 *lp, guint8 *cp,
-						   guint8 *llp)
+                                                   guint8 *lp, guint8 *cp,
+                                                   guint8 *llp)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	priv->tight_compute_predicted(conn, ppixel, lp, cp, llp);
+    priv->tight_compute_predicted(conn, ppixel, lp, cp, llp);
 }
 
 static void vnc_connection_tight_sum_pixel(VncConnection *conn,
-					   guint8 *lhs, guint8 *rhs)
+                                           guint8 *lhs, guint8 *rhs)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	priv->tight_sum_pixel(conn, lhs, rhs);
+    priv->tight_sum_pixel(conn, lhs, rhs);
 }
 
 static void vnc_connection_tight_update_gradient(VncConnection *conn,
-						 guint16 x, guint16 y,
-						 guint16 width, guint16 height)
+                                                 guint16 x, guint16 y,
+                                                 guint16 width, guint16 height)
 {
-	int i, j;
-	guint8 zero_pixel[4];
-	guint8 *last_row, *row;
-	int bpp;
-	VncConnectionPrivate *priv = conn->priv;
+    int i, j;
+    guint8 zero_pixel[4];
+    guint8 *last_row, *row;
+    int bpp;
+    VncConnectionPrivate *priv = conn->priv;
 
-	bpp = vnc_connection_pixel_size(conn);
-	last_row = g_malloc(width * bpp);
-	row = g_malloc(width * bpp);
+    bpp = vnc_connection_pixel_size(conn);
+    last_row = g_malloc(width * bpp);
+    row = g_malloc(width * bpp);
 
-	memset(last_row, 0, width * bpp);
-	memset(zero_pixel, 0, 4);
+    memset(last_row, 0, width * bpp);
+    memset(zero_pixel, 0, 4);
 
-	for (j = 0; j < height; j++) {
-		guint8 *tmp_row;
-		guint8 *llp, *lp;
+    for (j = 0; j < height; j++) {
+        guint8 *tmp_row;
+        guint8 *llp, *lp;
 
-		/* use zero pixels for the edge cases */
-		llp = zero_pixel;
-		lp = zero_pixel;
+        /* use zero pixels for the edge cases */
+        llp = zero_pixel;
+        lp = zero_pixel;
 
-		for (i = 0; i < width; i++) {
-			guint8 predicted_pixel[4];
+        for (i = 0; i < width; i++) {
+            guint8 predicted_pixel[4];
 
-			/* compute predicted pixel value */
-			vnc_connection_tight_compute_predicted(conn, predicted_pixel,
-							       lp, last_row + i * bpp,
-							       llp);
+            /* compute predicted pixel value */
+            vnc_connection_tight_compute_predicted(conn, predicted_pixel,
+                                                   lp, last_row + i * bpp,
+                                                   llp);
 
-			/* read the difference pixel from the wire */
-			vnc_connection_read_tpixel(conn, row + i * bpp);
+            /* read the difference pixel from the wire */
+            vnc_connection_read_tpixel(conn, row + i * bpp);
 
-			/* sum the predicted pixel and the difference to get
-			 * the original pixel value */
-			vnc_connection_tight_sum_pixel(conn, row + i * bpp,
-						       predicted_pixel);
+            /* sum the predicted pixel and the difference to get
+             * the original pixel value */
+            vnc_connection_tight_sum_pixel(conn, row + i * bpp,
+                                           predicted_pixel);
 
-			llp = last_row + i * bpp;
-			lp = row + i * bpp;
-		}
+            llp = last_row + i * bpp;
+            lp = row + i * bpp;
+        }
 
-		/* write out row of pixel data */
-		vnc_framebuffer_blt(priv->fb, row, width * bpp, x, y + j, width, 1);
+        /* write out row of pixel data */
+        vnc_framebuffer_blt(priv->fb, row, width * bpp, x, y + j, width, 1);
 
-		/* swap last row and current row */
-		tmp_row = last_row;
-		last_row = row;
-		row = tmp_row;
-	}
+        /* swap last row and current row */
+        tmp_row = last_row;
+        last_row = row;
+        row = tmp_row;
+    }
 
-	g_free(row);
-	g_free(last_row);
+    g_free(row);
+    g_free(last_row);
 }
 
 
 static void vnc_connection_tight_update_jpeg(VncConnection *conn, guint16 x, guint16 y,
-					     guint16 width, guint16 height,
-					     guint8 *data, size_t length)
+                                             guint16 width, guint16 height,
+                                             guint8 *data, size_t length)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
-	GdkPixbuf *p;
+    VncConnectionPrivate *priv = conn->priv;
+    GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
+    GdkPixbuf *p;
 
-	if (!gdk_pixbuf_loader_write(loader, data, length, NULL)) {
-		priv->has_error = TRUE;
-		return;
-	}
+    if (!gdk_pixbuf_loader_write(loader, data, length, NULL)) {
+        priv->has_error = TRUE;
+        return;
+    }
 
-	gdk_pixbuf_loader_close(loader, NULL);
+    gdk_pixbuf_loader_close(loader, NULL);
 
-	p = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
-	g_object_unref(loader);
+    p = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
+    g_object_unref(loader);
 
-	vnc_framebuffer_rgb24_blt(priv->fb,
-				  gdk_pixbuf_get_pixels(p),
-				  gdk_pixbuf_get_rowstride(p),
-				  x, y, width, height);
+    vnc_framebuffer_rgb24_blt(priv->fb,
+                              gdk_pixbuf_get_pixels(p),
+                              gdk_pixbuf_get_rowstride(p),
+                              x, y, width, height);
 
-	g_object_unref(p);
+    g_object_unref(p);
 }
 
 static void vnc_connection_tight_update(VncConnection *conn,
-					guint16 x, guint16 y,
-					guint16 width, guint16 height)
-{
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 ccontrol;
-	guint8 pixel[4];
-	int i;
-
-	ccontrol = vnc_connection_read_u8(conn);
-
-	for (i = 0; i < 4; i++) {
-		if (ccontrol & (1 << i)) {
-			inflateEnd(&priv->streams[i + 1]);
-			inflateInit(&priv->streams[i + 1]);
-		}
-	}
-
-	ccontrol >>= 4;
-	ccontrol &= 0x0F;
-
-	if (ccontrol <= 7) {
-		/* basic */
-		guint8 filter_id = 0;
-		guint32 data_size, zlib_length;
-		guint8 *zlib_data = NULL;
-		guint8 palette[256][4];
-		int palette_size = 0;
-
-		if (ccontrol & 0x04)
-			filter_id = vnc_connection_read_u8(conn);
-
-		priv->strm = &priv->streams[(ccontrol & 0x03) + 1];
-
-		if (filter_id == 1) {
-			palette_size = vnc_connection_read_u8(conn);
-			palette_size += 1;
-			for (i = 0; i < palette_size; i++)
-				vnc_connection_read_tpixel(conn, palette[i]);
-		}
-
-		if (filter_id == 1) {
-			if (palette_size == 2)
-				data_size = ((width + 7) / 8) * height;
-			else
-				data_size = width * height;
-		} else
-			data_size = width * height * vnc_connection_tpixel_size(conn);
-
-		if (data_size >= 12) {
-			zlib_length = vnc_connection_read_cint(conn);
-			zlib_data = g_malloc(zlib_length);
-
-			vnc_connection_read(conn, zlib_data, zlib_length);
-
-			priv->uncompressed_length = 0;
-			priv->compressed_length = zlib_length;
-			priv->compressed_buffer = zlib_data;
-		}
-
-		switch (filter_id) {
-		case 0: /* copy */
-			vnc_connection_tight_update_copy(conn, x, y, width, height);
-			break;
-		case 1: /* palette */
-			vnc_connection_tight_update_palette(conn, palette_size,
-							    (guint8 *)palette,
-							    x, y, width, height);
-			break;
-		case 2: /* gradient */
-			vnc_connection_tight_update_gradient(conn, x, y, width, height);
-			break;
-		default: /* error */
-			VNC_DEBUG("Closing the connection: vnc_connection_tight_update() - filter_id unknown");
-			priv->has_error = TRUE;
-			break;
-		}
-
-		if (data_size >= 12) {
-			priv->uncompressed_length = 0;
-			priv->compressed_length = 0;
-			priv->compressed_buffer = NULL;
-
-			g_free(zlib_data);
-		}
-
-		priv->strm = NULL;
-	} else if (ccontrol == 8) {
-		/* fill */
-		/* FIXME check each width; endianness */
-		vnc_connection_read_tpixel(conn, pixel);
-		vnc_framebuffer_fill(priv->fb, pixel, x, y, width, height);
-	} else if (ccontrol == 9) {
-		/* jpeg */
-		guint32 length;
-		guint8 *jpeg_data;
-
-		length = vnc_connection_read_cint(conn);
-		jpeg_data = g_malloc(length);
-		vnc_connection_read(conn, jpeg_data, length);
-		vnc_connection_tight_update_jpeg(conn, x, y, width, height,
-						 jpeg_data, length);
-		g_free(jpeg_data);
-	} else {
-		/* error */
-		VNC_DEBUG("Closing the connection: vnc_connection_tight_update() - ccontrol unknown");
-		priv->has_error = TRUE;
-	}
+                                        guint16 x, guint16 y,
+                                        guint16 width, guint16 height)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 ccontrol;
+    guint8 pixel[4];
+    int i;
+
+    ccontrol = vnc_connection_read_u8(conn);
+
+    for (i = 0; i < 4; i++) {
+        if (ccontrol & (1 << i)) {
+            inflateEnd(&priv->streams[i + 1]);
+            inflateInit(&priv->streams[i + 1]);
+        }
+    }
+
+    ccontrol >>= 4;
+    ccontrol &= 0x0F;
+
+    if (ccontrol <= 7) {
+        /* basic */
+        guint8 filter_id = 0;
+        guint32 data_size, zlib_length;
+        guint8 *zlib_data = NULL;
+        guint8 palette[256][4];
+        int palette_size = 0;
+
+        if (ccontrol & 0x04)
+            filter_id = vnc_connection_read_u8(conn);
+
+        priv->strm = &priv->streams[(ccontrol & 0x03) + 1];
+
+        if (filter_id == 1) {
+            palette_size = vnc_connection_read_u8(conn);
+            palette_size += 1;
+            for (i = 0; i < palette_size; i++)
+                vnc_connection_read_tpixel(conn, palette[i]);
+        }
+
+        if (filter_id == 1) {
+            if (palette_size == 2)
+                data_size = ((width + 7) / 8) * height;
+            else
+                data_size = width * height;
+        } else
+            data_size = width * height * vnc_connection_tpixel_size(conn);
+
+        if (data_size >= 12) {
+            zlib_length = vnc_connection_read_cint(conn);
+            zlib_data = g_malloc(zlib_length);
+
+            vnc_connection_read(conn, zlib_data, zlib_length);
+
+            priv->uncompressed_length = 0;
+            priv->compressed_length = zlib_length;
+            priv->compressed_buffer = zlib_data;
+        }
+
+        switch (filter_id) {
+        case 0: /* copy */
+            vnc_connection_tight_update_copy(conn, x, y, width, height);
+            break;
+        case 1: /* palette */
+            vnc_connection_tight_update_palette(conn, palette_size,
+                                                (guint8 *)palette,
+                                                x, y, width, height);
+            break;
+        case 2: /* gradient */
+            vnc_connection_tight_update_gradient(conn, x, y, width, height);
+            break;
+        default: /* error */
+            VNC_DEBUG("Closing the connection: vnc_connection_tight_update() - filter_id unknown");
+            priv->has_error = TRUE;
+            break;
+        }
+
+        if (data_size >= 12) {
+            priv->uncompressed_length = 0;
+            priv->compressed_length = 0;
+            priv->compressed_buffer = NULL;
+
+            g_free(zlib_data);
+        }
+
+        priv->strm = NULL;
+    } else if (ccontrol == 8) {
+        /* fill */
+        /* FIXME check each width; endianness */
+        vnc_connection_read_tpixel(conn, pixel);
+        vnc_framebuffer_fill(priv->fb, pixel, x, y, width, height);
+    } else if (ccontrol == 9) {
+        /* jpeg */
+        guint32 length;
+        guint8 *jpeg_data;
+
+        length = vnc_connection_read_cint(conn);
+        jpeg_data = g_malloc(length);
+        vnc_connection_read(conn, jpeg_data, length);
+        vnc_connection_tight_update_jpeg(conn, x, y, width, height,
+                                         jpeg_data, length);
+        g_free(jpeg_data);
+    } else {
+        /* error */
+        VNC_DEBUG("Closing the connection: vnc_connection_tight_update() - ccontrol unknown");
+        priv->has_error = TRUE;
+    }
 }
 
 static void vnc_connection_update(VncConnection *conn, int x, int y, int width, int height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
 
-	if (priv->has_error)
-		return;
+    if (priv->has_error)
+        return;
 
-	VNC_DEBUG("Notify update area (%dx%d) at location %d,%d", width, height, x, y);
+    VNC_DEBUG("Notify update area (%dx%d) at location %d,%d", width, height, x, y);
 
-	sigdata.params.area.x = x;
-	sigdata.params.area.y = y;
-	sigdata.params.area.width = width;
-	sigdata.params.area.height = height;
-	vnc_connection_emit_main_context(conn, VNC_FRAMEBUFFER_UPDATE, &sigdata);
+    sigdata.params.area.x = x;
+    sigdata.params.area.y = y;
+    sigdata.params.area.width = width;
+    sigdata.params.area.height = height;
+    vnc_connection_emit_main_context(conn, VNC_FRAMEBUFFER_UPDATE, &sigdata);
 }
 
 
 static void vnc_connection_bell(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
 
-	if (priv->has_error)
-		return;
+    if (priv->has_error)
+        return;
 
-	VNC_DEBUG("Server beep");
+    VNC_DEBUG("Server beep");
 
-	vnc_connection_emit_main_context(conn, VNC_BELL, &sigdata);
+    vnc_connection_emit_main_context(conn, VNC_BELL, &sigdata);
 }
 
 static void vnc_connection_server_cut_text(VncConnection *conn,
-					   const void *data,
-					   size_t len)
+                                           const void *data,
+                                           size_t len)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
-	GString *text;
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
+    GString *text;
 
-	if (priv->has_error)
-		return;
+    if (priv->has_error)
+        return;
 
-	text = g_string_new_len ((const gchar *)data, len);
-	sigdata.params.text = text->str;
+    text = g_string_new_len ((const gchar *)data, len);
+    sigdata.params.text = text->str;
 
-	vnc_connection_emit_main_context(conn, VNC_SERVER_CUT_TEXT, &sigdata);
+    vnc_connection_emit_main_context(conn, VNC_SERVER_CUT_TEXT, &sigdata);
 
-	g_string_free(text, TRUE);
+    g_string_free(text, TRUE);
 }
 
 static void vnc_connection_resize(VncConnection *conn, int width, int height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
 
-	if (priv->has_error)
-		return;
+    if (priv->has_error)
+        return;
 
-	priv->width = width;
-	priv->height = height;
+    priv->width = width;
+    priv->height = height;
 
-	sigdata.params.size.width = width;
-	sigdata.params.size.height = height;
-	vnc_connection_emit_main_context(conn, VNC_DESKTOP_RESIZE, &sigdata);
+    sigdata.params.size.width = width;
+    sigdata.params.size.height = height;
+    vnc_connection_emit_main_context(conn, VNC_DESKTOP_RESIZE, &sigdata);
 }
 
 static void vnc_connection_pixel_format(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
 
-        if (priv->has_error)
-                return;
+    if (priv->has_error)
+        return;
 
-	sigdata.params.pixelFormat = &priv->fmt;
-	vnc_connection_emit_main_context(conn, VNC_PIXEL_FORMAT_CHANGED, &sigdata);
+    sigdata.params.pixelFormat = &priv->fmt;
+    vnc_connection_emit_main_context(conn, VNC_PIXEL_FORMAT_CHANGED, &sigdata);
 }
 
 static void vnc_connection_pointer_type_change(VncConnection *conn, gboolean absPointer)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
 
-	if (priv->absPointer == absPointer)
-		return;
-	priv->absPointer = absPointer;
+    if (priv->absPointer == absPointer)
+        return;
+    priv->absPointer = absPointer;
 
-	if (priv->has_error)
-		return;
+    if (priv->has_error)
+        return;
 
-	sigdata.params.absPointer = absPointer;
-	vnc_connection_emit_main_context(conn, VNC_POINTER_MODE_CHANGED, &sigdata);
+    sigdata.params.absPointer = absPointer;
+    vnc_connection_emit_main_context(conn, VNC_POINTER_MODE_CHANGED, &sigdata);
 }
 
 static void vnc_connection_rich_cursor_blt(VncConnection *conn, guint8 *pixbuf,
-					   guint8 *image, guint8 *mask,
-					   int pitch, guint16 width, guint16 height)
+                                           guint8 *image, guint8 *mask,
+                                           int pitch, guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	priv->rich_cursor_blt(conn, pixbuf, image, mask, pitch, width, height);
+    priv->rich_cursor_blt(conn, pixbuf, image, mask, pitch, width, height);
 }
 
 static void vnc_connection_rich_cursor(VncConnection *conn, int x, int y, int width, int height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
 
-	if (priv->cursor) {
-		g_object_unref(priv->cursor);
-		priv->cursor = NULL;
-	}
+    if (priv->cursor) {
+        g_object_unref(priv->cursor);
+        priv->cursor = NULL;
+    }
 
-	if (width && height) {
-		guint8 *pixbuf = NULL;
-		guint8 *image = NULL, *mask = NULL;
-		int imagelen, masklen;
+    if (width && height) {
+        guint8 *pixbuf = NULL;
+        guint8 *image = NULL, *mask = NULL;
+        int imagelen, masklen;
 
-		imagelen = width * height * (priv->fmt.bits_per_pixel / 8);
-		masklen = ((width + 7)/8) * height;
+        imagelen = width * height * (priv->fmt.bits_per_pixel / 8);
+        masklen = ((width + 7)/8) * height;
 
-		image = g_malloc(imagelen);
-		mask = g_malloc(masklen);
-		pixbuf = g_malloc(width * height * 4); /* RGB-A 8bit */
+        image = g_malloc(imagelen);
+        mask = g_malloc(masklen);
+        pixbuf = g_malloc(width * height * 4); /* RGB-A 8bit */
 
-		vnc_connection_read(conn, image, imagelen);
-		vnc_connection_read(conn, mask, masklen);
+        vnc_connection_read(conn, image, imagelen);
+        vnc_connection_read(conn, mask, masklen);
 
-		vnc_connection_rich_cursor_blt(conn, pixbuf, image, mask,
-					       width * (priv->fmt.bits_per_pixel/8),
-					       width, height);
+        vnc_connection_rich_cursor_blt(conn, pixbuf, image, mask,
+                                       width * (priv->fmt.bits_per_pixel/8),
+                                       width, height);
 
-		g_free(image);
-		g_free(mask);
+        g_free(image);
+        g_free(mask);
 
-		priv->cursor = vnc_cursor_new(pixbuf, x, y, width, height);
-	}
+        priv->cursor = vnc_cursor_new(pixbuf, x, y, width, height);
+    }
 
-	if (priv->has_error)
-		return;
+    if (priv->has_error)
+        return;
 
-	sigdata.params.cursor = priv->cursor;
+    sigdata.params.cursor = priv->cursor;
 
-	vnc_connection_emit_main_context(conn, VNC_CURSOR_CHANGED, &sigdata);
+    vnc_connection_emit_main_context(conn, VNC_CURSOR_CHANGED, &sigdata);
 }
 
 static void vnc_connection_xcursor(VncConnection *conn, int x, int y, int width, int height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
-
-	if (priv->cursor) {
-		g_object_unref(priv->cursor);
-		priv->cursor = NULL;
-	}
-
-	if (width && height) {
-		guint8 *pixbuf = NULL;
-		guint8 *data, *mask, *datap, *maskp;
-		guint32 *pixp;
-		int rowlen;
-		int x1, y1;
-		guint8 fgrgb[3], bgrgb[3];
-		guint32 fg, bg;
-		vnc_connection_read(conn, fgrgb, 3);
-		vnc_connection_read(conn, bgrgb, 3);
-		fg = (255 << 24) | (fgrgb[0] << 16) | (fgrgb[1] << 8) | fgrgb[2];
-		bg = (255 << 24) | (bgrgb[0] << 16) | (bgrgb[1] << 8) | bgrgb[2];
-
-		rowlen = ((width + 7)/8);
-		data = g_malloc(rowlen*height);
-		mask = g_malloc(rowlen*height);
-		pixbuf = g_malloc(width * height * 4); /* RGB-A 8bit */
-
-		vnc_connection_read(conn, data, rowlen*height);
-		vnc_connection_read(conn, mask, rowlen*height);
-		datap = data;
-		maskp = mask;
-		pixp = (guint32*)pixbuf;
-		for (y1 = 0; y1 < height; y1++) {
-			for (x1 = 0; x1 < width; x1++) {
-				*pixp++ = ((maskp[x1 / 8] >> (7-(x1 % 8))) & 1) ?
-					(((datap[x1 / 8] >> (7-(x1 % 8))) & 1) ? fg : bg) : 0;
-			}
-			datap += rowlen;
-			maskp += rowlen;
-		}
-		g_free(data);
-		g_free(mask);
-
-		priv->cursor = vnc_cursor_new(pixbuf, x, y, width, height);
-	}
-
-	if (priv->has_error)
-		return;
-
-	sigdata.params.cursor = priv->cursor;
-
-	vnc_connection_emit_main_context(conn, VNC_CURSOR_CHANGED, &sigdata);
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
+
+    if (priv->cursor) {
+        g_object_unref(priv->cursor);
+        priv->cursor = NULL;
+    }
+
+    if (width && height) {
+        guint8 *pixbuf = NULL;
+        guint8 *data, *mask, *datap, *maskp;
+        guint32 *pixp;
+        int rowlen;
+        int x1, y1;
+        guint8 fgrgb[3], bgrgb[3];
+        guint32 fg, bg;
+        vnc_connection_read(conn, fgrgb, 3);
+        vnc_connection_read(conn, bgrgb, 3);
+        fg = (255 << 24) | (fgrgb[0] << 16) | (fgrgb[1] << 8) | fgrgb[2];
+        bg = (255 << 24) | (bgrgb[0] << 16) | (bgrgb[1] << 8) | bgrgb[2];
+
+        rowlen = ((width + 7)/8);
+        data = g_malloc(rowlen*height);
+        mask = g_malloc(rowlen*height);
+        pixbuf = g_malloc(width * height * 4); /* RGB-A 8bit */
+
+        vnc_connection_read(conn, data, rowlen*height);
+        vnc_connection_read(conn, mask, rowlen*height);
+        datap = data;
+        maskp = mask;
+        pixp = (guint32*)pixbuf;
+        for (y1 = 0; y1 < height; y1++) {
+            for (x1 = 0; x1 < width; x1++) {
+                *pixp++ = ((maskp[x1 / 8] >> (7-(x1 % 8))) & 1) ?
+                    (((datap[x1 / 8] >> (7-(x1 % 8))) & 1) ? fg : bg) : 0;
+            }
+            datap += rowlen;
+            maskp += rowlen;
+        }
+        g_free(data);
+        g_free(mask);
+
+        priv->cursor = vnc_cursor_new(pixbuf, x, y, width, height);
+    }
+
+    if (priv->has_error)
+        return;
+
+    sigdata.params.cursor = priv->cursor;
+
+    vnc_connection_emit_main_context(conn, VNC_CURSOR_CHANGED, &sigdata);
 }
 
 static void vnc_connection_ext_key_event(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	priv->has_ext_key_event = TRUE;
+    priv->has_ext_key_event = TRUE;
 }
 
 
 static gboolean vnc_connection_validate_boundary(VncConnection *conn,
-						 guint16 x, guint16 y,
-						 guint16 width, guint16 height)
+                                                 guint16 x, guint16 y,
+                                                 guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if ((x + width) > priv->width || (y + height) > priv->height) {
-		VNC_DEBUG("Framebuffer update %dx%d at %d,%d outside boundary %dx%d",
-			  width, height, x, y, priv->width, priv->height);
-		priv->has_error = TRUE;
-	}
+    if ((x + width) > priv->width || (y + height) > priv->height) {
+        VNC_DEBUG("Framebuffer update %dx%d at %d,%d outside boundary %dx%d",
+                  width, height, x, y, priv->width, priv->height);
+        priv->has_error = TRUE;
+    }
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 static gboolean vnc_connection_framebuffer_update(VncConnection *conn, gint32 etype,
-						  guint16 x, guint16 y,
-						  guint16 width, guint16 height)
-{
-	VncConnectionPrivate *priv = conn->priv;
-
-	VNC_DEBUG("FramebufferUpdate type=%d area (%dx%d) at location %d,%d",
-		   etype, width, height, x, y);
-
-	if (vnc_connection_has_error(conn))
-		return !vnc_connection_has_error(conn);
-
-	switch (etype) {
-	case VNC_CONNECTION_ENCODING_RAW:
-		if (!vnc_connection_validate_boundary(conn, x, y, width, height))
-			break;
-		vnc_connection_raw_update(conn, x, y, width, height);
-		vnc_connection_update(conn, x, y, width, height);
-		break;
-	case VNC_CONNECTION_ENCODING_COPY_RECT:
-		if (!vnc_connection_validate_boundary(conn, x, y, width, height))
-			break;
-		vnc_connection_copyrect_update(conn, x, y, width, height);
-		vnc_connection_update(conn, x, y, width, height);
-		break;
-	case VNC_CONNECTION_ENCODING_RRE:
-		if (!vnc_connection_validate_boundary(conn, x, y, width, height))
-			break;
-		vnc_connection_rre_update(conn, x, y, width, height);
-		vnc_connection_update(conn, x, y, width, height);
-		break;
-	case VNC_CONNECTION_ENCODING_HEXTILE:
-		if (!vnc_connection_validate_boundary(conn, x, y, width, height))
-			break;
-		vnc_connection_hextile_update(conn, x, y, width, height);
-		vnc_connection_update(conn, x, y, width, height);
-		break;
-	case VNC_CONNECTION_ENCODING_ZRLE:
-		if (!vnc_connection_validate_boundary(conn, x, y, width, height))
-			break;
-		vnc_connection_zrle_update(conn, x, y, width, height);
-		vnc_connection_update(conn, x, y, width, height);
-		break;
-	case VNC_CONNECTION_ENCODING_TIGHT:
-		if (!vnc_connection_validate_boundary(conn, x, y, width, height))
-			break;
-		vnc_connection_tight_update(conn, x, y, width, height);
-		vnc_connection_update(conn, x, y, width, height);
-		break;
-	case VNC_CONNECTION_ENCODING_DESKTOP_RESIZE:
-		vnc_connection_resize(conn, width, height);
-		break;
-	case VNC_CONNECTION_ENCODING_POINTER_CHANGE:
-		vnc_connection_pointer_type_change(conn, x);
-		vnc_connection_resend_framebuffer_update_request(conn);
-		break;
-        case VNC_CONNECTION_ENCODING_WMVi:
-                vnc_connection_read_pixel_format(conn, &priv->fmt);
-                vnc_connection_pixel_format(conn);
-                break;
-	case VNC_CONNECTION_ENCODING_RICH_CURSOR:
-		vnc_connection_rich_cursor(conn, x, y, width, height);
-		vnc_connection_resend_framebuffer_update_request(conn);
-		break;
-	case VNC_CONNECTION_ENCODING_XCURSOR:
-		vnc_connection_xcursor(conn, x, y, width, height);
-		vnc_connection_resend_framebuffer_update_request(conn);
-		break;
-	case VNC_CONNECTION_ENCODING_EXT_KEY_EVENT:
-		vnc_connection_ext_key_event(conn);
-		vnc_connection_resend_framebuffer_update_request(conn);
-		break;
-	case VNC_CONNECTION_ENCODING_AUDIO:
-		priv->has_audio=TRUE;
-
-		if (priv->audio_disable_pending)
-			vnc_connection_audio_disable(conn);
-		if (priv->audio_format_pending)
-			vnc_connection_send_audio_format(conn);
-		if (priv->audio_enable_pending)
-			vnc_connection_audio_enable(conn);
-		break;
-	default:
-		VNC_DEBUG("Received an unknown encoding type: %d", etype);
-		priv->has_error = TRUE;
-		break;
-	}
-
-	return !vnc_connection_has_error(conn);
+                                                  guint16 x, guint16 y,
+                                                  guint16 width, guint16 height)
+{
+    VncConnectionPrivate *priv = conn->priv;
+
+    VNC_DEBUG("FramebufferUpdate type=%d area (%dx%d) at location %d,%d",
+              etype, width, height, x, y);
+
+    if (vnc_connection_has_error(conn))
+        return !vnc_connection_has_error(conn);
+
+    switch (etype) {
+    case VNC_CONNECTION_ENCODING_RAW:
+        if (!vnc_connection_validate_boundary(conn, x, y, width, height))
+            break;
+        vnc_connection_raw_update(conn, x, y, width, height);
+        vnc_connection_update(conn, x, y, width, height);
+        break;
+    case VNC_CONNECTION_ENCODING_COPY_RECT:
+        if (!vnc_connection_validate_boundary(conn, x, y, width, height))
+            break;
+        vnc_connection_copyrect_update(conn, x, y, width, height);
+        vnc_connection_update(conn, x, y, width, height);
+        break;
+    case VNC_CONNECTION_ENCODING_RRE:
+        if (!vnc_connection_validate_boundary(conn, x, y, width, height))
+            break;
+        vnc_connection_rre_update(conn, x, y, width, height);
+        vnc_connection_update(conn, x, y, width, height);
+        break;
+    case VNC_CONNECTION_ENCODING_HEXTILE:
+        if (!vnc_connection_validate_boundary(conn, x, y, width, height))
+            break;
+        vnc_connection_hextile_update(conn, x, y, width, height);
+        vnc_connection_update(conn, x, y, width, height);
+        break;
+    case VNC_CONNECTION_ENCODING_ZRLE:
+        if (!vnc_connection_validate_boundary(conn, x, y, width, height))
+            break;
+        vnc_connection_zrle_update(conn, x, y, width, height);
+        vnc_connection_update(conn, x, y, width, height);
+        break;
+    case VNC_CONNECTION_ENCODING_TIGHT:
+        if (!vnc_connection_validate_boundary(conn, x, y, width, height))
+            break;
+        vnc_connection_tight_update(conn, x, y, width, height);
+        vnc_connection_update(conn, x, y, width, height);
+        break;
+    case VNC_CONNECTION_ENCODING_DESKTOP_RESIZE:
+        vnc_connection_resize(conn, width, height);
+        break;
+    case VNC_CONNECTION_ENCODING_POINTER_CHANGE:
+        vnc_connection_pointer_type_change(conn, x);
+        vnc_connection_resend_framebuffer_update_request(conn);
+        break;
+    case VNC_CONNECTION_ENCODING_WMVi:
+        vnc_connection_read_pixel_format(conn, &priv->fmt);
+        vnc_connection_pixel_format(conn);
+        break;
+    case VNC_CONNECTION_ENCODING_RICH_CURSOR:
+        vnc_connection_rich_cursor(conn, x, y, width, height);
+        vnc_connection_resend_framebuffer_update_request(conn);
+        break;
+    case VNC_CONNECTION_ENCODING_XCURSOR:
+        vnc_connection_xcursor(conn, x, y, width, height);
+        vnc_connection_resend_framebuffer_update_request(conn);
+        break;
+    case VNC_CONNECTION_ENCODING_EXT_KEY_EVENT:
+        vnc_connection_ext_key_event(conn);
+        vnc_connection_resend_framebuffer_update_request(conn);
+        break;
+    case VNC_CONNECTION_ENCODING_AUDIO:
+        priv->has_audio=TRUE;
+
+        if (priv->audio_disable_pending)
+            vnc_connection_audio_disable(conn);
+        if (priv->audio_format_pending)
+            vnc_connection_send_audio_format(conn);
+        if (priv->audio_enable_pending)
+            vnc_connection_audio_enable(conn);
+        break;
+    default:
+        VNC_DEBUG("Received an unknown encoding type: %d", etype);
+        priv->has_error = TRUE;
+        break;
+    }
+
+    return !vnc_connection_has_error(conn);
 }
 
 
 static gboolean vnc_connection_audio_timer(gpointer opaque)
 {
-	VncConnection *conn = opaque;
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnection *conn = opaque;
+    VncConnectionPrivate *priv = conn->priv;
 
-	priv->audio_timer = 0;
-	if (!priv->audio_sample)
-		return FALSE;
+    priv->audio_timer = 0;
+    if (!priv->audio_sample)
+        return FALSE;
 
-	VNC_DEBUG("Audio tick %u\n", priv->audio_sample->length);
+    VNC_DEBUG("Audio tick %u\n", priv->audio_sample->length);
 
-	if (priv->audio)
-		vnc_audio_playback_data(priv->audio, priv->audio_sample);
+    if (priv->audio)
+        vnc_audio_playback_data(priv->audio, priv->audio_sample);
 
-	vnc_audio_sample_free(priv->audio_sample);
-	priv->audio_sample = NULL;
-	return FALSE;
+    vnc_audio_sample_free(priv->audio_sample);
+    priv->audio_sample = NULL;
+    return FALSE;
 }
 
 
 struct audio_action_data
 {
-	VncConnection *conn;
-	struct coroutine *caller;
-	int action;
+    VncConnection *conn;
+    struct coroutine *caller;
+    int action;
 };
 
 static gboolean do_vnc_connection_audio_action(gpointer opaque)
 {
-	struct audio_action_data *data = opaque;
-	VncConnectionPrivate *priv = data->conn->priv;
+    struct audio_action_data *data = opaque;
+    VncConnectionPrivate *priv = data->conn->priv;
 
-	VNC_DEBUG("Audio action main context %d", data->action);
+    VNC_DEBUG("Audio action main context %d", data->action);
 
-	switch (data->action) {
-	case 0:
-		vnc_audio_playback_stop(priv->audio);
-		break;
-	case 1:
-		vnc_audio_playback_start(priv->audio, &priv->audio_format);
-		break;
-	case 2:
-		vnc_audio_playback_data(priv->audio, priv->audio_sample);
-		break;
-	}
+    switch (data->action) {
+    case 0:
+        vnc_audio_playback_stop(priv->audio);
+        break;
+    case 1:
+        vnc_audio_playback_start(priv->audio, &priv->audio_format);
+        break;
+    case 2:
+        vnc_audio_playback_data(priv->audio, priv->audio_sample);
+        break;
+    }
 
-	coroutine_yieldto(data->caller, NULL);
-	return FALSE;
+    coroutine_yieldto(data->caller, NULL);
+    return FALSE;
 }
 
 static void vnc_connection_audio_action(VncConnection *conn,
-					int action)
+                                        int action)
 {
-	struct audio_action_data data = {
-		conn,
-		coroutine_self(),
-		action,
-	};
+    struct audio_action_data data = {
+        conn,
+        coroutine_self(),
+        action,
+    };
 
-	VNC_DEBUG("Emit audio action %d\n", action);
+    VNC_DEBUG("Emit audio action %d\n", action);
 
-	g_idle_add(do_vnc_connection_audio_action, &data);
+    g_idle_add(do_vnc_connection_audio_action, &data);
 
-	/* This switches to the system coroutine context, lets
-	 * the idle function run to dispatch the action, and
-	 * finally returns once complete. ie this is synchronous
-	 * from the POV of the VNC coroutine despite there being
-	 * an idle function involved
-	 */
-	coroutine_yield(NULL);
+    /* This switches to the system coroutine context, lets
+     * the idle function run to dispatch the action, and
+     * finally returns once complete. ie this is synchronous
+     * from the POV of the VNC coroutine despite there being
+     * an idle function involved
+     */
+    coroutine_yield(NULL);
 }
 
 
 static gboolean vnc_connection_server_message(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 msg;
-	int ret;
-
-	if (vnc_connection_has_error(conn))
-		return !vnc_connection_has_error(conn);
-
-	/* NB: make sure that all server message functions
-	   handle has_error appropriately */
-
-	do {
-		if (priv->xmit_buffer_size) {
-			vnc_connection_write(conn, priv->xmit_buffer, priv->xmit_buffer_size);
-			vnc_connection_flush(conn);
-			priv->xmit_buffer_size = 0;
-		}
-	} while ((ret = vnc_connection_read_u8_interruptable(conn, &msg)) == -EAGAIN);
-
-	if (ret < 0) {
-		VNC_DEBUG("Aborting message processing on error");
-		return !vnc_connection_has_error(conn);
-	}
-
-	switch (msg) {
-	case 0: { /* FramebufferUpdate */
-		guint8 pad[1];
-		guint16 n_rects;
-		int i;
-
-		vnc_connection_read(conn, pad, 1);
-		n_rects = vnc_connection_read_u16(conn);
-		for (i = 0; i < n_rects; i++) {
-			guint16 x, y, w, h;
-			gint32 etype;
-
-			x = vnc_connection_read_u16(conn);
-			y = vnc_connection_read_u16(conn);
-			w = vnc_connection_read_u16(conn);
-			h = vnc_connection_read_u16(conn);
-			etype = vnc_connection_read_s32(conn);
-
-			if (!vnc_connection_framebuffer_update(conn, etype, x, y, w, h))
-				break;
-		}
-	}	break;
-	case 1: { /* SetColorMapEntries */
-		guint16 first_color;
-		guint16 n_colors;
-		guint8 pad[1];
-		VncColorMap *map;
-		int i;
-
-		vnc_connection_read(conn, pad, 1);
-		first_color = vnc_connection_read_u16(conn);
-		n_colors = vnc_connection_read_u16(conn);
-
-		VNC_DEBUG("Colour map from %d with %d entries",
-			  first_color, n_colors);
-		map = vnc_color_map_new(first_color, n_colors);
-
-		for (i = 0; i < n_colors; i++) {
-			guint16 red, green, blue;
-
-			red = vnc_connection_read_u16(conn);
-			green = vnc_connection_read_u16(conn);
-			blue = vnc_connection_read_u16(conn);
-
-			vnc_color_map_set(map, 
-					  i + first_color,
-					  red, green, blue);
-		}
-
-		vnc_framebuffer_set_color_map(priv->fb, map);
-		vnc_color_map_free(map);
-	}	break;
-	case 2: /* Bell */
-		vnc_connection_bell(conn);
-		break;
-	case 3: { /* ServerCutText */
-		guint8 pad[3];
-		guint32 n_text;
-		char *data;
-
-		vnc_connection_read(conn, pad, 3);
-		n_text = vnc_connection_read_u32(conn);
-		if (n_text > (32 << 20)) {
-			VNC_DEBUG("Closing the connection: vnc_connection_server_message() - cutText > allowed");
-			priv->has_error = TRUE;
-			break;
-		}
-
-		data = g_new(char, n_text + 1);
-		if (data == NULL) {
-			VNC_DEBUG("Closing the connection: vnc_connection_server_message() - cutText - !data");
-			priv->has_error = TRUE;
-			break;
-		}
-
-		vnc_connection_read(conn, data, n_text);
-		data[n_text] = 0;
-
-		vnc_connection_server_cut_text(conn, data, n_text);
-		g_free(data);
-	}	break;
-	case 255: { /* QEMU Messages */
-		guint8  n_type;
-
-		n_type = vnc_connection_read_u8(conn);
-
-		if (priv->has_error)
-			break;
-
-		switch (n_type) {
-		case 1: { /* QEMU audio */
-			guint16 n_subtype;
-			guint32 n_length;
-
-			n_subtype = vnc_connection_read_u16(conn);
-			switch (n_subtype) {
-			case 2:
-				n_length = vnc_connection_read_u32(conn);
-				if (n_length > (1024*1024)) {
-					VNC_DEBUG("Received audio message that is too large %u", n_length);
-					priv->has_error = TRUE;
-					break;
-				}
-				if (priv->has_error)
-					break;
-
-				if (!priv->audio) {
-					VNC_DEBUG("No audio playback available");
-					priv->has_error = TRUE;
-					break;
-				}
-				if (priv->audio_sample &&
-				    ((priv->audio_sample->capacity - priv->audio_sample->length) < n_length)) {
-					g_source_remove(priv->audio_timer);
-					fprintf(stderr, "%u %u %u\n",
-						priv->audio_sample->capacity,
-						priv->audio_sample->length,
-						n_length);
-					vnc_connection_audio_action(conn, 2);
-					vnc_audio_sample_free(priv->audio_sample);
-					priv->audio_sample = NULL;
-				}
-				if (!priv->audio_sample) {
-					priv->audio_sample = vnc_audio_sample_new(1024*1024);
-					priv->audio_timer = g_timeout_add(50,
-									  vnc_connection_audio_timer,
-									  conn);
-				}
-
-				vnc_connection_read(conn,
-						    priv->audio_sample->data + priv->audio_sample->length,
-						    n_length);
-				priv->audio_sample->length += n_length;
-				break;
-			case 1:
-				if (priv->audio)
-					vnc_connection_audio_action(conn, 1);
-				else
-					priv->has_error = TRUE;
-				break;
-			case 0:
-				if (priv->audio) {
-					if (priv->audio_sample) {
-						g_source_remove(priv->audio_timer);
-						vnc_connection_audio_action(conn, 2);
-						vnc_audio_sample_free(priv->audio_sample);
-						priv->audio_sample = NULL;
-					}
-					vnc_connection_audio_action(conn, 0);
-				} else {
-					priv->has_error = TRUE;
-				}
-				break;
-			default:
-				VNC_DEBUG("Received unknown QEMU audio message: %u", (int)n_subtype);
-				priv->has_error = TRUE;
-				break;
-			}
-		}       break;
-		default:
-			VNC_DEBUG("Received an unknown QEMU message: %u", n_type);
-			priv->has_error = TRUE;
-		}
-	} break;
-	default:
-		VNC_DEBUG("Received an unknown message: %u", msg);
-		priv->has_error = TRUE;
-		break;
-	}
-
-	return !vnc_connection_has_error(conn);
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 msg;
+    int ret;
+
+    if (vnc_connection_has_error(conn))
+        return !vnc_connection_has_error(conn);
+
+    /* NB: make sure that all server message functions
+       handle has_error appropriately */
+
+    do {
+        if (priv->xmit_buffer_size) {
+            vnc_connection_write(conn, priv->xmit_buffer, priv->xmit_buffer_size);
+            vnc_connection_flush(conn);
+            priv->xmit_buffer_size = 0;
+        }
+    } while ((ret = vnc_connection_read_u8_interruptable(conn, &msg)) == -EAGAIN);
+
+    if (ret < 0) {
+        VNC_DEBUG("Aborting message processing on error");
+        return !vnc_connection_has_error(conn);
+    }
+
+    switch (msg) {
+    case 0: { /* FramebufferUpdate */
+        guint8 pad[1];
+        guint16 n_rects;
+        int i;
+
+        vnc_connection_read(conn, pad, 1);
+        n_rects = vnc_connection_read_u16(conn);
+        for (i = 0; i < n_rects; i++) {
+            guint16 x, y, w, h;
+            gint32 etype;
+
+            x = vnc_connection_read_u16(conn);
+            y = vnc_connection_read_u16(conn);
+            w = vnc_connection_read_u16(conn);
+            h = vnc_connection_read_u16(conn);
+            etype = vnc_connection_read_s32(conn);
+
+            if (!vnc_connection_framebuffer_update(conn, etype, x, y, w, h))
+                break;
+        }
+    }        break;
+    case 1: { /* SetColorMapEntries */
+        guint16 first_color;
+        guint16 n_colors;
+        guint8 pad[1];
+        VncColorMap *map;
+        int i;
+
+        vnc_connection_read(conn, pad, 1);
+        first_color = vnc_connection_read_u16(conn);
+        n_colors = vnc_connection_read_u16(conn);
+
+        VNC_DEBUG("Colour map from %d with %d entries",
+                  first_color, n_colors);
+        map = vnc_color_map_new(first_color, n_colors);
+
+        for (i = 0; i < n_colors; i++) {
+            guint16 red, green, blue;
+
+            red = vnc_connection_read_u16(conn);
+            green = vnc_connection_read_u16(conn);
+            blue = vnc_connection_read_u16(conn);
+
+            vnc_color_map_set(map, 
+                              i + first_color,
+                              red, green, blue);
+        }
+
+        vnc_framebuffer_set_color_map(priv->fb, map);
+        vnc_color_map_free(map);
+    }        break;
+    case 2: /* Bell */
+        vnc_connection_bell(conn);
+        break;
+    case 3: { /* ServerCutText */
+        guint8 pad[3];
+        guint32 n_text;
+        char *data;
+
+        vnc_connection_read(conn, pad, 3);
+        n_text = vnc_connection_read_u32(conn);
+        if (n_text > (32 << 20)) {
+            VNC_DEBUG("Closing the connection: vnc_connection_server_message() - cutText > allowed");
+            priv->has_error = TRUE;
+            break;
+        }
+
+        data = g_new(char, n_text + 1);
+        if (data == NULL) {
+            VNC_DEBUG("Closing the connection: vnc_connection_server_message() - cutText - !data");
+            priv->has_error = TRUE;
+            break;
+        }
+
+        vnc_connection_read(conn, data, n_text);
+        data[n_text] = 0;
+
+        vnc_connection_server_cut_text(conn, data, n_text);
+        g_free(data);
+    }        break;
+    case 255: { /* QEMU Messages */
+        guint8  n_type;
+
+        n_type = vnc_connection_read_u8(conn);
+
+        if (priv->has_error)
+            break;
+
+        switch (n_type) {
+        case 1: { /* QEMU audio */
+            guint16 n_subtype;
+            guint32 n_length;
+
+            n_subtype = vnc_connection_read_u16(conn);
+            switch (n_subtype) {
+            case 2:
+                n_length = vnc_connection_read_u32(conn);
+                if (n_length > (1024*1024)) {
+                    VNC_DEBUG("Received audio message that is too large %u", n_length);
+                    priv->has_error = TRUE;
+                    break;
+                }
+                if (priv->has_error)
+                    break;
+
+                if (!priv->audio) {
+                    VNC_DEBUG("No audio playback available");
+                    priv->has_error = TRUE;
+                    break;
+                }
+                if (priv->audio_sample &&
+                    ((priv->audio_sample->capacity - priv->audio_sample->length) < n_length)) {
+                    g_source_remove(priv->audio_timer);
+                    fprintf(stderr, "%u %u %u\n",
+                            priv->audio_sample->capacity,
+                            priv->audio_sample->length,
+                            n_length);
+                    vnc_connection_audio_action(conn, 2);
+                    vnc_audio_sample_free(priv->audio_sample);
+                    priv->audio_sample = NULL;
+                }
+                if (!priv->audio_sample) {
+                    priv->audio_sample = vnc_audio_sample_new(1024*1024);
+                    priv->audio_timer = g_timeout_add(50,
+                                                      vnc_connection_audio_timer,
+                                                      conn);
+                }
+
+                vnc_connection_read(conn,
+                                    priv->audio_sample->data + priv->audio_sample->length,
+                                    n_length);
+                priv->audio_sample->length += n_length;
+                break;
+            case 1:
+                if (priv->audio)
+                    vnc_connection_audio_action(conn, 1);
+                else
+                    priv->has_error = TRUE;
+                break;
+            case 0:
+                if (priv->audio) {
+                    if (priv->audio_sample) {
+                        g_source_remove(priv->audio_timer);
+                        vnc_connection_audio_action(conn, 2);
+                        vnc_audio_sample_free(priv->audio_sample);
+                        priv->audio_sample = NULL;
+                    }
+                    vnc_connection_audio_action(conn, 0);
+                } else {
+                    priv->has_error = TRUE;
+                }
+                break;
+            default:
+                VNC_DEBUG("Received unknown QEMU audio message: %u", (int)n_subtype);
+                priv->has_error = TRUE;
+                break;
+            }
+        }       break;
+        default:
+            VNC_DEBUG("Received an unknown QEMU message: %u", n_type);
+            priv->has_error = TRUE;
+        }
+    } break;
+    default:
+        VNC_DEBUG("Received an unknown message: %u", msg);
+        priv->has_error = TRUE;
+        break;
+    }
+
+    return !vnc_connection_has_error(conn);
 }
 
 static gboolean vnc_connection_has_credentials(gpointer data)
 {
-	VncConnection *conn = data;
-	VncConnectionPrivate *priv = conn->priv;
-
-	if (priv->has_error)
-		return TRUE;
-	if (priv->want_cred_username && !priv->cred_username)
-		return FALSE;
-	if (priv->want_cred_password && !priv->cred_password)
-		return FALSE;
-	/*
-	 * For x509 we require a minimum of the CA cert.
-	 * Anything else is a bonus - though the server
-	 * may reject auth if it decides it wants a client
-	 * cert. We can't express that based on auth type
-	 * alone though - we'll merely find out when TLS
-	 * negotiation takes place.
-	 */
-	if (priv->want_cred_x509 && !priv->cred_x509_cacert)
-		return FALSE;
-	return TRUE;
+    VncConnection *conn = data;
+    VncConnectionPrivate *priv = conn->priv;
+
+    if (priv->has_error)
+        return TRUE;
+    if (priv->want_cred_username && !priv->cred_username)
+        return FALSE;
+    if (priv->want_cred_password && !priv->cred_password)
+        return FALSE;
+    /*
+     * For x509 we require a minimum of the CA cert.
+     * Anything else is a bonus - though the server
+     * may reject auth if it decides it wants a client
+     * cert. We can't express that based on auth type
+     * alone though - we'll merely find out when TLS
+     * negotiation takes place.
+     */
+    if (priv->want_cred_x509 && !priv->cred_x509_cacert)
+        return FALSE;
+    return TRUE;
 }
 
 static gboolean vnc_connection_gather_credentials(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-
-	if (priv->has_error)
-		return FALSE;
-
-	if (!vnc_connection_has_credentials(conn)) {
-		GValueArray *authCred;
-		GValue username, password, clientname;
-		struct signal_data sigdata;
-
-		memset(&username, 0, sizeof(username));
-		memset(&password, 0, sizeof(password));
-		memset(&clientname, 0, sizeof(clientname));
-
-		authCred = g_value_array_new(0);
-		if (priv->want_cred_username) {
-			g_value_init(&username, VNC_TYPE_CONNECTION_CREDENTIAL);
-			g_value_set_enum(&username, VNC_CONNECTION_CREDENTIAL_USERNAME);
-			authCred = g_value_array_append(authCred, &username);
-		}
-		if (priv->want_cred_password) {
-			g_value_init(&password, VNC_TYPE_CONNECTION_CREDENTIAL);
-			g_value_set_enum(&password, VNC_CONNECTION_CREDENTIAL_PASSWORD);
-			authCred = g_value_array_append(authCred, &password);
-		}
-		if (priv->want_cred_x509) {
-			g_value_init(&clientname, VNC_TYPE_CONNECTION_CREDENTIAL);
-			g_value_set_enum(&clientname, VNC_CONNECTION_CREDENTIAL_CLIENTNAME);
-			authCred = g_value_array_append(authCred, &clientname);
-		}
-
-		sigdata.params.authCred = authCred;
-		VNC_DEBUG("Requesting missing credentials");
-		vnc_connection_emit_main_context(conn, VNC_AUTH_CREDENTIAL, &sigdata);
-
-		g_value_array_free(authCred);
-
-		if (priv->has_error)
-			return FALSE;
-		VNC_DEBUG("Waiting for missing credentials");
-		g_condition_wait(vnc_connection_has_credentials, conn);
-		VNC_DEBUG("Got all credentials");
-	}
-	return !vnc_connection_has_error(conn);
+    VncConnectionPrivate *priv = conn->priv;
+
+    if (priv->has_error)
+        return FALSE;
+
+    if (!vnc_connection_has_credentials(conn)) {
+        GValueArray *authCred;
+        GValue username, password, clientname;
+        struct signal_data sigdata;
+
+        memset(&username, 0, sizeof(username));
+        memset(&password, 0, sizeof(password));
+        memset(&clientname, 0, sizeof(clientname));
+
+        authCred = g_value_array_new(0);
+        if (priv->want_cred_username) {
+            g_value_init(&username, VNC_TYPE_CONNECTION_CREDENTIAL);
+            g_value_set_enum(&username, VNC_CONNECTION_CREDENTIAL_USERNAME);
+            authCred = g_value_array_append(authCred, &username);
+        }
+        if (priv->want_cred_password) {
+            g_value_init(&password, VNC_TYPE_CONNECTION_CREDENTIAL);
+            g_value_set_enum(&password, VNC_CONNECTION_CREDENTIAL_PASSWORD);
+            authCred = g_value_array_append(authCred, &password);
+        }
+        if (priv->want_cred_x509) {
+            g_value_init(&clientname, VNC_TYPE_CONNECTION_CREDENTIAL);
+            g_value_set_enum(&clientname, VNC_CONNECTION_CREDENTIAL_CLIENTNAME);
+            authCred = g_value_array_append(authCred, &clientname);
+        }
+
+        sigdata.params.authCred = authCred;
+        VNC_DEBUG("Requesting missing credentials");
+        vnc_connection_emit_main_context(conn, VNC_AUTH_CREDENTIAL, &sigdata);
+
+        g_value_array_free(authCred);
+
+        if (priv->has_error)
+            return FALSE;
+        VNC_DEBUG("Waiting for missing credentials");
+        g_condition_wait(vnc_connection_has_credentials, conn);
+        VNC_DEBUG("Got all credentials");
+    }
+    return !vnc_connection_has_error(conn);
 }
 
 
 static gboolean vnc_connection_check_auth_result(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint32 result;
-
-	VNC_DEBUG("Checking auth result");
-	result = vnc_connection_read_u32(conn);
-	if (!result) {
-		VNC_DEBUG("Success");
-		return TRUE;
-	}
-
-	if (priv->minor >= 8) {
-		guint32 len;
-		char reason[1024];
-		len = vnc_connection_read_u32(conn);
-		if (len > (sizeof(reason)-1))
-			return FALSE;
-		vnc_connection_read(conn, reason, len);
-		reason[len] = '\0';
-		VNC_DEBUG("Fail %s", reason);
-		if (!priv->has_error) {
-			struct signal_data sigdata;
-			sigdata.params.authReason = reason;
-			vnc_connection_emit_main_context(conn, VNC_AUTH_FAILURE, &sigdata);
-		}
-	} else {
-		VNC_DEBUG("Fail auth no result");
-		if (!priv->has_error) {
-			struct signal_data sigdata;
-			sigdata.params.authReason = "Unknown authentication failure";
-			vnc_connection_emit_main_context(conn, VNC_AUTH_FAILURE, &sigdata);
-		}
-	}
-	return FALSE;
+    VncConnectionPrivate *priv = conn->priv;
+    guint32 result;
+
+    VNC_DEBUG("Checking auth result");
+    result = vnc_connection_read_u32(conn);
+    if (!result) {
+        VNC_DEBUG("Success");
+        return TRUE;
+    }
+
+    if (priv->minor >= 8) {
+        guint32 len;
+        char reason[1024];
+        len = vnc_connection_read_u32(conn);
+        if (len > (sizeof(reason)-1))
+            return FALSE;
+        vnc_connection_read(conn, reason, len);
+        reason[len] = '\0';
+        VNC_DEBUG("Fail %s", reason);
+        if (!priv->has_error) {
+            struct signal_data sigdata;
+            sigdata.params.authReason = reason;
+            vnc_connection_emit_main_context(conn, VNC_AUTH_FAILURE, &sigdata);
+        }
+    } else {
+        VNC_DEBUG("Fail auth no result");
+        if (!priv->has_error) {
+            struct signal_data sigdata;
+            sigdata.params.authReason = "Unknown authentication failure";
+            vnc_connection_emit_main_context(conn, VNC_AUTH_FAILURE, &sigdata);
+        }
+    }
+    return FALSE;
 }
 
 static gboolean vnc_connection_perform_auth_vnc(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	guint8 challenge[16];
-	guint8 key[8];
+    VncConnectionPrivate *priv = conn->priv;
+    guint8 challenge[16];
+    guint8 key[8];
 
-	VNC_DEBUG("Do Challenge");
-	priv->want_cred_password = TRUE;
-	priv->want_cred_username = FALSE;
-	priv->want_cred_x509 = FALSE;
-	if (!vnc_connection_gather_credentials(conn))
-		return FALSE;
+    VNC_DEBUG("Do Challenge");
+    priv->want_cred_password = TRUE;
+    priv->want_cred_username = FALSE;
+    priv->want_cred_x509 = FALSE;
+    if (!vnc_connection_gather_credentials(conn))
+        return FALSE;
 
-	if (!priv->cred_password)
-		return FALSE;
+    if (!priv->cred_password)
+        return FALSE;
 
-	vnc_connection_read(conn, challenge, 16);
+    vnc_connection_read(conn, challenge, 16);
 
-	memset(key, 0, 8);
-	strncpy((char*)key, (char*)priv->cred_password, 8);
+    memset(key, 0, 8);
+    strncpy((char*)key, (char*)priv->cred_password, 8);
 
-	deskey(key, EN0);
-	des(challenge, challenge);
-	des(challenge + 8, challenge + 8);
+    deskey(key, EN0);
+    des(challenge, challenge);
+    des(challenge + 8, challenge + 8);
 
-	vnc_connection_write(conn, challenge, 16);
-	vnc_connection_flush(conn);
-	return vnc_connection_check_auth_result(conn);
+    vnc_connection_write(conn, challenge, 16);
+    vnc_connection_flush(conn);
+    return vnc_connection_check_auth_result(conn);
 }
 
 /*
@@ -3276,216 +3276,216 @@ static gboolean vnc_connection_perform_auth_vnc(VncConnection *conn)
 static void
 vncEncryptBytes2(unsigned char *where, const int length, unsigned char *key)
 {
-	int i, j;
-	deskey(key, EN0);
-	for (i = 0; i< 8; i++)
-		where[i] ^= key[i];
-	des(where, where);
-	for (i = 8; i < length; i += 8) {
-		for (j = 0; j < 8; j++)
-			where[i + j] ^= where[i + j - 8];
-		des(where + i, where + i);
-	}
+    int i, j;
+    deskey(key, EN0);
+    for (i = 0; i< 8; i++)
+        where[i] ^= key[i];
+    des(where, where);
+    for (i = 8; i < length; i += 8) {
+        for (j = 0; j < 8; j++)
+            where[i + j] ^= where[i + j - 8];
+        des(where + i, where + i);
+    }
 }
 
 static gboolean vnc_connection_perform_auth_mslogon(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct vnc_dh *dh;
-	guchar gen[8], mod[8], resp[8], pub[8], key[8];
-	gcry_mpi_t genmpi, modmpi, respmpi, pubmpi, keympi;
-	guchar username[256], password[64];
-	guint passwordLen, usernameLen;
-
-	VNC_DEBUG("Do Challenge");
-	priv->want_cred_password = TRUE;
-	priv->want_cred_username = TRUE;
-	priv->want_cred_x509 = FALSE;
-	if (!vnc_connection_gather_credentials(conn))
-		return FALSE;
+    VncConnectionPrivate *priv = conn->priv;
+    struct vnc_dh *dh;
+    guchar gen[8], mod[8], resp[8], pub[8], key[8];
+    gcry_mpi_t genmpi, modmpi, respmpi, pubmpi, keympi;
+    guchar username[256], password[64];
+    guint passwordLen, usernameLen;
+
+    VNC_DEBUG("Do Challenge");
+    priv->want_cred_password = TRUE;
+    priv->want_cred_username = TRUE;
+    priv->want_cred_x509 = FALSE;
+    if (!vnc_connection_gather_credentials(conn))
+        return FALSE;
 
-	vnc_connection_read(conn, gen, sizeof(gen));
-	vnc_connection_read(conn, mod, sizeof(mod));
-	vnc_connection_read(conn, resp, sizeof(resp));
+    vnc_connection_read(conn, gen, sizeof(gen));
+    vnc_connection_read(conn, mod, sizeof(mod));
+    vnc_connection_read(conn, resp, sizeof(resp));
 
-	genmpi = vnc_bytes_to_mpi(gen,sizeof(gen));
-	modmpi = vnc_bytes_to_mpi(mod,sizeof(mod));
-	respmpi = vnc_bytes_to_mpi(resp,sizeof(resp));
+    genmpi = vnc_bytes_to_mpi(gen,sizeof(gen));
+    modmpi = vnc_bytes_to_mpi(mod,sizeof(mod));
+    respmpi = vnc_bytes_to_mpi(resp,sizeof(resp));
 
-	dh = vnc_dh_new(genmpi, modmpi);
+    dh = vnc_dh_new(genmpi, modmpi);
 
-	pubmpi = vnc_dh_gen_secret(dh);
-	vnc_mpi_to_bytes(pubmpi, pub, sizeof(pub));
+    pubmpi = vnc_dh_gen_secret(dh);
+    vnc_mpi_to_bytes(pubmpi, pub, sizeof(pub));
 
-	vnc_connection_write(conn, pub, sizeof(pub));
+    vnc_connection_write(conn, pub, sizeof(pub));
 
-	keympi = vnc_dh_gen_key(dh, respmpi);
-	vnc_mpi_to_bytes(keympi, key, sizeof(key));
+    keympi = vnc_dh_gen_key(dh, respmpi);
+    vnc_mpi_to_bytes(keympi, key, sizeof(key));
 
-	passwordLen = strlen(priv->cred_password);
-	usernameLen = strlen(priv->cred_username);
-	if (passwordLen > sizeof(password))
-		passwordLen = sizeof(password);
-	if (usernameLen > sizeof(username))
-		usernameLen = sizeof(username);
+    passwordLen = strlen(priv->cred_password);
+    usernameLen = strlen(priv->cred_username);
+    if (passwordLen > sizeof(password))
+        passwordLen = sizeof(password);
+    if (usernameLen > sizeof(username))
+        usernameLen = sizeof(username);
 
-	memset(password, 0, sizeof password);
-	memset(username, 0, sizeof username);
-	memcpy(password, priv->cred_password, passwordLen);
-	memcpy(username, priv->cred_username, usernameLen);
+    memset(password, 0, sizeof password);
+    memset(username, 0, sizeof username);
+    memcpy(password, priv->cred_password, passwordLen);
+    memcpy(username, priv->cred_username, usernameLen);
 
-	vncEncryptBytes2(username, sizeof(username), key);
-	vncEncryptBytes2(password, sizeof(password), key);
+    vncEncryptBytes2(username, sizeof(username), key);
+    vncEncryptBytes2(password, sizeof(password), key);
 
-	vnc_connection_write(conn, username, sizeof(username));
-	vnc_connection_write(conn, password, sizeof(password));
-	vnc_connection_flush(conn);
+    vnc_connection_write(conn, username, sizeof(username));
+    vnc_connection_write(conn, password, sizeof(password));
+    vnc_connection_flush(conn);
 
-	gcry_mpi_release(genmpi);
-	gcry_mpi_release(modmpi);
-	gcry_mpi_release(respmpi);
-	vnc_dh_free (dh);
+    gcry_mpi_release(genmpi);
+    gcry_mpi_release(modmpi);
+    gcry_mpi_release(respmpi);
+    vnc_dh_free (dh);
 
-	return vnc_connection_check_auth_result(conn);
+    return vnc_connection_check_auth_result(conn);
 }
 
 static gboolean vnc_connection_perform_auth_ard(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct vnc_dh *dh;
-	guchar gen[2], len[2];
-	size_t keylen;
-	guchar *mod, *resp, *pub, *key, *shared;
-	gcry_mpi_t genmpi, modmpi, respmpi, pubmpi, keympi;
-	guchar userpass[128], ciphertext[128];
-	guint passwordLen, usernameLen;
-	gcry_md_hd_t md5;
-	gcry_cipher_hd_t aes;
-	gcry_error_t error;
-
-	VNC_DEBUG("Do Challenge");
-	priv->want_cred_password = TRUE;
-	priv->want_cred_username = TRUE;
-	priv->want_cred_x509 = FALSE;
-	if (!vnc_connection_gather_credentials(conn))
-		return FALSE;
-
-	vnc_connection_read(conn, gen, sizeof(gen));
-	vnc_connection_read(conn, len, sizeof(len));
-
-	keylen = 256*len[0] + len[1];
-	mod = malloc(keylen);
-	if (mod == NULL) {
-		VNC_DEBUG("malloc failed\n");
-		return FALSE;
-	}
-	resp = malloc(keylen);
-	if (resp == NULL) {
-		free(mod);
-		VNC_DEBUG("malloc failed\n");
-		return FALSE;
-	}
-	pub = malloc(keylen);
-	if (pub == NULL) {
-		free(resp);
-		free(mod);
-		VNC_DEBUG("malloc failed\n");
-		return FALSE;
-	}
-	key = malloc(keylen);
-	if (key == NULL) {
-		free(pub);
-		free(resp);
-		free(mod);
-		VNC_DEBUG("malloc failed\n");
-		return FALSE;
-	}
-
-	vnc_connection_read(conn, mod, keylen);
-	vnc_connection_read(conn, resp, keylen);
-
-	genmpi = vnc_bytes_to_mpi(gen,sizeof(gen));
-	modmpi = vnc_bytes_to_mpi(mod,keylen);
-	respmpi = vnc_bytes_to_mpi(resp,keylen);
-
-	dh = vnc_dh_new(genmpi, modmpi);
-
-	pubmpi = vnc_dh_gen_secret(dh);
-	vnc_mpi_to_bytes(pubmpi, pub, keylen);
-
-	keympi = vnc_dh_gen_key(dh, respmpi);
-	vnc_mpi_to_bytes(keympi, key, keylen);
-
-	error=gcry_md_open(&md5, GCRY_MD_MD5, 0);
-	if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
-		VNC_DEBUG("gcry_md_open error: %s\n", gcry_strerror(error));
-		free(pub);
-		free(resp);
-		free(mod);
-		return FALSE;
-	}
-	gcry_md_write(md5, key, keylen);
-	error=gcry_md_final(md5);
-	if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
-		VNC_DEBUG("gcry_md_final error: %s\n", gcry_strerror(error));
-		free(pub);
-		free(resp);
-		free(mod);
-		return FALSE;
-	}
-	shared = gcry_md_read(md5, GCRY_MD_MD5);
-
-	passwordLen = strlen(priv->cred_password)+1;
-	usernameLen = strlen(priv->cred_username)+1;
-	if (passwordLen > sizeof(userpass)/2)
-		passwordLen = sizeof(userpass)/2;
-	if (usernameLen > sizeof(userpass)/2)
-		usernameLen = sizeof(userpass)/2;
-
-	gcry_randomize(userpass, sizeof(userpass), GCRY_STRONG_RANDOM);
-	memcpy(userpass, priv->cred_username, usernameLen);
-	memcpy(userpass+sizeof(userpass)/2, priv->cred_password, passwordLen);
-	
-	error=gcry_cipher_open(&aes, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0);
-	if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
-		VNC_DEBUG("gcry_cipher_open error: %s\n", gcry_strerror(error));
-		free(pub);
-		free(resp);
-		free(mod);
-		return FALSE;
-	}
-	error=gcry_cipher_setkey(aes, shared, 16);
-	if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
-		VNC_DEBUG("gcry_cipher_setkey error: %s\n", gcry_strerror(error));
-		free(pub);
-		free(resp);
-		free(mod);
-		return FALSE;
-	}
-	error=gcry_cipher_encrypt(aes, ciphertext, sizeof(ciphertext), userpass, sizeof(userpass));
-	if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
-		VNC_DEBUG("gcry_cipher_encrypt error: %s\n", gcry_strerror(error));
-		free(pub);
-		free(resp);
-		free(mod);
-		return FALSE;
-	}
-
-	vnc_connection_write(conn, ciphertext, sizeof(ciphertext));
-	vnc_connection_write(conn, pub, keylen);
-	vnc_connection_flush(conn);
-
-	free(mod);
-	free(resp);
-	free(pub);
-	free(key);
-	gcry_md_close(md5);
-	gcry_mpi_release(genmpi);
-	gcry_mpi_release(modmpi);
-	gcry_mpi_release(respmpi);
-	vnc_dh_free (dh);
-
-	return vnc_connection_check_auth_result(conn);
+    VncConnectionPrivate *priv = conn->priv;
+    struct vnc_dh *dh;
+    guchar gen[2], len[2];
+    size_t keylen;
+    guchar *mod, *resp, *pub, *key, *shared;
+    gcry_mpi_t genmpi, modmpi, respmpi, pubmpi, keympi;
+    guchar userpass[128], ciphertext[128];
+    guint passwordLen, usernameLen;
+    gcry_md_hd_t md5;
+    gcry_cipher_hd_t aes;
+    gcry_error_t error;
+
+    VNC_DEBUG("Do Challenge");
+    priv->want_cred_password = TRUE;
+    priv->want_cred_username = TRUE;
+    priv->want_cred_x509 = FALSE;
+    if (!vnc_connection_gather_credentials(conn))
+        return FALSE;
+
+    vnc_connection_read(conn, gen, sizeof(gen));
+    vnc_connection_read(conn, len, sizeof(len));
+
+    keylen = 256*len[0] + len[1];
+    mod = malloc(keylen);
+    if (mod == NULL) {
+        VNC_DEBUG("malloc failed\n");
+        return FALSE;
+    }
+    resp = malloc(keylen);
+    if (resp == NULL) {
+        free(mod);
+        VNC_DEBUG("malloc failed\n");
+        return FALSE;
+    }
+    pub = malloc(keylen);
+    if (pub == NULL) {
+        free(resp);
+        free(mod);
+        VNC_DEBUG("malloc failed\n");
+        return FALSE;
+    }
+    key = malloc(keylen);
+    if (key == NULL) {
+        free(pub);
+        free(resp);
+        free(mod);
+        VNC_DEBUG("malloc failed\n");
+        return FALSE;
+    }
+
+    vnc_connection_read(conn, mod, keylen);
+    vnc_connection_read(conn, resp, keylen);
+
+    genmpi = vnc_bytes_to_mpi(gen,sizeof(gen));
+    modmpi = vnc_bytes_to_mpi(mod,keylen);
+    respmpi = vnc_bytes_to_mpi(resp,keylen);
+
+    dh = vnc_dh_new(genmpi, modmpi);
+
+    pubmpi = vnc_dh_gen_secret(dh);
+    vnc_mpi_to_bytes(pubmpi, pub, keylen);
+
+    keympi = vnc_dh_gen_key(dh, respmpi);
+    vnc_mpi_to_bytes(keympi, key, keylen);
+
+    error=gcry_md_open(&md5, GCRY_MD_MD5, 0);
+    if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
+        VNC_DEBUG("gcry_md_open error: %s\n", gcry_strerror(error));
+        free(pub);
+        free(resp);
+        free(mod);
+        return FALSE;
+    }
+    gcry_md_write(md5, key, keylen);
+    error=gcry_md_final(md5);
+    if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
+        VNC_DEBUG("gcry_md_final error: %s\n", gcry_strerror(error));
+        free(pub);
+        free(resp);
+        free(mod);
+        return FALSE;
+    }
+    shared = gcry_md_read(md5, GCRY_MD_MD5);
+
+    passwordLen = strlen(priv->cred_password)+1;
+    usernameLen = strlen(priv->cred_username)+1;
+    if (passwordLen > sizeof(userpass)/2)
+        passwordLen = sizeof(userpass)/2;
+    if (usernameLen > sizeof(userpass)/2)
+        usernameLen = sizeof(userpass)/2;
+
+    gcry_randomize(userpass, sizeof(userpass), GCRY_STRONG_RANDOM);
+    memcpy(userpass, priv->cred_username, usernameLen);
+    memcpy(userpass+sizeof(userpass)/2, priv->cred_password, passwordLen);
+        
+    error=gcry_cipher_open(&aes, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0);
+    if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
+        VNC_DEBUG("gcry_cipher_open error: %s\n", gcry_strerror(error));
+        free(pub);
+        free(resp);
+        free(mod);
+        return FALSE;
+    }
+    error=gcry_cipher_setkey(aes, shared, 16);
+    if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
+        VNC_DEBUG("gcry_cipher_setkey error: %s\n", gcry_strerror(error));
+        free(pub);
+        free(resp);
+        free(mod);
+        return FALSE;
+    }
+    error=gcry_cipher_encrypt(aes, ciphertext, sizeof(ciphertext), userpass, sizeof(userpass));
+    if (gcry_err_code (error) != GPG_ERR_NO_ERROR) {
+        VNC_DEBUG("gcry_cipher_encrypt error: %s\n", gcry_strerror(error));
+        free(pub);
+        free(resp);
+        free(mod);
+        return FALSE;
+    }
+
+    vnc_connection_write(conn, ciphertext, sizeof(ciphertext));
+    vnc_connection_write(conn, pub, keylen);
+    vnc_connection_flush(conn);
+
+    free(mod);
+    free(resp);
+    free(pub);
+    free(key);
+    gcry_md_close(md5);
+    gcry_mpi_release(genmpi);
+    gcry_mpi_release(modmpi);
+    gcry_mpi_release(respmpi);
+    vnc_dh_free (dh);
+
+    return vnc_connection_check_auth_result(conn);
 }
 
 
@@ -3495,81 +3495,81 @@ static gboolean vnc_connection_perform_auth_ard(VncConnection *conn)
  */
 static char *vnc_connection_addr_to_string(GSocketAddress *addr)
 {
-	GInetSocketAddress *iaddr = G_INET_SOCKET_ADDRESS(addr);
-	guint16 port;
-	GInetAddress *host;
-	gchar *hoststr;
-	gchar *ret;
+    GInetSocketAddress *iaddr = G_INET_SOCKET_ADDRESS(addr);
+    guint16 port;
+    GInetAddress *host;
+    gchar *hoststr;
+    gchar *ret;
 
-	host = g_inet_socket_address_get_address(iaddr);
-	port = g_inet_socket_address_get_port(iaddr);
-	hoststr = g_inet_address_to_string(host);
+    host = g_inet_socket_address_get_address(iaddr);
+    port = g_inet_socket_address_get_port(iaddr);
+    hoststr = g_inet_address_to_string(host);
 
-	ret = g_strdup_printf("%s;%hu", hoststr, port);
-	g_free(hoststr);
+    ret = g_strdup_printf("%s;%hu", hoststr, port);
+    g_free(hoststr);
 
-	return ret;
+    return ret;
 }
 
 
 
 static gboolean
 vnc_connection_gather_sasl_credentials(VncConnection *conn,
-				       sasl_interact_t *interact)
+                                       sasl_interact_t *interact)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int ninteract;
+    VncConnectionPrivate *priv = conn->priv;
+    int ninteract;
 
-	priv->want_cred_password = FALSE;
-	priv->want_cred_username = FALSE;
-	priv->want_cred_x509 = FALSE;
+    priv->want_cred_password = FALSE;
+    priv->want_cred_username = FALSE;
+    priv->want_cred_x509 = FALSE;
 
-	for (ninteract = 0 ; interact[ninteract].id != 0 ; ninteract++) {
-		switch (interact[ninteract].id) {
-		case SASL_CB_AUTHNAME:
-		case SASL_CB_USER:
-			priv->want_cred_username = TRUE;
-			break;
+    for (ninteract = 0 ; interact[ninteract].id != 0 ; ninteract++) {
+        switch (interact[ninteract].id) {
+        case SASL_CB_AUTHNAME:
+        case SASL_CB_USER:
+            priv->want_cred_username = TRUE;
+            break;
 
-		case SASL_CB_PASS:
-			priv->want_cred_password = TRUE;
-			break;
+        case SASL_CB_PASS:
+            priv->want_cred_password = TRUE;
+            break;
 
-		default:
-			VNC_DEBUG("Unsupported credential %lu",
-				   interact[ninteract].id);
-			/* Unsupported */
-			return FALSE;
-		}
-	}
-
-	if ((priv->want_cred_password ||
-	     priv->want_cred_username) &&
-	    !vnc_connection_gather_credentials(conn)) {
-		VNC_DEBUG("%s", "cannot gather sasl credentials");
-		return FALSE;
-	}
-
-	for (ninteract = 0 ; interact[ninteract].id != 0 ; ninteract++) {
-		switch (interact[ninteract].id) {
-		case SASL_CB_AUTHNAME:
-		case SASL_CB_USER:
-			interact[ninteract].result = priv->cred_username;
-			interact[ninteract].len = strlen(priv->cred_username);
-			VNC_DEBUG("Gather Username %s", priv->cred_username);
-			break;
+        default:
+            VNC_DEBUG("Unsupported credential %lu",
+                      interact[ninteract].id);
+            /* Unsupported */
+            return FALSE;
+        }
+    }
 
-		case SASL_CB_PASS:
-			interact[ninteract].result =  priv->cred_password;
-			interact[ninteract].len = strlen(priv->cred_password);
-			//VNC_DEBUG("Gather Password %s", priv->cred_password);
-			break;
-		}
-	}
+    if ((priv->want_cred_password ||
+         priv->want_cred_username) &&
+        !vnc_connection_gather_credentials(conn)) {
+        VNC_DEBUG("%s", "cannot gather sasl credentials");
+        return FALSE;
+    }
+
+    for (ninteract = 0 ; interact[ninteract].id != 0 ; ninteract++) {
+        switch (interact[ninteract].id) {
+        case SASL_CB_AUTHNAME:
+        case SASL_CB_USER:
+            interact[ninteract].result = priv->cred_username;
+            interact[ninteract].len = strlen(priv->cred_username);
+            VNC_DEBUG("Gather Username %s", priv->cred_username);
+            break;
+
+        case SASL_CB_PASS:
+            interact[ninteract].result =  priv->cred_password;
+            interact[ninteract].len = strlen(priv->cred_password);
+            //VNC_DEBUG("Gather Password %s", priv->cred_password);
+            break;
+        }
+    }
 
-	VNC_DEBUG("%s", "Filled SASL interact");
+    VNC_DEBUG("%s", "Filled SASL interact");
 
-	return TRUE;
+    return TRUE;
 }
 
 
@@ -3614,1373 +3614,1373 @@ vnc_connection_gather_sasl_credentials(VncConnection *conn,
  */
 static gboolean vnc_connection_perform_auth_sasl(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	sasl_conn_t *saslconn = NULL;
-	sasl_security_properties_t secprops;
-	const char *clientout;
-	char *serverin = NULL;
-	unsigned int clientoutlen, serverinlen;
-	int err, complete;
-	char *localAddr = NULL, *remoteAddr = NULL;
-	const void *val;
-	sasl_ssf_t ssf;
-	sasl_callback_t saslcb[] = {
-		{ .id = SASL_CB_AUTHNAME },
-		//		{ .id = SASL_CB_USER },
-		{ .id = SASL_CB_PASS },
-		{ .id = 0 },
-	};
-	sasl_interact_t *interact = NULL;
-	guint32 mechlistlen;
-        char *mechlist;
-	const char *mechname;
-	gboolean ret;
-	GSocketAddress *addr;
-
-	/* Sets up the SASL library as a whole */
-	err = sasl_client_init(NULL);
-	VNC_DEBUG("Client initialize SASL authentication %d", err);
-	if (err != SASL_OK) {
-		VNC_DEBUG("failed to initialize SASL library: %d (%s)",
-			   err, sasl_errstring(err, NULL, NULL));
-		goto error;
-	}
-
-	/* Get local address in form  IPADDR:PORT */
-	addr = g_socket_get_local_address(priv->sock, NULL);
-	if (!addr) {
-		VNC_DEBUG("failed to get local address");
-		goto error;
-	}
-	if ((g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV4 ||
-	     g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV6) &&
-	    (localAddr = vnc_connection_addr_to_string(addr)) == NULL)
-		goto error;
-
-	/* Get remote address in form  IPADDR:PORT */
-	addr = g_socket_get_remote_address(priv->sock, NULL);
-	if (!addr) {
-		VNC_DEBUG("failed to get peer address");
-		goto error;
-	}
-	if ((g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV4 ||
-	     g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV6) &&
-	    (remoteAddr = vnc_connection_addr_to_string(addr)) == NULL)
-		goto error;
-
-	VNC_DEBUG("Client SASL new host:'%s' local:'%s' remote:'%s'", priv->host, localAddr, remoteAddr);
-
-	/* Setup a handle for being a client */
-	err = sasl_client_new("vnc",
-			      priv->host,
-			      localAddr,
-			      remoteAddr,
-			      saslcb,
-			      SASL_SUCCESS_DATA,
-			      &saslconn);
-	g_free(localAddr);
-	g_free(remoteAddr);
-
-	if (err != SASL_OK) {
-		VNC_DEBUG("Failed to create SASL client context: %d (%s)",
-			   err, sasl_errstring(err, NULL, NULL));
-		goto error;
-	}
-
-	/* Initialize some connection props we care about */
-	if (priv->tls_session) {
-		gnutls_cipher_algorithm_t cipher;
-
-		cipher = gnutls_cipher_get(priv->tls_session);
-		if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
-			VNC_DEBUG("%s", "invalid cipher size for TLS session");
-			goto error;
-		}
-		ssf *= 8; /* key size is bytes, sasl wants bits */
-
-		VNC_DEBUG("Setting external SSF %d", ssf);
-		err = sasl_setprop(saslconn, SASL_SSF_EXTERNAL, &ssf);
-		if (err != SASL_OK) {
-			VNC_DEBUG("cannot set external SSF %d (%s)",
-				   err, sasl_errstring(err, NULL, NULL));
-			goto error;
-		}
-	}
-
-	memset (&secprops, 0, sizeof secprops);
-	/* If we've got TLS, we don't care about SSF */
-	secprops.min_ssf = priv->tls_session ? 0 : 56; /* Equiv to DES supported by all Kerberos */
-	secprops.max_ssf = priv->tls_session ? 0 : 100000; /* Very strong ! AES == 256 */
-	secprops.maxbufsize = 100000;
-	/* If we're not TLS, then forbid any anonymous or trivially crackable auth */
-	secprops.security_flags = priv->tls_session ? 0 :
-		SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT;
-
-	err = sasl_setprop(saslconn, SASL_SEC_PROPS, &secprops);
-	if (err != SASL_OK) {
-		VNC_DEBUG("cannot set security props %d (%s)",
-			   err, sasl_errstring(err, NULL, NULL));
-		goto error;
-	}
-
-	/* Get the supported mechanisms from the server */
-	mechlistlen = vnc_connection_read_u32(conn);
-	if (priv->has_error)
-		goto error;
-	if (mechlistlen > SASL_MAX_MECHLIST_LEN) {
-		VNC_DEBUG("mechlistlen %d too long", mechlistlen);
-		goto error;
-	}
-
-	mechlist = g_malloc(mechlistlen+1);
-        vnc_connection_read(conn, mechlist, mechlistlen);
-	mechlist[mechlistlen] = '\0';
-	if (priv->has_error) {
-		g_free(mechlist);
-		mechlist = NULL;
-		goto error;
-	}
+    VncConnectionPrivate *priv = conn->priv;
+    sasl_conn_t *saslconn = NULL;
+    sasl_security_properties_t secprops;
+    const char *clientout;
+    char *serverin = NULL;
+    unsigned int clientoutlen, serverinlen;
+    int err, complete;
+    char *localAddr = NULL, *remoteAddr = NULL;
+    const void *val;
+    sasl_ssf_t ssf;
+    sasl_callback_t saslcb[] = {
+        { .id = SASL_CB_AUTHNAME },
+        //                { .id = SASL_CB_USER },
+        { .id = SASL_CB_PASS },
+        { .id = 0 },
+    };
+    sasl_interact_t *interact = NULL;
+    guint32 mechlistlen;
+    char *mechlist;
+    const char *mechname;
+    gboolean ret;
+    GSocketAddress *addr;
+
+    /* Sets up the SASL library as a whole */
+    err = sasl_client_init(NULL);
+    VNC_DEBUG("Client initialize SASL authentication %d", err);
+    if (err != SASL_OK) {
+        VNC_DEBUG("failed to initialize SASL library: %d (%s)",
+                  err, sasl_errstring(err, NULL, NULL));
+        goto error;
+    }
+
+    /* Get local address in form  IPADDR:PORT */
+    addr = g_socket_get_local_address(priv->sock, NULL);
+    if (!addr) {
+        VNC_DEBUG("failed to get local address");
+        goto error;
+    }
+    if ((g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV4 ||
+         g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV6) &&
+        (localAddr = vnc_connection_addr_to_string(addr)) == NULL)
+        goto error;
+
+    /* Get remote address in form  IPADDR:PORT */
+    addr = g_socket_get_remote_address(priv->sock, NULL);
+    if (!addr) {
+        VNC_DEBUG("failed to get peer address");
+        goto error;
+    }
+    if ((g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV4 ||
+         g_socket_address_get_family(addr) == G_SOCKET_FAMILY_IPV6) &&
+        (remoteAddr = vnc_connection_addr_to_string(addr)) == NULL)
+        goto error;
+
+    VNC_DEBUG("Client SASL new host:'%s' local:'%s' remote:'%s'", priv->host, localAddr, remoteAddr);
+
+    /* Setup a handle for being a client */
+    err = sasl_client_new("vnc",
+                          priv->host,
+                          localAddr,
+                          remoteAddr,
+                          saslcb,
+                          SASL_SUCCESS_DATA,
+                          &saslconn);
+    g_free(localAddr);
+    g_free(remoteAddr);
+
+    if (err != SASL_OK) {
+        VNC_DEBUG("Failed to create SASL client context: %d (%s)",
+                  err, sasl_errstring(err, NULL, NULL));
+        goto error;
+    }
+
+    /* Initialize some connection props we care about */
+    if (priv->tls_session) {
+        gnutls_cipher_algorithm_t cipher;
+
+        cipher = gnutls_cipher_get(priv->tls_session);
+        if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
+            VNC_DEBUG("%s", "invalid cipher size for TLS session");
+            goto error;
+        }
+        ssf *= 8; /* key size is bytes, sasl wants bits */
+
+        VNC_DEBUG("Setting external SSF %d", ssf);
+        err = sasl_setprop(saslconn, SASL_SSF_EXTERNAL, &ssf);
+        if (err != SASL_OK) {
+            VNC_DEBUG("cannot set external SSF %d (%s)",
+                      err, sasl_errstring(err, NULL, NULL));
+            goto error;
+        }
+    }
+
+    memset (&secprops, 0, sizeof secprops);
+    /* If we've got TLS, we don't care about SSF */
+    secprops.min_ssf = priv->tls_session ? 0 : 56; /* Equiv to DES supported by all Kerberos */
+    secprops.max_ssf = priv->tls_session ? 0 : 100000; /* Very strong ! AES == 256 */
+    secprops.maxbufsize = 100000;
+    /* If we're not TLS, then forbid any anonymous or trivially crackable auth */
+    secprops.security_flags = priv->tls_session ? 0 :
+        SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT;
+
+    err = sasl_setprop(saslconn, SASL_SEC_PROPS, &secprops);
+    if (err != SASL_OK) {
+        VNC_DEBUG("cannot set security props %d (%s)",
+                  err, sasl_errstring(err, NULL, NULL));
+        goto error;
+    }
+
+    /* Get the supported mechanisms from the server */
+    mechlistlen = vnc_connection_read_u32(conn);
+    if (priv->has_error)
+        goto error;
+    if (mechlistlen > SASL_MAX_MECHLIST_LEN) {
+        VNC_DEBUG("mechlistlen %d too long", mechlistlen);
+        goto error;
+    }
+
+    mechlist = g_malloc(mechlistlen+1);
+    vnc_connection_read(conn, mechlist, mechlistlen);
+    mechlist[mechlistlen] = '\0';
+    if (priv->has_error) {
+        g_free(mechlist);
+        mechlist = NULL;
+        goto error;
+    }
 
 #if 0
-	if (wantmech) {
-		if (strstr(mechlist, wantmech) == NULL) {
-			VNC_DEBUG("SASL mechanism %s not supported by server",
-				   wantmech);
-			VIR_FREE(iret.mechlist);
-			goto error;
-		}
-		mechlist = wantmech;
-	}
+    if (wantmech) {
+        if (strstr(mechlist, wantmech) == NULL) {
+            VNC_DEBUG("SASL mechanism %s not supported by server",
+                      wantmech);
+            VIR_FREE(iret.mechlist);
+            goto error;
+        }
+        mechlist = wantmech;
+    }
 #endif
 
  restart:
-	/* Start the auth negotiation on the client end first */
-	VNC_DEBUG("Client start negotiation mechlist '%s'", mechlist);
-	err = sasl_client_start(saslconn,
-				mechlist,
-				&interact,
-				&clientout,
-				&clientoutlen,
-				&mechname);
-	if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
-		VNC_DEBUG("Failed to start SASL negotiation: %d (%s)",
-			   err, sasl_errdetail(saslconn));
-		g_free(mechlist);
-		mechlist = NULL;
-		goto error;
-	}
-
-	/* Need to gather some credentials from the client */
-	if (err == SASL_INTERACT) {
-		if (!vnc_connection_gather_sasl_credentials(conn,
-							    interact)) {
-			VNC_DEBUG("%s", "Failed to collect auth credentials");
-			goto error;
-		}
-		goto restart;
-	}
-
-	VNC_DEBUG("Server start negotiation with mech %s. Data %d bytes %p '%s'",
-		   mechname, clientoutlen, clientout, clientout);
-
-	if (clientoutlen > SASL_MAX_DATA_LEN) {
-		VNC_DEBUG("SASL negotiation data too long: %d bytes",
-			   clientoutlen);
-		goto error;
-	}
-
-	/* Send back the chosen mechname */
-	vnc_connection_write_u32(conn, strlen(mechname));
-	vnc_connection_write(conn, mechname, strlen(mechname));
-
-	/* NB, distinction of NULL vs "" is *critical* in SASL */
-	if (clientout) {
-		vnc_connection_write_u32(conn, clientoutlen + 1);
-		vnc_connection_write(conn, clientout, clientoutlen + 1);
-	} else {
-		vnc_connection_write_u32(conn, 0);
-	}
-	vnc_connection_flush(conn);
-	if (priv->has_error)
-		goto error;
-
-
-	VNC_DEBUG("%s", "Getting sever start negotiation reply");
-	/* Read the 'START' message reply from server */
-	serverinlen = vnc_connection_read_u32(conn);
-	if (priv->has_error)
-		goto error;
-	if (serverinlen > SASL_MAX_DATA_LEN) {
-		VNC_DEBUG("SASL negotiation data too long: %d bytes",
-			   clientoutlen);
-		goto error;
-	}
-
-	/* NB, distinction of NULL vs "" is *critical* in SASL */
-	if (serverinlen) {
-		serverin = g_malloc(serverinlen);
-		vnc_connection_read(conn, serverin, serverinlen);
-		serverin[serverinlen-1] = '\0';
-		serverinlen--;
-	} else {
-		serverin = NULL;
-	}
-	complete = vnc_connection_read_u8(conn);
-	if (priv->has_error)
-		goto error;
-
-	VNC_DEBUG("Client start result complete: %d. Data %d bytes %p '%s'",
-		   complete, serverinlen, serverin, serverin);
-
-	/* Loop-the-loop...
-	 * Even if the server has completed, the client must *always* do at least one step
-	 * in this loop to verify the server isn't lying about something. Mutual auth */
-	for (;;) {
-	restep:
-		err = sasl_client_step(saslconn,
-				       serverin,
-				       serverinlen,
-				       &interact,
-				       &clientout,
-				       &clientoutlen);
-		if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
-			VNC_DEBUG("Failed SASL step: %d (%s)",
-				   err, sasl_errdetail(saslconn));
-			goto error;
-		}
-
-		/* Need to gather some credentials from the client */
-		if (err == SASL_INTERACT) {
-			if (!vnc_connection_gather_sasl_credentials(conn,
-								    interact)) {
-				VNC_DEBUG("%s", "Failed to collect auth credentials");
-				goto error;
-			}
-			goto restep;
-		}
-
-		if (serverin) {
-			g_free(serverin);
-			serverin = NULL;
-		}
-
-		VNC_DEBUG("Client step result %d. Data %d bytes %p '%s'", err, clientoutlen, clientout, clientout);
-
-		/* Previous server call showed completion & we're now locally complete too */
-		if (complete && err == SASL_OK)
-			break;
-
-		/* Not done, prepare to talk with the server for another iteration */
-
-		/* NB, distinction of NULL vs "" is *critical* in SASL */
-		if (clientout) {
-			vnc_connection_write_u32(conn, clientoutlen + 1);
-			vnc_connection_write(conn, clientout, clientoutlen + 1);
-		} else {
-			vnc_connection_write_u32(conn, 0);
-		}
-		vnc_connection_flush(conn);
-		if (priv->has_error)
-			goto error;
-
-		VNC_DEBUG("Server step with %d bytes %p", clientoutlen, clientout);
-
-		serverinlen = vnc_connection_read_u32(conn);
-		if (priv->has_error)
-			goto error;
-		if (serverinlen > SASL_MAX_DATA_LEN) {
-			VNC_DEBUG("SASL negotiation data too long: %d bytes",
-				   clientoutlen);
-			goto error;
-		}
-
-		/* NB, distinction of NULL vs "" is *critical* in SASL */
-		if (serverinlen) {
-			serverin = g_malloc(serverinlen);
-			vnc_connection_read(conn, serverin, serverinlen);
-			serverin[serverinlen-1] = '\0';
-			serverinlen--;
-		} else {
-			serverin = NULL;
-		}
-		complete = vnc_connection_read_u8(conn);
-		if (priv->has_error)
-			goto error;
-
-		VNC_DEBUG("Client step result complete: %d. Data %d bytes %p '%s'",
-			   complete, serverinlen, serverin, serverin);
-
-		/* This server call shows complete, and earlier client step was OK */
-		if (complete && err == SASL_OK) {
-			g_free(serverin);
-			serverin = NULL;
-			break;
-		}
-	}
-
-	/* Check for suitable SSF if non-TLS */
-	if (!priv->tls_session) {
-		err = sasl_getprop(saslconn, SASL_SSF, &val);
-		if (err != SASL_OK) {
-			VNC_DEBUG("cannot query SASL ssf on connection %d (%s)",
-				   err, sasl_errstring(err, NULL, NULL));
-			goto error;
-		}
-		ssf = *(const int *)val;
-		VNC_DEBUG("SASL SSF value %d", ssf);
-		if (ssf < 56) { /* 56 == DES level, good for Kerberos */
-			VNC_DEBUG("negotiation SSF %d was not strong enough", ssf);
-			goto error;
-		}
-	}
-
-	VNC_DEBUG("%s", "SASL authentication complete");
-	ret = vnc_connection_check_auth_result(conn);
-	/* This must come *after* check-auth-result, because the former
-	 * is defined to be sent unencrypted, and setting saslconn turns
-	 * on the SSF layer encryption processing */
-	priv->saslconn = saslconn;
-	return ret;
+    /* Start the auth negotiation on the client end first */
+    VNC_DEBUG("Client start negotiation mechlist '%s'", mechlist);
+    err = sasl_client_start(saslconn,
+                            mechlist,
+                            &interact,
+                            &clientout,
+                            &clientoutlen,
+                            &mechname);
+    if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
+        VNC_DEBUG("Failed to start SASL negotiation: %d (%s)",
+                  err, sasl_errdetail(saslconn));
+        g_free(mechlist);
+        mechlist = NULL;
+        goto error;
+    }
+
+    /* Need to gather some credentials from the client */
+    if (err == SASL_INTERACT) {
+        if (!vnc_connection_gather_sasl_credentials(conn,
+                                                    interact)) {
+            VNC_DEBUG("%s", "Failed to collect auth credentials");
+            goto error;
+        }
+        goto restart;
+    }
+
+    VNC_DEBUG("Server start negotiation with mech %s. Data %d bytes %p '%s'",
+              mechname, clientoutlen, clientout, clientout);
+
+    if (clientoutlen > SASL_MAX_DATA_LEN) {
+        VNC_DEBUG("SASL negotiation data too long: %d bytes",
+                  clientoutlen);
+        goto error;
+    }
+
+    /* Send back the chosen mechname */
+    vnc_connection_write_u32(conn, strlen(mechname));
+    vnc_connection_write(conn, mechname, strlen(mechname));
+
+    /* NB, distinction of NULL vs "" is *critical* in SASL */
+    if (clientout) {
+        vnc_connection_write_u32(conn, clientoutlen + 1);
+        vnc_connection_write(conn, clientout, clientoutlen + 1);
+    } else {
+        vnc_connection_write_u32(conn, 0);
+    }
+    vnc_connection_flush(conn);
+    if (priv->has_error)
+        goto error;
+
+
+    VNC_DEBUG("%s", "Getting sever start negotiation reply");
+    /* Read the 'START' message reply from server */
+    serverinlen = vnc_connection_read_u32(conn);
+    if (priv->has_error)
+        goto error;
+    if (serverinlen > SASL_MAX_DATA_LEN) {
+        VNC_DEBUG("SASL negotiation data too long: %d bytes",
+                  clientoutlen);
+        goto error;
+    }
+
+    /* NB, distinction of NULL vs "" is *critical* in SASL */
+    if (serverinlen) {
+        serverin = g_malloc(serverinlen);
+        vnc_connection_read(conn, serverin, serverinlen);
+        serverin[serverinlen-1] = '\0';
+        serverinlen--;
+    } else {
+        serverin = NULL;
+    }
+    complete = vnc_connection_read_u8(conn);
+    if (priv->has_error)
+        goto error;
+
+    VNC_DEBUG("Client start result complete: %d. Data %d bytes %p '%s'",
+              complete, serverinlen, serverin, serverin);
+
+    /* Loop-the-loop...
+     * Even if the server has completed, the client must *always* do at least one step
+     * in this loop to verify the server isn't lying about something. Mutual auth */
+    for (;;) {
+    restep:
+        err = sasl_client_step(saslconn,
+                               serverin,
+                               serverinlen,
+                               &interact,
+                               &clientout,
+                               &clientoutlen);
+        if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
+            VNC_DEBUG("Failed SASL step: %d (%s)",
+                      err, sasl_errdetail(saslconn));
+            goto error;
+        }
+
+        /* Need to gather some credentials from the client */
+        if (err == SASL_INTERACT) {
+            if (!vnc_connection_gather_sasl_credentials(conn,
+                                                        interact)) {
+                VNC_DEBUG("%s", "Failed to collect auth credentials");
+                goto error;
+            }
+            goto restep;
+        }
+
+        if (serverin) {
+            g_free(serverin);
+            serverin = NULL;
+        }
+
+        VNC_DEBUG("Client step result %d. Data %d bytes %p '%s'", err, clientoutlen, clientout, clientout);
+
+        /* Previous server call showed completion & we're now locally complete too */
+        if (complete && err == SASL_OK)
+            break;
+
+        /* Not done, prepare to talk with the server for another iteration */
+
+        /* NB, distinction of NULL vs "" is *critical* in SASL */
+        if (clientout) {
+            vnc_connection_write_u32(conn, clientoutlen + 1);
+            vnc_connection_write(conn, clientout, clientoutlen + 1);
+        } else {
+            vnc_connection_write_u32(conn, 0);
+        }
+        vnc_connection_flush(conn);
+        if (priv->has_error)
+            goto error;
+
+        VNC_DEBUG("Server step with %d bytes %p", clientoutlen, clientout);
+
+        serverinlen = vnc_connection_read_u32(conn);
+        if (priv->has_error)
+            goto error;
+        if (serverinlen > SASL_MAX_DATA_LEN) {
+            VNC_DEBUG("SASL negotiation data too long: %d bytes",
+                      clientoutlen);
+            goto error;
+        }
+
+        /* NB, distinction of NULL vs "" is *critical* in SASL */
+        if (serverinlen) {
+            serverin = g_malloc(serverinlen);
+            vnc_connection_read(conn, serverin, serverinlen);
+            serverin[serverinlen-1] = '\0';
+            serverinlen--;
+        } else {
+            serverin = NULL;
+        }
+        complete = vnc_connection_read_u8(conn);
+        if (priv->has_error)
+            goto error;
+
+        VNC_DEBUG("Client step result complete: %d. Data %d bytes %p '%s'",
+                  complete, serverinlen, serverin, serverin);
+
+        /* This server call shows complete, and earlier client step was OK */
+        if (complete && err == SASL_OK) {
+            g_free(serverin);
+            serverin = NULL;
+            break;
+        }
+    }
+
+    /* Check for suitable SSF if non-TLS */
+    if (!priv->tls_session) {
+        err = sasl_getprop(saslconn, SASL_SSF, &val);
+        if (err != SASL_OK) {
+            VNC_DEBUG("cannot query SASL ssf on connection %d (%s)",
+                      err, sasl_errstring(err, NULL, NULL));
+            goto error;
+        }
+        ssf = *(const int *)val;
+        VNC_DEBUG("SASL SSF value %d", ssf);
+        if (ssf < 56) { /* 56 == DES level, good for Kerberos */
+            VNC_DEBUG("negotiation SSF %d was not strong enough", ssf);
+            goto error;
+        }
+    }
+
+    VNC_DEBUG("%s", "SASL authentication complete");
+    ret = vnc_connection_check_auth_result(conn);
+    /* This must come *after* check-auth-result, because the former
+     * is defined to be sent unencrypted, and setting saslconn turns
+     * on the SSF layer encryption processing */
+    priv->saslconn = saslconn;
+    return ret;
 
  error:
-	priv->has_error = TRUE;
-	if (saslconn)
-		sasl_dispose(&saslconn);
-	return FALSE;
+    priv->has_error = TRUE;
+    if (saslconn)
+        sasl_dispose(&saslconn);
+    return FALSE;
 }
 #endif /* HAVE_SASL */
 
 
 static gboolean vnc_connection_start_tls(VncConnection *conn, int anonTLS)
 {
-	VncConnectionPrivate *priv = conn->priv;
-#if defined(GNUTLS_VERSION_NUMBER) && \
+    VncConnectionPrivate *priv = conn->priv;
+#if defined(GNUTLS_VERSION_NUMBER) &&                   \
     GNUTLS_VERSION_NUMBER >= 0x020200 /* 2.2.0 */
-	const char *priority = anonTLS ? "NORMAL:+ANON-DH" : "NORMAL";
+    const char *priority = anonTLS ? "NORMAL:+ANON-DH" : "NORMAL";
 #else
-	static const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 };
-	static const int protocol_priority[]= { GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0 };
-	static const int kx_priority[] = {GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0};
-	static const int kx_anon[] = {GNUTLS_KX_ANON_DH, 0};
+    static const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 };
+    static const int protocol_priority[]= { GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0 };
+    static const int kx_priority[] = {GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0};
+    static const int kx_anon[] = {GNUTLS_KX_ANON_DH, 0};
 #endif
-	int ret;
-
-	VNC_DEBUG("Do TLS handshake");
-	if (vnc_connection_tls_initialize() < 0) {
-		VNC_DEBUG("Failed to init TLS");
-		priv->has_error = TRUE;
-		return FALSE;
-	}
-	if (priv->tls_session == NULL) {
-		if (gnutls_init(&priv->tls_session, GNUTLS_CLIENT) < 0) {
-			priv->has_error = TRUE;
-			return FALSE;
-		}
-
-#if defined(GNUTLS_VERSION_NUMBER) && \
-	GNUTLS_VERSION_NUMBER >= 0x020200 /* 2.2.0 */
-		if (gnutls_priority_set_direct(priv->tls_session, priority, NULL) < 0) {
-			gnutls_deinit(priv->tls_session);
-			priv->has_error = TRUE;
-			return FALSE;
-		}
+    int ret;
+
+    VNC_DEBUG("Do TLS handshake");
+    if (vnc_connection_tls_initialize() < 0) {
+        VNC_DEBUG("Failed to init TLS");
+        priv->has_error = TRUE;
+        return FALSE;
+    }
+    if (priv->tls_session == NULL) {
+        if (gnutls_init(&priv->tls_session, GNUTLS_CLIENT) < 0) {
+            priv->has_error = TRUE;
+            return FALSE;
+        }
+
+#if defined(GNUTLS_VERSION_NUMBER) &&                   \
+    GNUTLS_VERSION_NUMBER >= 0x020200 /* 2.2.0 */
+        if (gnutls_priority_set_direct(priv->tls_session, priority, NULL) < 0) {
+            gnutls_deinit(priv->tls_session);
+            priv->has_error = TRUE;
+            return FALSE;
+        }
 #else
-		if (gnutls_set_default_priority(priv->tls_session) < 0) {
-			gnutls_deinit(priv->tls_session);
-			priv->has_error = TRUE;
-			return FALSE;
-		}
-
-		if (gnutls_kx_set_priority(priv->tls_session, anonTLS ? kx_anon : kx_priority) < 0) {
-			gnutls_deinit(priv->tls_session);
-			priv->has_error = TRUE;
-			return FALSE;
-		}
-
-		if (gnutls_certificate_type_set_priority(priv->tls_session, cert_type_priority) < 0) {
-			gnutls_deinit(priv->tls_session);
-			priv->has_error = TRUE;
-			return FALSE;
-		}
-
-		if (gnutls_protocol_set_priority(priv->tls_session, protocol_priority) < 0) {
-			gnutls_deinit(priv->tls_session);
-			priv->has_error = TRUE;
-			return FALSE;
-		}
+        if (gnutls_set_default_priority(priv->tls_session) < 0) {
+            gnutls_deinit(priv->tls_session);
+            priv->has_error = TRUE;
+            return FALSE;
+        }
+
+        if (gnutls_kx_set_priority(priv->tls_session, anonTLS ? kx_anon : kx_priority) < 0) {
+            gnutls_deinit(priv->tls_session);
+            priv->has_error = TRUE;
+            return FALSE;
+        }
+
+        if (gnutls_certificate_type_set_priority(priv->tls_session, cert_type_priority) < 0) {
+            gnutls_deinit(priv->tls_session);
+            priv->has_error = TRUE;
+            return FALSE;
+        }
+
+        if (gnutls_protocol_set_priority(priv->tls_session, protocol_priority) < 0) {
+            gnutls_deinit(priv->tls_session);
+            priv->has_error = TRUE;
+            return FALSE;
+        }
 #endif
 
-		if (anonTLS) {
-			gnutls_anon_client_credentials anon_cred = vnc_connection_tls_initialize_anon_cred();
-			if (!anon_cred) {
-				gnutls_deinit(priv->tls_session);
-				priv->has_error = TRUE;
-				return FALSE;
-			}
-			if (gnutls_credentials_set(priv->tls_session, GNUTLS_CRD_ANON, anon_cred) < 0) {
-				gnutls_deinit(priv->tls_session);
-				priv->has_error = TRUE;
-				return FALSE;
-			}
-		} else {
-			priv->want_cred_password = FALSE;
-			priv->want_cred_username = FALSE;
-			priv->want_cred_x509 = TRUE;
-			if (!vnc_connection_gather_credentials(conn))
-				return FALSE;
-
-			gnutls_certificate_credentials_t x509_cred = vnc_connection_tls_initialize_cert_cred(conn);
-			if (!x509_cred) {
-				gnutls_deinit(priv->tls_session);
-				priv->has_error = TRUE;
-				return FALSE;
-			}
-			if (gnutls_credentials_set(priv->tls_session, GNUTLS_CRD_CERTIFICATE, x509_cred) < 0) {
-				gnutls_deinit(priv->tls_session);
-				priv->has_error = TRUE;
-				return FALSE;
-			}
-		}
-
-		gnutls_transport_set_ptr(priv->tls_session, (gnutls_transport_ptr_t)conn);
-		gnutls_transport_set_push_function(priv->tls_session, vnc_connection_tls_push);
-		gnutls_transport_set_pull_function(priv->tls_session, vnc_connection_tls_pull);
-	}
+        if (anonTLS) {
+            gnutls_anon_client_credentials anon_cred = vnc_connection_tls_initialize_anon_cred();
+            if (!anon_cred) {
+                gnutls_deinit(priv->tls_session);
+                priv->has_error = TRUE;
+                return FALSE;
+            }
+            if (gnutls_credentials_set(priv->tls_session, GNUTLS_CRD_ANON, anon_cred) < 0) {
+                gnutls_deinit(priv->tls_session);
+                priv->has_error = TRUE;
+                return FALSE;
+            }
+        } else {
+            priv->want_cred_password = FALSE;
+            priv->want_cred_username = FALSE;
+            priv->want_cred_x509 = TRUE;
+            if (!vnc_connection_gather_credentials(conn))
+                return FALSE;
+
+            gnutls_certificate_credentials_t x509_cred = vnc_connection_tls_initialize_cert_cred(conn);
+            if (!x509_cred) {
+                gnutls_deinit(priv->tls_session);
+                priv->has_error = TRUE;
+                return FALSE;
+            }
+            if (gnutls_credentials_set(priv->tls_session, GNUTLS_CRD_CERTIFICATE, x509_cred) < 0) {
+                gnutls_deinit(priv->tls_session);
+                priv->has_error = TRUE;
+                return FALSE;
+            }
+        }
+
+        gnutls_transport_set_ptr(priv->tls_session, (gnutls_transport_ptr_t)conn);
+        gnutls_transport_set_push_function(priv->tls_session, vnc_connection_tls_push);
+        gnutls_transport_set_pull_function(priv->tls_session, vnc_connection_tls_pull);
+    }
 
  retry:
-	if ((ret = gnutls_handshake(priv->tls_session)) < 0) {
-		if (!gnutls_error_is_fatal(ret)) {
-			VNC_DEBUG("Handshake was blocking");
-			if (!gnutls_record_get_direction(priv->tls_session))
-				g_io_wait(priv->sock, G_IO_IN);
-			else
-				g_io_wait(priv->sock, G_IO_OUT);
-			goto retry;
-		}
-		VNC_DEBUG("Handshake failed %s", gnutls_strerror(ret));
-		gnutls_deinit(priv->tls_session);
-		priv->tls_session = NULL;
-		priv->has_error = TRUE;
-		return FALSE;
-	}
-
-	VNC_DEBUG("Handshake done");
-
-	if (anonTLS) {
-		return TRUE;
-	} else {
-		if (!vnc_connection_validate_certificate(conn)) {
-			VNC_DEBUG("Certificate validation failed");
-			priv->has_error = TRUE;
-			return FALSE;
-		}
-		return TRUE;
-	}
+    if ((ret = gnutls_handshake(priv->tls_session)) < 0) {
+        if (!gnutls_error_is_fatal(ret)) {
+            VNC_DEBUG("Handshake was blocking");
+            if (!gnutls_record_get_direction(priv->tls_session))
+                g_io_wait(priv->sock, G_IO_IN);
+            else
+                g_io_wait(priv->sock, G_IO_OUT);
+            goto retry;
+        }
+        VNC_DEBUG("Handshake failed %s", gnutls_strerror(ret));
+        gnutls_deinit(priv->tls_session);
+        priv->tls_session = NULL;
+        priv->has_error = TRUE;
+        return FALSE;
+    }
+
+    VNC_DEBUG("Handshake done");
+
+    if (anonTLS) {
+        return TRUE;
+    } else {
+        if (!vnc_connection_validate_certificate(conn)) {
+            VNC_DEBUG("Certificate validation failed");
+            priv->has_error = TRUE;
+            return FALSE;
+        }
+        return TRUE;
+    }
 }
 
 static gboolean vnc_connection_has_auth_subtype(gpointer data)
 {
-	VncConnection *conn = data;
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnection *conn = data;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->has_error)
-		return TRUE;
-	if (priv->auth_subtype == VNC_CONNECTION_AUTH_INVALID)
-		return FALSE;
-	return TRUE;
+    if (priv->has_error)
+        return TRUE;
+    if (priv->auth_subtype == VNC_CONNECTION_AUTH_INVALID)
+        return FALSE;
+    return TRUE;
 }
 
 static void vnc_connection_choose_auth(VncConnection *conn,
-				       int signum,
-				       unsigned int ntypes,
-				       unsigned int *types)
+                                       int signum,
+                                       unsigned int ntypes,
+                                       unsigned int *types)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
+    GValueArray *authTypes;
+    GValue authType;
+
+    authTypes = g_value_array_new(0);
+
+    for (int i = 0 ; i < ntypes ; i++) {
+        memset(&authType, 0, sizeof(authType));
+
+        if (signum == VNC_AUTH_CHOOSE_TYPE) {
+            g_value_init(&authType, VNC_TYPE_CONNECTION_AUTH);
+        } else {
+            if (priv->auth_type == VNC_CONNECTION_AUTH_VENCRYPT)
+                g_value_init(&authType, VNC_TYPE_CONNECTION_AUTH_VENCRYPT);
+            else
+                g_value_init(&authType, VNC_TYPE_CONNECTION_AUTH);
+        }
+        g_value_set_enum(&authType, types[i]);
+        authTypes = g_value_array_append(authTypes, &authType);
+    }
+
+    sigdata.params.authCred = authTypes;
+    vnc_connection_emit_main_context(conn, signum, &sigdata);
+    g_value_array_free(authTypes);
+}
+
+static gboolean vnc_connection_perform_auth_tls(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	struct signal_data sigdata;
-	GValueArray *authTypes;
-	GValue authType;
+    VncConnectionPrivate *priv = conn->priv;
+    unsigned int nauth, i;
+    unsigned int auth[20];
 
-	authTypes = g_value_array_new(0);
+    if (!vnc_connection_start_tls(conn, 1)) {
+        VNC_DEBUG("Could not start TLS");
+        return FALSE;
+    }
+    VNC_DEBUG("Completed TLS setup");
 
-	for (int i = 0 ; i < ntypes ; i++) {
-		memset(&authType, 0, sizeof(authType));
+    nauth = vnc_connection_read_u8(conn);
+    VNC_DEBUG("Got %d subauths", nauth);
+    if (vnc_connection_has_error(conn))
+        return FALSE;
 
-		if (signum == VNC_AUTH_CHOOSE_TYPE) {
-			g_value_init(&authType, VNC_TYPE_CONNECTION_AUTH);
-		} else {
-			if (priv->auth_type == VNC_CONNECTION_AUTH_VENCRYPT)
-				g_value_init(&authType, VNC_TYPE_CONNECTION_AUTH_VENCRYPT);
-			else
-				g_value_init(&authType, VNC_TYPE_CONNECTION_AUTH);
-		}
-		g_value_set_enum(&authType, types[i]);
-		authTypes = g_value_array_append(authTypes, &authType);
-	}
+    VNC_DEBUG("Got %d subauths", nauth);
+    if (nauth == 0) {
+        VNC_DEBUG("No sub-auth types requested");
+        return vnc_connection_check_auth_result(conn);
+    }
 
-	sigdata.params.authCred = authTypes;
-	vnc_connection_emit_main_context(conn, signum, &sigdata);
-	g_value_array_free(authTypes);
-}
+    if (nauth > sizeof(auth)) {
+        VNC_DEBUG("Too many (%d) auth types", nauth);
+        priv->has_error = TRUE;
+        return FALSE;
+    }
+    for (i = 0 ; i < nauth ; i++) {
+        auth[i] = vnc_connection_read_u8(conn);
+    }
 
-static gboolean vnc_connection_perform_auth_tls(VncConnection *conn)
-{
-	VncConnectionPrivate *priv = conn->priv;
-	unsigned int nauth, i;
-	unsigned int auth[20];
-
-	if (!vnc_connection_start_tls(conn, 1)) {
-		VNC_DEBUG("Could not start TLS");
-		return FALSE;
-	}
-	VNC_DEBUG("Completed TLS setup");
-
-	nauth = vnc_connection_read_u8(conn);
-	VNC_DEBUG("Got %d subauths", nauth);
-	if (vnc_connection_has_error(conn))
-		return FALSE;
-
-	VNC_DEBUG("Got %d subauths", nauth);
-	if (nauth == 0) {
-		VNC_DEBUG("No sub-auth types requested");
-		return vnc_connection_check_auth_result(conn);
-	}
-
-	if (nauth > sizeof(auth)) {
-		VNC_DEBUG("Too many (%d) auth types", nauth);
-		priv->has_error = TRUE;
-		return FALSE;
-	}
-	for (i = 0 ; i < nauth ; i++) {
-		auth[i] = vnc_connection_read_u8(conn);
-	}
-
-	for (i = 0 ; i < nauth ; i++) {
-		VNC_DEBUG("Possible TLS sub-auth %d", auth[i]);
-	}
-
-	if (priv->has_error)
-		return FALSE;
-	vnc_connection_choose_auth(conn, VNC_AUTH_CHOOSE_SUBTYPE, nauth, auth);
-	if (priv->has_error)
-		return FALSE;
-
-	VNC_DEBUG("Waiting for TLS auth subtype");
-	g_condition_wait(vnc_connection_has_auth_subtype, conn);
-	if (priv->has_error)
-		return FALSE;
-
-	VNC_DEBUG("Choose auth %d", priv->auth_subtype);
-
-	vnc_connection_write_u8(conn, priv->auth_subtype);
-	vnc_connection_flush(conn);
-
-	switch (priv->auth_subtype) {
-	case VNC_CONNECTION_AUTH_NONE:
-		if (priv->minor == 8)
-			return vnc_connection_check_auth_result(conn);
-		return TRUE;
-	case VNC_CONNECTION_AUTH_VNC:
-		return vnc_connection_perform_auth_vnc(conn);
+    for (i = 0 ; i < nauth ; i++) {
+        VNC_DEBUG("Possible TLS sub-auth %d", auth[i]);
+    }
+
+    if (priv->has_error)
+        return FALSE;
+    vnc_connection_choose_auth(conn, VNC_AUTH_CHOOSE_SUBTYPE, nauth, auth);
+    if (priv->has_error)
+        return FALSE;
+
+    VNC_DEBUG("Waiting for TLS auth subtype");
+    g_condition_wait(vnc_connection_has_auth_subtype, conn);
+    if (priv->has_error)
+        return FALSE;
+
+    VNC_DEBUG("Choose auth %d", priv->auth_subtype);
+
+    vnc_connection_write_u8(conn, priv->auth_subtype);
+    vnc_connection_flush(conn);
+
+    switch (priv->auth_subtype) {
+    case VNC_CONNECTION_AUTH_NONE:
+        if (priv->minor == 8)
+            return vnc_connection_check_auth_result(conn);
+        return TRUE;
+    case VNC_CONNECTION_AUTH_VNC:
+        return vnc_connection_perform_auth_vnc(conn);
 #if HAVE_SASL
-	case VNC_CONNECTION_AUTH_SASL:
-		return vnc_connection_perform_auth_sasl(conn);
+    case VNC_CONNECTION_AUTH_SASL:
+        return vnc_connection_perform_auth_sasl(conn);
 #endif
-	default:
-		return FALSE;
-	}
+    default:
+        return FALSE;
+    }
 
-	return TRUE;
+    return TRUE;
 }
 
 static gboolean vnc_connection_perform_auth_vencrypt(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int major, minor, status, anonTLS;
-	unsigned int nauth, i;
-	unsigned int auth[20];
-
-	major = vnc_connection_read_u8(conn);
-	minor = vnc_connection_read_u8(conn);
-
-	if (major != 0 &&
-	    minor != 2) {
-		VNC_DEBUG("Unsupported VeNCrypt version %d %d", major, minor);
-		return FALSE;
-	}
-
-	vnc_connection_write_u8(conn, major);
-	vnc_connection_write_u8(conn, minor);
-	vnc_connection_flush(conn);
-	status = vnc_connection_read_u8(conn);
-	if (status != 0) {
-		VNC_DEBUG("Server refused VeNCrypt version %d %d", major, minor);
-		return FALSE;
-	}
-
-	nauth = vnc_connection_read_u8(conn);
-	if (nauth > (sizeof(auth)/sizeof(auth[0]))) {
-		VNC_DEBUG("Too many (%d) auth types", nauth);
-		return FALSE;
-	}
-
-	for (i = 0 ; i < nauth ; i++) {
-		auth[i] = vnc_connection_read_u32(conn);
-	}
-
-	for (i = 0 ; i < nauth ; i++) {
-		VNC_DEBUG("Possible VeNCrypt sub-auth %d", auth[i]);
-	}
-
-	if (priv->has_error)
-		return FALSE;
-	vnc_connection_choose_auth(conn, VNC_AUTH_CHOOSE_SUBTYPE, nauth, auth);
-	if (priv->has_error)
-		return FALSE;
-
-	VNC_DEBUG("Waiting for VeNCrypt auth subtype");
-	g_condition_wait(vnc_connection_has_auth_subtype, conn);
-	if (priv->has_error)
-		return FALSE;
-
-	VNC_DEBUG("Choose auth %d", priv->auth_subtype);
-
-	if (!vnc_connection_gather_credentials(conn))
-		return FALSE;
+    VncConnectionPrivate *priv = conn->priv;
+    int major, minor, status, anonTLS;
+    unsigned int nauth, i;
+    unsigned int auth[20];
+
+    major = vnc_connection_read_u8(conn);
+    minor = vnc_connection_read_u8(conn);
+
+    if (major != 0 &&
+        minor != 2) {
+        VNC_DEBUG("Unsupported VeNCrypt version %d %d", major, minor);
+        return FALSE;
+    }
+
+    vnc_connection_write_u8(conn, major);
+    vnc_connection_write_u8(conn, minor);
+    vnc_connection_flush(conn);
+    status = vnc_connection_read_u8(conn);
+    if (status != 0) {
+        VNC_DEBUG("Server refused VeNCrypt version %d %d", major, minor);
+        return FALSE;
+    }
+
+    nauth = vnc_connection_read_u8(conn);
+    if (nauth > (sizeof(auth)/sizeof(auth[0]))) {
+        VNC_DEBUG("Too many (%d) auth types", nauth);
+        return FALSE;
+    }
+
+    for (i = 0 ; i < nauth ; i++) {
+        auth[i] = vnc_connection_read_u32(conn);
+    }
+
+    for (i = 0 ; i < nauth ; i++) {
+        VNC_DEBUG("Possible VeNCrypt sub-auth %d", auth[i]);
+    }
+
+    if (priv->has_error)
+        return FALSE;
+    vnc_connection_choose_auth(conn, VNC_AUTH_CHOOSE_SUBTYPE, nauth, auth);
+    if (priv->has_error)
+        return FALSE;
+
+    VNC_DEBUG("Waiting for VeNCrypt auth subtype");
+    g_condition_wait(vnc_connection_has_auth_subtype, conn);
+    if (priv->has_error)
+        return FALSE;
+
+    VNC_DEBUG("Choose auth %d", priv->auth_subtype);
+
+    if (!vnc_connection_gather_credentials(conn))
+        return FALSE;
 
 #if !DEBUG
-	if (priv->auth_subtype == VNC_CONNECTION_AUTH_VENCRYPT_PLAIN) {
-		VNC_DEBUG("Cowardly refusing to transmit plain text password");
-		return FALSE;
-	}
+    if (priv->auth_subtype == VNC_CONNECTION_AUTH_VENCRYPT_PLAIN) {
+        VNC_DEBUG("Cowardly refusing to transmit plain text password");
+        return FALSE;
+    }
 #endif
 
-	vnc_connection_write_u32(conn, priv->auth_subtype);
-	vnc_connection_flush(conn);
-	status = vnc_connection_read_u8(conn);
-	if (status != 1) {
-		VNC_DEBUG("Server refused VeNCrypt auth %d %d", priv->auth_subtype, status);
-		return FALSE;
-	}
-
-	switch (priv->auth_subtype) {
-	case VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE:
-	case VNC_CONNECTION_AUTH_VENCRYPT_TLSPLAIN:
-	case VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC:
-	case VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL:
-		anonTLS = 1;
-		break;
-	default:
-		anonTLS = 0;
-	}
-
-	if (!vnc_connection_start_tls(conn, anonTLS)) {
-		VNC_DEBUG("Could not start TLS");
-		return FALSE;
-	}
-	VNC_DEBUG("Completed TLS setup, do subauth %d", priv->auth_subtype);
-
-	switch (priv->auth_subtype) {
-		/* Plain certificate based auth */
-	case VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE:
-	case VNC_CONNECTION_AUTH_VENCRYPT_X509NONE:
-		VNC_DEBUG("Completing auth");
-		return vnc_connection_check_auth_result(conn);
-
-		/* Regular VNC layered over TLS */
-	case VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC:
-	case VNC_CONNECTION_AUTH_VENCRYPT_X509VNC:
-		VNC_DEBUG("Handing off to VNC auth");
-		return vnc_connection_perform_auth_vnc(conn);
+    vnc_connection_write_u32(conn, priv->auth_subtype);
+    vnc_connection_flush(conn);
+    status = vnc_connection_read_u8(conn);
+    if (status != 1) {
+        VNC_DEBUG("Server refused VeNCrypt auth %d %d", priv->auth_subtype, status);
+        return FALSE;
+    }
+
+    switch (priv->auth_subtype) {
+    case VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE:
+    case VNC_CONNECTION_AUTH_VENCRYPT_TLSPLAIN:
+    case VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC:
+    case VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL:
+        anonTLS = 1;
+        break;
+    default:
+        anonTLS = 0;
+    }
+
+    if (!vnc_connection_start_tls(conn, anonTLS)) {
+        VNC_DEBUG("Could not start TLS");
+        return FALSE;
+    }
+    VNC_DEBUG("Completed TLS setup, do subauth %d", priv->auth_subtype);
+
+    switch (priv->auth_subtype) {
+        /* Plain certificate based auth */
+    case VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE:
+    case VNC_CONNECTION_AUTH_VENCRYPT_X509NONE:
+        VNC_DEBUG("Completing auth");
+        return vnc_connection_check_auth_result(conn);
+
+        /* Regular VNC layered over TLS */
+    case VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC:
+    case VNC_CONNECTION_AUTH_VENCRYPT_X509VNC:
+        VNC_DEBUG("Handing off to VNC auth");
+        return vnc_connection_perform_auth_vnc(conn);
 
 #if HAVE_SASL
-		/* SASL layered over TLS */
-	case VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL:
-	case VNC_CONNECTION_AUTH_VENCRYPT_X509SASL:
-		VNC_DEBUG("Handing off to SASL auth");
-		return vnc_connection_perform_auth_sasl(conn);
+        /* SASL layered over TLS */
+    case VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL:
+    case VNC_CONNECTION_AUTH_VENCRYPT_X509SASL:
+        VNC_DEBUG("Handing off to SASL auth");
+        return vnc_connection_perform_auth_sasl(conn);
 #endif
 
-	default:
-		VNC_DEBUG("Unknown auth subtype %d", priv->auth_subtype);
-		return FALSE;
-	}
+    default:
+        VNC_DEBUG("Unknown auth subtype %d", priv->auth_subtype);
+        return FALSE;
+    }
 }
 
 static gboolean vnc_connection_has_auth_type(gpointer data)
 {
-	VncConnection *conn = data;
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnection *conn = data;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (priv->has_error)
-		return TRUE;
-	if (priv->auth_type == VNC_CONNECTION_AUTH_INVALID)
-		return FALSE;
-	return TRUE;
+    if (priv->has_error)
+        return TRUE;
+    if (priv->auth_type == VNC_CONNECTION_AUTH_INVALID)
+        return FALSE;
+    return TRUE;
 }
 
 static gboolean vnc_connection_perform_auth(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	unsigned int nauth, i;
-	unsigned int auth[10];
-
-	if (priv->minor <= 6) {
-		nauth = 1;
-		auth[0] = vnc_connection_read_u32(conn);
-	} else {
-		nauth = vnc_connection_read_u8(conn);
-		if (vnc_connection_has_error(conn))
-			return FALSE;
-
-		if (nauth == 0)
-			return vnc_connection_check_auth_result(conn);
-
-		if (nauth > sizeof(auth)) {
-			priv->has_error = TRUE;
-			return FALSE;
-		}
-		for (i = 0 ; i < nauth ; i++)
-			auth[i] = vnc_connection_read_u8(conn);
-	}
-
-	for (i = 0 ; i < nauth ; i++) {
-		VNC_DEBUG("Possible auth %u", auth[i]);
-	}
-
-	if (priv->has_error)
-		return FALSE;
-	vnc_connection_choose_auth(conn, VNC_AUTH_CHOOSE_TYPE, nauth, auth);
-	if (priv->has_error)
-		return FALSE;
-
-	VNC_DEBUG("Waiting for auth type");
-	g_condition_wait(vnc_connection_has_auth_type, conn);
-	if (priv->has_error)
-		return FALSE;
-
-	VNC_DEBUG("Choose auth %u", priv->auth_type);
-	if (!vnc_connection_gather_credentials(conn))
-		return FALSE;
-
-	if (priv->minor > 6) {
-		vnc_connection_write_u8(conn, priv->auth_type);
-		vnc_connection_flush(conn);
-	}
-
-	switch (priv->auth_type) {
-	case VNC_CONNECTION_AUTH_NONE:
-		if (priv->minor == 8)
-			return vnc_connection_check_auth_result(conn);
-		return TRUE;
-	case VNC_CONNECTION_AUTH_VNC:
-		return vnc_connection_perform_auth_vnc(conn);
-
-	case VNC_CONNECTION_AUTH_TLS:
-		if (priv->minor < 7)
-			return FALSE;
-		return vnc_connection_perform_auth_tls(conn);
-
-	case VNC_CONNECTION_AUTH_VENCRYPT:
-		return vnc_connection_perform_auth_vencrypt(conn);
+    VncConnectionPrivate *priv = conn->priv;
+    unsigned int nauth, i;
+    unsigned int auth[10];
+
+    if (priv->minor <= 6) {
+        nauth = 1;
+        auth[0] = vnc_connection_read_u32(conn);
+    } else {
+        nauth = vnc_connection_read_u8(conn);
+        if (vnc_connection_has_error(conn))
+            return FALSE;
+
+        if (nauth == 0)
+            return vnc_connection_check_auth_result(conn);
+
+        if (nauth > sizeof(auth)) {
+            priv->has_error = TRUE;
+            return FALSE;
+        }
+        for (i = 0 ; i < nauth ; i++)
+            auth[i] = vnc_connection_read_u8(conn);
+    }
+
+    for (i = 0 ; i < nauth ; i++) {
+        VNC_DEBUG("Possible auth %u", auth[i]);
+    }
+
+    if (priv->has_error)
+        return FALSE;
+    vnc_connection_choose_auth(conn, VNC_AUTH_CHOOSE_TYPE, nauth, auth);
+    if (priv->has_error)
+        return FALSE;
+
+    VNC_DEBUG("Waiting for auth type");
+    g_condition_wait(vnc_connection_has_auth_type, conn);
+    if (priv->has_error)
+        return FALSE;
+
+    VNC_DEBUG("Choose auth %u", priv->auth_type);
+    if (!vnc_connection_gather_credentials(conn))
+        return FALSE;
+
+    if (priv->minor > 6) {
+        vnc_connection_write_u8(conn, priv->auth_type);
+        vnc_connection_flush(conn);
+    }
+
+    switch (priv->auth_type) {
+    case VNC_CONNECTION_AUTH_NONE:
+        if (priv->minor == 8)
+            return vnc_connection_check_auth_result(conn);
+        return TRUE;
+    case VNC_CONNECTION_AUTH_VNC:
+        return vnc_connection_perform_auth_vnc(conn);
+
+    case VNC_CONNECTION_AUTH_TLS:
+        if (priv->minor < 7)
+            return FALSE;
+        return vnc_connection_perform_auth_tls(conn);
+
+    case VNC_CONNECTION_AUTH_VENCRYPT:
+        return vnc_connection_perform_auth_vencrypt(conn);
 
 #if HAVE_SASL
-	case VNC_CONNECTION_AUTH_SASL:
- 		return vnc_connection_perform_auth_sasl(conn);
+    case VNC_CONNECTION_AUTH_SASL:
+        return vnc_connection_perform_auth_sasl(conn);
 #endif
 
-	case VNC_CONNECTION_AUTH_MSLOGON:
-		return vnc_connection_perform_auth_mslogon(conn);
+    case VNC_CONNECTION_AUTH_MSLOGON:
+        return vnc_connection_perform_auth_mslogon(conn);
 
-	case VNC_CONNECTION_AUTH_ARD:
-		return vnc_connection_perform_auth_ard(conn);
+    case VNC_CONNECTION_AUTH_ARD:
+        return vnc_connection_perform_auth_ard(conn);
 
-	default:
-		{
-			struct signal_data sigdata;
-			sigdata.params.authUnsupported = priv->auth_type;
-			vnc_connection_emit_main_context(conn, VNC_AUTH_UNSUPPORTED, &sigdata);
-			priv->has_error = TRUE;
-		}
-		return FALSE;
-	}
+    default:
+        {
+            struct signal_data sigdata;
+            sigdata.params.authUnsupported = priv->auth_type;
+            vnc_connection_emit_main_context(conn, VNC_AUTH_UNSUPPORTED, &sigdata);
+            priv->has_error = TRUE;
+        }
+        return FALSE;
+    }
 
-	return TRUE;
+    return TRUE;
 }
 
 static void vnc_connection_finalize (GObject *object)
 {
-	VncConnection *conn = VNC_CONNECTION(object);
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnection *conn = VNC_CONNECTION(object);
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Finalize VncConnection=%p", conn);
+    VNC_DEBUG("Finalize VncConnection=%p", conn);
 
-	if (vnc_connection_is_open(conn))
-		vnc_connection_close(conn);
+    if (vnc_connection_is_open(conn))
+        vnc_connection_close(conn);
 
-	if (priv->cursor)
-		g_object_unref(G_OBJECT(priv->cursor));
+    if (priv->cursor)
+        g_object_unref(G_OBJECT(priv->cursor));
 
-	if (priv->fb)
-		g_object_unref(G_OBJECT(priv->fb));
+    if (priv->fb)
+        g_object_unref(G_OBJECT(priv->fb));
 
-	if (priv->audio)
-		g_object_unref(G_OBJECT(priv->audio));
-	if (priv->audio_sample)
-		g_object_unref(G_OBJECT(priv->audio_sample));
-	if (priv->audio_timer)
-		g_source_remove(priv->audio_timer);
+    if (priv->audio)
+        g_object_unref(G_OBJECT(priv->audio));
+    if (priv->audio_sample)
+        g_object_unref(G_OBJECT(priv->audio_sample));
+    if (priv->audio_timer)
+        g_source_remove(priv->audio_timer);
 
-	G_OBJECT_CLASS(vnc_connection_parent_class)->finalize (object);
+    G_OBJECT_CLASS(vnc_connection_parent_class)->finalize (object);
 }
 
 static void vnc_connection_class_init(VncConnectionClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = vnc_connection_finalize;
-	object_class->get_property = vnc_connection_get_property;
-	object_class->set_property = vnc_connection_set_property;
-
-	g_object_class_install_property(object_class,
-					PROP_FRAMEBUFFER,
-					g_param_spec_object("framebuffer",
-							    "The desktop framebuffer",
-							    "The desktop framebuffer instance",
-							    VNC_TYPE_FRAMEBUFFER,
-							    G_PARAM_READABLE |
-							    G_PARAM_WRITABLE |
-							    G_PARAM_STATIC_NAME |
-							    G_PARAM_STATIC_NICK |
-							    G_PARAM_STATIC_BLURB));
-
-	signals[VNC_CURSOR_CHANGED] =
-		g_signal_new ("vnc-cursor-changed",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_cursor_changed),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__OBJECT,
-			      G_TYPE_NONE,
-			      1,
-			      VNC_TYPE_CURSOR);
-
-	signals[VNC_POINTER_MODE_CHANGED] =
-		g_signal_new ("vnc-pointer-mode-changed",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_pointer_mode_changed),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__BOOLEAN,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_BOOLEAN);
-
-	signals[VNC_BELL] =
-		g_signal_new ("vnc-bell",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_bell),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-
-	signals[VNC_SERVER_CUT_TEXT] =
-		g_signal_new ("vnc-server-cut-text",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_server_cut_text),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__STRING,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_STRING);
-
-	signals[VNC_FRAMEBUFFER_UPDATE] =
-		g_signal_new ("vnc-framebuffer-update",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_framebuffer_update),
-			      NULL, NULL,
-			      g_cclosure_user_marshal_VOID__INT_INT_INT_INT,
-			      G_TYPE_NONE,
-			      4,
-			      G_TYPE_INT,
-			      G_TYPE_INT,
-			      G_TYPE_INT,
-			      G_TYPE_INT);
-
-	signals[VNC_DESKTOP_RESIZE] =
-		g_signal_new ("vnc-desktop-resize",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_desktop_resize),
-			      NULL, NULL,
-			      g_cclosure_user_marshal_VOID__INT_INT,
-			      G_TYPE_NONE,
-			      2,
-			      G_TYPE_INT,
-			      G_TYPE_INT);
-
-	signals[VNC_PIXEL_FORMAT_CHANGED] =
-		g_signal_new ("vnc-pixel-format-changed",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_pixel_format_changed),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__POINTER,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_POINTER);
-
-	signals[VNC_AUTH_FAILURE] =
-		g_signal_new ("vnc-auth-failure",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_failure),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__STRING,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_STRING);
-
-
-	signals[VNC_AUTH_UNSUPPORTED] =
-		g_signal_new ("vnc-auth-unsupported",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_unsupported),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__UINT,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_UINT);
-
-	signals[VNC_AUTH_CREDENTIAL] =
-		g_signal_new ("vnc-auth-credential",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_credential),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__BOXED,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_VALUE_ARRAY);
-
-	signals[VNC_AUTH_CHOOSE_TYPE] =
-		g_signal_new ("vnc-auth-choose-type",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_choose_type),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__BOXED,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_VALUE_ARRAY);
-
-	signals[VNC_AUTH_CHOOSE_SUBTYPE] =
-		g_signal_new ("vnc-auth-choose-subtype",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_choose_subtype),
-			      NULL, NULL,
-			      g_cclosure_user_marshal_VOID__UINT_BOXED,
-			      G_TYPE_NONE,
-			      2,
-			      G_TYPE_UINT,
-			      G_TYPE_VALUE_ARRAY);
-
-
-	signals[VNC_CONNECTED] =
-		g_signal_new ("vnc-connected",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_connected),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-	signals[VNC_INITIALIZED] =
-		g_signal_new ("vnc-initialized",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_initialized),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-	signals[VNC_DISCONNECTED] =
-		g_signal_new ("vnc-disconnected",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncConnectionClass, vnc_disconnected),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-
-
-	g_type_class_add_private(klass, sizeof(VncConnectionPrivate));
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = vnc_connection_finalize;
+    object_class->get_property = vnc_connection_get_property;
+    object_class->set_property = vnc_connection_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_FRAMEBUFFER,
+                                    g_param_spec_object("framebuffer",
+                                                        "The desktop framebuffer",
+                                                        "The desktop framebuffer instance",
+                                                        VNC_TYPE_FRAMEBUFFER,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_WRITABLE |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+    signals[VNC_CURSOR_CHANGED] =
+        g_signal_new ("vnc-cursor-changed",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_cursor_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__OBJECT,
+                      G_TYPE_NONE,
+                      1,
+                      VNC_TYPE_CURSOR);
+
+    signals[VNC_POINTER_MODE_CHANGED] =
+        g_signal_new ("vnc-pointer-mode-changed",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_pointer_mode_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOOLEAN,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_BOOLEAN);
+
+    signals[VNC_BELL] =
+        g_signal_new ("vnc-bell",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_bell),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
+    signals[VNC_SERVER_CUT_TEXT] =
+        g_signal_new ("vnc-server-cut-text",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_server_cut_text),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_STRING);
+
+    signals[VNC_FRAMEBUFFER_UPDATE] =
+        g_signal_new ("vnc-framebuffer-update",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_framebuffer_update),
+                      NULL, NULL,
+                      g_cclosure_user_marshal_VOID__INT_INT_INT_INT,
+                      G_TYPE_NONE,
+                      4,
+                      G_TYPE_INT,
+                      G_TYPE_INT,
+                      G_TYPE_INT,
+                      G_TYPE_INT);
+
+    signals[VNC_DESKTOP_RESIZE] =
+        g_signal_new ("vnc-desktop-resize",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_desktop_resize),
+                      NULL, NULL,
+                      g_cclosure_user_marshal_VOID__INT_INT,
+                      G_TYPE_NONE,
+                      2,
+                      G_TYPE_INT,
+                      G_TYPE_INT);
+
+    signals[VNC_PIXEL_FORMAT_CHANGED] =
+        g_signal_new ("vnc-pixel-format-changed",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_pixel_format_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__POINTER,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_POINTER);
+
+    signals[VNC_AUTH_FAILURE] =
+        g_signal_new ("vnc-auth-failure",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_failure),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_STRING);
+
+
+    signals[VNC_AUTH_UNSUPPORTED] =
+        g_signal_new ("vnc-auth-unsupported",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_unsupported),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__UINT,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_UINT);
+
+    signals[VNC_AUTH_CREDENTIAL] =
+        g_signal_new ("vnc-auth-credential",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_credential),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOXED,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_VALUE_ARRAY);
+
+    signals[VNC_AUTH_CHOOSE_TYPE] =
+        g_signal_new ("vnc-auth-choose-type",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_choose_type),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOXED,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_VALUE_ARRAY);
+
+    signals[VNC_AUTH_CHOOSE_SUBTYPE] =
+        g_signal_new ("vnc-auth-choose-subtype",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_choose_subtype),
+                      NULL, NULL,
+                      g_cclosure_user_marshal_VOID__UINT_BOXED,
+                      G_TYPE_NONE,
+                      2,
+                      G_TYPE_UINT,
+                      G_TYPE_VALUE_ARRAY);
+
+
+    signals[VNC_CONNECTED] =
+        g_signal_new ("vnc-connected",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_connected),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+    signals[VNC_INITIALIZED] =
+        g_signal_new ("vnc-initialized",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_initialized),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+    signals[VNC_DISCONNECTED] =
+        g_signal_new ("vnc-disconnected",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncConnectionClass, vnc_disconnected),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
+
+    g_type_class_add_private(klass, sizeof(VncConnectionPrivate));
 }
 
 
 void vnc_connection_init(VncConnection *conn)
 {
-	VncConnectionPrivate *priv;
+    VncConnectionPrivate *priv;
 
-	VNC_DEBUG("Init VncConnection=%p", conn);
+    VNC_DEBUG("Init VncConnection=%p", conn);
 
-	priv = conn->priv = VNC_CONNECTION_GET_PRIVATE(conn);
+    priv = conn->priv = VNC_CONNECTION_GET_PRIVATE(conn);
 
-	memset(priv, 0, sizeof(*priv));
+    memset(priv, 0, sizeof(*priv));
 
-	priv->fd = -1;
-	priv->auth_type = VNC_CONNECTION_AUTH_INVALID;
-	priv->auth_subtype = VNC_CONNECTION_AUTH_INVALID;
+    priv->fd = -1;
+    priv->auth_type = VNC_CONNECTION_AUTH_INVALID;
+    priv->auth_subtype = VNC_CONNECTION_AUTH_INVALID;
 }
 
 
 VncConnection *vnc_connection_new(void)
 {
-	return VNC_CONNECTION(g_object_new(VNC_TYPE_CONNECTION,
-					   NULL));
+    return VNC_CONNECTION(g_object_new(VNC_TYPE_CONNECTION,
+                                       NULL));
 }
 
 static void vnc_connection_close(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int i;
+    VncConnectionPrivate *priv = conn->priv;
+    int i;
 
-	VNC_DEBUG("Close VncConnection=%p", conn);
+    VNC_DEBUG("Close VncConnection=%p", conn);
 
-	if (priv->tls_session) {
-		gnutls_bye(priv->tls_session, GNUTLS_SHUT_RDWR);
-		priv->tls_session = NULL;
-	}
+    if (priv->tls_session) {
+        gnutls_bye(priv->tls_session, GNUTLS_SHUT_RDWR);
+        priv->tls_session = NULL;
+    }
 #if HAVE_SASL
-	if (priv->saslconn) {
-		sasl_dispose (&priv->saslconn);
-		priv->saslconn = NULL;
-		priv->saslDecodedOffset = priv->saslDecodedLength = 0;
-	}
+    if (priv->saslconn) {
+        sasl_dispose (&priv->saslconn);
+        priv->saslconn = NULL;
+        priv->saslDecodedOffset = priv->saslDecodedLength = 0;
+    }
 #endif
 
-	if (priv->sock) {
-		g_object_unref(priv->sock);
-		priv->sock = NULL;
-	}
-	if (priv->fd != -1)
-		priv->fd = -1;
-
-	if (priv->host) {
-		g_free(priv->host);
-		priv->host = NULL;
-	}
-
-	if (priv->port) {
-		g_free(priv->port);
-		priv->port = NULL;
-	}
-
-	if (priv->name) {
-		g_free(priv->name);
-		priv->name = NULL;
-	}
-
-	if (priv->xmit_buffer) {
-		g_free(priv->xmit_buffer);
-		priv->xmit_buffer = NULL;
-		priv->xmit_buffer_size = 0;
-		priv->xmit_buffer_capacity = 0;
-	}
-
-	priv->read_offset = priv->read_size = 0;
-	priv->write_offset = 0;
-	priv->uncompressed_length = 0;
-	priv->compressed_length = 0;
-
-	priv->width = priv->height = 0;
-	priv->major = priv->minor = 0;
-
-	if (priv->cred_username) {
-		g_free(priv->cred_username);
-		priv->cred_username = NULL;
-	}
-	if (priv->cred_password) {
-		g_free(priv->cred_password);
-		priv->cred_password = NULL;
-	}
-
-	if (priv->cred_x509_cacert) {
-		g_free(priv->cred_x509_cacert);
-		priv->cred_x509_cacert = NULL;
-	}
-	if (priv->cred_x509_cacrl) {
-		g_free(priv->cred_x509_cacrl);
-		priv->cred_x509_cacrl = NULL;
-	}
-	if (priv->cred_x509_cert) {
-		g_free(priv->cred_x509_cert);
-		priv->cred_x509_cert = NULL;
-	}
-	if (priv->cred_x509_key) {
-		g_free(priv->cred_x509_key);
-		priv->cred_x509_key = NULL;
-	}
-
-	priv->want_cred_x509 = priv->want_cred_username =
-		priv->want_cred_password = FALSE;
-
-	for (i = 0; i < 5; i++)
-		inflateEnd(&priv->streams[i]);
-
-	priv->auth_type = VNC_CONNECTION_AUTH_INVALID;
-	priv->auth_subtype = VNC_CONNECTION_AUTH_INVALID;
-	priv->sharedFlag = FALSE;
-
-	memset(&priv->fmt, 0, sizeof(priv->fmt));
-
-	priv->has_error = FALSE;
+    if (priv->sock) {
+        g_object_unref(priv->sock);
+        priv->sock = NULL;
+    }
+    if (priv->fd != -1)
+        priv->fd = -1;
+
+    if (priv->host) {
+        g_free(priv->host);
+        priv->host = NULL;
+    }
+
+    if (priv->port) {
+        g_free(priv->port);
+        priv->port = NULL;
+    }
+
+    if (priv->name) {
+        g_free(priv->name);
+        priv->name = NULL;
+    }
+
+    if (priv->xmit_buffer) {
+        g_free(priv->xmit_buffer);
+        priv->xmit_buffer = NULL;
+        priv->xmit_buffer_size = 0;
+        priv->xmit_buffer_capacity = 0;
+    }
+
+    priv->read_offset = priv->read_size = 0;
+    priv->write_offset = 0;
+    priv->uncompressed_length = 0;
+    priv->compressed_length = 0;
+
+    priv->width = priv->height = 0;
+    priv->major = priv->minor = 0;
+
+    if (priv->cred_username) {
+        g_free(priv->cred_username);
+        priv->cred_username = NULL;
+    }
+    if (priv->cred_password) {
+        g_free(priv->cred_password);
+        priv->cred_password = NULL;
+    }
+
+    if (priv->cred_x509_cacert) {
+        g_free(priv->cred_x509_cacert);
+        priv->cred_x509_cacert = NULL;
+    }
+    if (priv->cred_x509_cacrl) {
+        g_free(priv->cred_x509_cacrl);
+        priv->cred_x509_cacrl = NULL;
+    }
+    if (priv->cred_x509_cert) {
+        g_free(priv->cred_x509_cert);
+        priv->cred_x509_cert = NULL;
+    }
+    if (priv->cred_x509_key) {
+        g_free(priv->cred_x509_key);
+        priv->cred_x509_key = NULL;
+    }
+
+    priv->want_cred_x509 = priv->want_cred_username =
+        priv->want_cred_password = FALSE;
+
+    for (i = 0; i < 5; i++)
+        inflateEnd(&priv->streams[i]);
+
+    priv->auth_type = VNC_CONNECTION_AUTH_INVALID;
+    priv->auth_subtype = VNC_CONNECTION_AUTH_INVALID;
+    priv->sharedFlag = FALSE;
+
+    memset(&priv->fmt, 0, sizeof(priv->fmt));
+
+    priv->has_error = FALSE;
 }
 
 void vnc_connection_shutdown(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Shutdown VncConnection=%p", conn);
+    VNC_DEBUG("Shutdown VncConnection=%p", conn);
 
-	if (priv->open_id) {
-		g_source_remove(priv->open_id);
-		priv->open_id = 0;
-	}
+    if (priv->open_id) {
+        g_source_remove(priv->open_id);
+        priv->open_id = 0;
+    }
 
-	priv->fd = -1;
-	priv->has_error = 1;
-	VNC_DEBUG("Waking up couroutine to shutdown gracefully");
-	g_io_wakeup(&priv->wait);
+    priv->fd = -1;
+    priv->has_error = 1;
+    VNC_DEBUG("Waking up couroutine to shutdown gracefully");
+    g_io_wakeup(&priv->wait);
 
-	/* Closing the socket triggers an I/O error in the
-	 * event loop resulting...eventually.. in a call
-	 * to vnc_connection_close for full cleanup
-	 */
-	if (priv->sock)
-		g_socket_close(priv->sock, NULL);
+    /* Closing the socket triggers an I/O error in the
+     * event loop resulting...eventually.. in a call
+     * to vnc_connection_close for full cleanup
+     */
+    if (priv->sock)
+        g_socket_close(priv->sock, NULL);
 }
 
 gboolean vnc_connection_is_open(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (!conn)
-		return FALSE;
+    if (!conn)
+        return FALSE;
 
-	if (priv->fd != -1)
-		return TRUE;
-	if (priv->sock != NULL)
-		return TRUE;
-	if (priv->host)
-		return TRUE;
-	return FALSE;
+    if (priv->fd != -1)
+        return TRUE;
+    if (priv->sock != NULL)
+        return TRUE;
+    if (priv->host)
+        return TRUE;
+    return FALSE;
 }
 
 
 gboolean vnc_connection_is_initialized(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	if (!vnc_connection_is_open(conn))
-		return FALSE;
-	if (priv->name)
-		return TRUE;
-	return FALSE;
+    if (!vnc_connection_is_open(conn))
+        return FALSE;
+    if (priv->name)
+        return TRUE;
+    return FALSE;
 }
 
 
 static gboolean vnc_connection_before_version (VncConnection *conn, int major, int minor)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return (priv->major < major) || (priv->major == major && priv->minor < minor);
+    return (priv->major < major) || (priv->major == major && priv->minor < minor);
 }
 
 
 static gboolean vnc_connection_after_version (VncConnection *conn, int major, int minor)
 {
-	return !vnc_connection_before_version (conn, major, minor+1);
+    return !vnc_connection_before_version (conn, major, minor+1);
 }
 
 
 static gboolean vnc_connection_initialize(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int ret, i;
-	char version[13];
-	guint32 n_name;
-
-	priv->absPointer = TRUE;
-
-	vnc_connection_read(conn, version, 12);
-	if (vnc_connection_has_error(conn)) {
-		VNC_DEBUG("Error while reading server version");
-		goto fail;
-	}
-
-	version[12] = 0;
-
- 	ret = sscanf(version, "RFB %03d.%03d\n", &priv->major, &priv->minor);
-	if (ret != 2) {
-		VNC_DEBUG("Error while parsing server version");
-		goto fail;
-	}
-
-	VNC_DEBUG("Server version: %d.%d", priv->major, priv->minor);
-
-	if (vnc_connection_before_version(conn, 3, 3)) {
-		VNC_DEBUG("Server version is not supported (%d.%d)", priv->major, priv->minor);
-		goto fail;
-	} else if (vnc_connection_before_version(conn, 3, 7)) {
-		priv->minor = 3;
-	} else if (vnc_connection_after_version(conn, 3, 8)) {
-		priv->major = 3;
-		priv->minor = 8;
-	}
-
-	snprintf(version, 13, "RFB %03d.%03d\n", priv->major, priv->minor);
-	vnc_connection_write(conn, version, 12);
-	vnc_connection_flush(conn);
-	VNC_DEBUG("Using version: %d.%d", priv->major, priv->minor);
-
-	if (!vnc_connection_perform_auth(conn)) {
-		VNC_DEBUG("Auth failed");
-		goto fail;
-	}
-
-	vnc_connection_write_u8(conn, priv->sharedFlag);
-	vnc_connection_flush(conn);
-	priv->width = vnc_connection_read_u16(conn);
-	priv->height = vnc_connection_read_u16(conn);
-
-	if (vnc_connection_has_error(conn))
-		return FALSE;
+    VncConnectionPrivate *priv = conn->priv;
+    int ret, i;
+    char version[13];
+    guint32 n_name;
+
+    priv->absPointer = TRUE;
+
+    vnc_connection_read(conn, version, 12);
+    if (vnc_connection_has_error(conn)) {
+        VNC_DEBUG("Error while reading server version");
+        goto fail;
+    }
+
+    version[12] = 0;
+
+    ret = sscanf(version, "RFB %03d.%03d\n", &priv->major, &priv->minor);
+    if (ret != 2) {
+        VNC_DEBUG("Error while parsing server version");
+        goto fail;
+    }
+
+    VNC_DEBUG("Server version: %d.%d", priv->major, priv->minor);
+
+    if (vnc_connection_before_version(conn, 3, 3)) {
+        VNC_DEBUG("Server version is not supported (%d.%d)", priv->major, priv->minor);
+        goto fail;
+    } else if (vnc_connection_before_version(conn, 3, 7)) {
+        priv->minor = 3;
+    } else if (vnc_connection_after_version(conn, 3, 8)) {
+        priv->major = 3;
+        priv->minor = 8;
+    }
+
+    snprintf(version, 13, "RFB %03d.%03d\n", priv->major, priv->minor);
+    vnc_connection_write(conn, version, 12);
+    vnc_connection_flush(conn);
+    VNC_DEBUG("Using version: %d.%d", priv->major, priv->minor);
+
+    if (!vnc_connection_perform_auth(conn)) {
+        VNC_DEBUG("Auth failed");
+        goto fail;
+    }
+
+    vnc_connection_write_u8(conn, priv->sharedFlag);
+    vnc_connection_flush(conn);
+    priv->width = vnc_connection_read_u16(conn);
+    priv->height = vnc_connection_read_u16(conn);
+
+    if (vnc_connection_has_error(conn))
+        return FALSE;
 
-	VNC_DEBUG("Initial desktop size %dx%d", priv->width, priv->height);
+    VNC_DEBUG("Initial desktop size %dx%d", priv->width, priv->height);
 
-	vnc_connection_read_pixel_format(conn, &priv->fmt);
+    vnc_connection_read_pixel_format(conn, &priv->fmt);
 
-	n_name = vnc_connection_read_u32(conn);
-	if (n_name > 4096)
-		goto fail;
+    n_name = vnc_connection_read_u32(conn);
+    if (n_name > 4096)
+        goto fail;
 
-	priv->name = g_new(char, n_name + 1);
+    priv->name = g_new(char, n_name + 1);
 
-	vnc_connection_read(conn, priv->name, n_name);
-	priv->name[n_name] = 0;
-	VNC_DEBUG("Display name '%s'", priv->name);
+    vnc_connection_read(conn, priv->name, n_name);
+    priv->name[n_name] = 0;
+    VNC_DEBUG("Display name '%s'", priv->name);
 
-	if (vnc_connection_has_error(conn))
-		return FALSE;
+    if (vnc_connection_has_error(conn))
+        return FALSE;
 
-	memset(&priv->strm, 0, sizeof(priv->strm));
-	/* FIXME what level? */
-	for (i = 0; i < 5; i++)
-		inflateInit(&priv->streams[i]);
-	priv->strm = NULL;
+    memset(&priv->strm, 0, sizeof(priv->strm));
+    /* FIXME what level? */
+    for (i = 0; i < 5; i++)
+        inflateInit(&priv->streams[i]);
+    priv->strm = NULL;
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 
  fail:
-	priv->has_error = TRUE;
-	return !vnc_connection_has_error(conn);
+    priv->has_error = TRUE;
+    return !vnc_connection_has_error(conn);
 }
 
 
 static gboolean vnc_connection_open_fd_internal(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Connecting to FD %d", priv->fd);
+    VNC_DEBUG("Connecting to FD %d", priv->fd);
 
-	if (!(priv->sock = g_socket_new_from_fd(priv->fd, NULL))) {
-		VNC_DEBUG("Failed to open socket from fd %d", priv->fd);
-		return FALSE;
-	}
+    if (!(priv->sock = g_socket_new_from_fd(priv->fd, NULL))) {
+        VNC_DEBUG("Failed to open socket from fd %d", priv->fd);
+        return FALSE;
+    }
 
-	g_socket_set_blocking(priv->sock, FALSE);
+    g_socket_set_blocking(priv->sock, FALSE);
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 static GSocket *vnc_connection_connect_socket(GSocketAddress *sockaddr,
-					      GError **error)
-{
-	GSocket *sock = g_socket_new(g_socket_address_get_family(sockaddr),
-				     G_SOCKET_TYPE_STREAM,
-				     G_SOCKET_PROTOCOL_DEFAULT,
-				     error);
-
-	if (!sock)
-		return NULL;
-
-	g_socket_set_blocking(sock, FALSE);
-	if (!g_socket_connect(sock, sockaddr, NULL, error)) {
-		if (*error && (*error)->code == G_IO_ERROR_PENDING) {
-			g_error_free(*error);
-			*error = NULL;
-			VNC_DEBUG("Socket pending");
-                        g_io_wait(sock, G_IO_OUT|G_IO_ERR|G_IO_HUP);
-
-			if (!g_socket_check_connect_result(sock, error)) {
-				VNC_DEBUG("Failed to connect %s", (*error)->message);
-				g_object_unref(sock);
-				return NULL;
-			}
-		} else {
-			VNC_DEBUG("Socket error: %s", *error ? (*error)->message : "unknown");
-			g_object_unref(sock);
-			return NULL;
-		}
-	}
+                                              GError **error)
+{
+    GSocket *sock = g_socket_new(g_socket_address_get_family(sockaddr),
+                                 G_SOCKET_TYPE_STREAM,
+                                 G_SOCKET_PROTOCOL_DEFAULT,
+                                 error);
+
+    if (!sock)
+        return NULL;
+
+    g_socket_set_blocking(sock, FALSE);
+    if (!g_socket_connect(sock, sockaddr, NULL, error)) {
+        if (*error && (*error)->code == G_IO_ERROR_PENDING) {
+            g_error_free(*error);
+            *error = NULL;
+            VNC_DEBUG("Socket pending");
+            g_io_wait(sock, G_IO_OUT|G_IO_ERR|G_IO_HUP);
+
+            if (!g_socket_check_connect_result(sock, error)) {
+                VNC_DEBUG("Failed to connect %s", (*error)->message);
+                g_object_unref(sock);
+                return NULL;
+            }
+        } else {
+            VNC_DEBUG("Socket error: %s", *error ? (*error)->message : "unknown");
+            g_object_unref(sock);
+            return NULL;
+        }
+    }
 
-	VNC_DEBUG("Finally connected");
+    VNC_DEBUG("Finally connected");
 
-	return sock;
+    return sock;
 }
 
 static gboolean vnc_connection_open_host_internal(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	GSocketConnectable *addr;
-	GSocketAddressEnumerator *enumerator;
-	GSocketAddress *sockaddr;
-	GError *conn_error = NULL;
-	GSocket *sock = NULL;
-	int port = atoi(priv->port);
-
-        VNC_DEBUG("Resolving host %s %s", priv->host, priv->port);
-
-	addr = g_network_address_new(priv->host, port);
-
-	enumerator = g_socket_connectable_enumerate (addr);
-	g_object_unref (addr);
-
-	/* Try each sockaddr until we succeed. Record the first
-	 * connection error, but not any further ones (since they'll probably
-	 * be basically the same as the first).
-	 */
-	while (!sock &&
-	       (sockaddr = g_socket_address_enumerator_next(enumerator, NULL, &conn_error))) {
-		VNC_DEBUG("Trying one socket");
-		g_clear_error(&conn_error);
-		sock = vnc_connection_connect_socket(sockaddr, &conn_error);
-		g_object_unref(sockaddr);
-	}
-	g_object_unref(enumerator);
-	g_clear_error(&conn_error);
-	if (sock) {
-		priv->sock = sock;
-		return TRUE;
-	}
-	return FALSE;
+    VncConnectionPrivate *priv = conn->priv;
+    GSocketConnectable *addr;
+    GSocketAddressEnumerator *enumerator;
+    GSocketAddress *sockaddr;
+    GError *conn_error = NULL;
+    GSocket *sock = NULL;
+    int port = atoi(priv->port);
+
+    VNC_DEBUG("Resolving host %s %s", priv->host, priv->port);
+
+    addr = g_network_address_new(priv->host, port);
+
+    enumerator = g_socket_connectable_enumerate (addr);
+    g_object_unref (addr);
+
+    /* Try each sockaddr until we succeed. Record the first
+     * connection error, but not any further ones (since they'll probably
+     * be basically the same as the first).
+     */
+    while (!sock &&
+           (sockaddr = g_socket_address_enumerator_next(enumerator, NULL, &conn_error))) {
+        VNC_DEBUG("Trying one socket");
+        g_clear_error(&conn_error);
+        sock = vnc_connection_connect_socket(sockaddr, &conn_error);
+        g_object_unref(sockaddr);
+    }
+    g_object_unref(enumerator);
+    g_clear_error(&conn_error);
+    if (sock) {
+        priv->sock = sock;
+        return TRUE;
+    }
+    return FALSE;
 }
 
 
@@ -4988,331 +4988,331 @@ static gboolean vnc_connection_open_host_internal(VncConnection *conn)
  * unref the object since the coroutine's state is part of the object */
 static gboolean vnc_connection_delayed_unref(gpointer data)
 {
-	VncConnection *conn = VNC_CONNECTION(data);
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnection *conn = VNC_CONNECTION(data);
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Delayed unref VncConnection=%p", conn);
+    VNC_DEBUG("Delayed unref VncConnection=%p", conn);
 
-	g_assert(priv->coroutine.exited == TRUE);
+    g_assert(priv->coroutine.exited == TRUE);
 
- 	g_object_unref(G_OBJECT(data));
+    g_object_unref(G_OBJECT(data));
 
-	return FALSE;
+    return FALSE;
 }
 
 static void *vnc_connection_coroutine(void *opaque)
 {
-	VncConnection *conn = VNC_CONNECTION(opaque);
-	VncConnectionPrivate *priv = conn->priv;
-	int ret;
-	struct signal_data s;
+    VncConnection *conn = VNC_CONNECTION(opaque);
+    VncConnectionPrivate *priv = conn->priv;
+    int ret;
+    struct signal_data s;
 
-	VNC_DEBUG("Started background coroutine");
+    VNC_DEBUG("Started background coroutine");
 
-	if (priv->fd != -1) {
-		if (!vnc_connection_open_fd_internal(conn))
-			goto cleanup;
-	} else {
-		if (!vnc_connection_open_host_internal(conn))
-			goto cleanup;
-	}
+    if (priv->fd != -1) {
+        if (!vnc_connection_open_fd_internal(conn))
+            goto cleanup;
+    } else {
+        if (!vnc_connection_open_host_internal(conn))
+            goto cleanup;
+    }
 
-	vnc_connection_emit_main_context(conn, VNC_CONNECTED, &s);
+    vnc_connection_emit_main_context(conn, VNC_CONNECTED, &s);
 
-	VNC_DEBUG("Protocol initialization");
-	if (!vnc_connection_initialize(conn))
-		goto cleanup;
+    VNC_DEBUG("Protocol initialization");
+    if (!vnc_connection_initialize(conn))
+        goto cleanup;
 
-	vnc_connection_emit_main_context(conn, VNC_INITIALIZED, &s);
+    vnc_connection_emit_main_context(conn, VNC_INITIALIZED, &s);
 
-	VNC_DEBUG("Running main loop");
-	while ((ret = vnc_connection_server_message(conn)))
-		;
+    VNC_DEBUG("Running main loop");
+    while ((ret = vnc_connection_server_message(conn)))
+        ;
 
  cleanup:
-	VNC_DEBUG("Doing final VNC cleanup");
-	vnc_connection_close(conn);
-	vnc_connection_emit_main_context(conn, VNC_DISCONNECTED, &s);
-	g_idle_add(vnc_connection_delayed_unref, conn);
-	/* Co-routine exits now - the VncDisplay object may no longer exist,
-	   so don't do anything else now unless you like SEGVs */
-	return NULL;
+    VNC_DEBUG("Doing final VNC cleanup");
+    vnc_connection_close(conn);
+    vnc_connection_emit_main_context(conn, VNC_DISCONNECTED, &s);
+    g_idle_add(vnc_connection_delayed_unref, conn);
+    /* Co-routine exits now - the VncDisplay object may no longer exist,
+       so don't do anything else now unless you like SEGVs */
+    return NULL;
 }
 
 static gboolean do_vnc_connection_open(gpointer data)
 {
-	VncConnection *conn = VNC_CONNECTION(data);
-	VncConnectionPrivate *priv = conn->priv;
-	struct coroutine *co;
+    VncConnection *conn = VNC_CONNECTION(data);
+    VncConnectionPrivate *priv = conn->priv;
+    struct coroutine *co;
 
-	VNC_DEBUG("Open coroutine starting");
-	priv->open_id = 0;
+    VNC_DEBUG("Open coroutine starting");
+    priv->open_id = 0;
 
-	co = &priv->coroutine;
+    co = &priv->coroutine;
 
-	co->stack_size = 16 << 20;
-	co->entry = vnc_connection_coroutine;
-	co->release = NULL;
+    co->stack_size = 16 << 20;
+    co->entry = vnc_connection_coroutine;
+    co->release = NULL;
 
-	coroutine_init(co);
-	coroutine_yieldto(co, conn);
+    coroutine_init(co);
+    coroutine_yieldto(co, conn);
 
-	return FALSE;
+    return FALSE;
 }
 
 gboolean vnc_connection_open_fd(VncConnection *conn, int fd)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Open fd=%d", fd);
+    VNC_DEBUG("Open fd=%d", fd);
 
-	if (vnc_connection_is_open(conn))
-		return FALSE;
+    if (vnc_connection_is_open(conn))
+        return FALSE;
 
-	priv->fd = fd;
-	priv->host = NULL;
-	priv->port = NULL;
+    priv->fd = fd;
+    priv->host = NULL;
+    priv->port = NULL;
 
-	g_object_ref(G_OBJECT(conn)); /* Unref'd when co-routine exits */
-	priv->open_id = g_idle_add(do_vnc_connection_open, conn);
+    g_object_ref(G_OBJECT(conn)); /* Unref'd when co-routine exits */
+    priv->open_id = g_idle_add(do_vnc_connection_open, conn);
 
-	return TRUE;
+    return TRUE;
 }
 
 gboolean vnc_connection_open_host(VncConnection *conn, const char *host, const char *port)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	VNC_DEBUG("Open host=%s port=%s", host, port);
+    VNC_DEBUG("Open host=%s port=%s", host, port);
 
-	if (vnc_connection_is_open(conn))
-		return FALSE;
+    if (vnc_connection_is_open(conn))
+        return FALSE;
 
-	priv->fd = -1;
-	priv->host = g_strdup(host);
-	priv->port = g_strdup(port);
+    priv->fd = -1;
+    priv->host = g_strdup(host);
+    priv->port = g_strdup(port);
 
-	g_object_ref(G_OBJECT(conn)); /* Unref'd when co-routine exits */
-	priv->open_id = g_idle_add(do_vnc_connection_open, conn);
+    g_object_ref(G_OBJECT(conn)); /* Unref'd when co-routine exits */
+    priv->open_id = g_idle_add(do_vnc_connection_open, conn);
 
-	return TRUE;
+    return TRUE;
 }
 
 
 gboolean vnc_connection_set_auth_type(VncConnection *conn, unsigned int type)
 {
-	VncConnectionPrivate *priv = conn->priv;
-
-        VNC_DEBUG("Thinking about auth type %u", type);
-        if (priv->auth_type != VNC_CONNECTION_AUTH_INVALID) {
-                priv->has_error = TRUE;
-                return !vnc_connection_has_error(conn);
-        }
-        if (type != VNC_CONNECTION_AUTH_NONE &&
-            type != VNC_CONNECTION_AUTH_VNC &&
-            type != VNC_CONNECTION_AUTH_MSLOGON &&
-            type != VNC_CONNECTION_AUTH_ARD &&
-            type != VNC_CONNECTION_AUTH_TLS &&
-            type != VNC_CONNECTION_AUTH_VENCRYPT &&
-            type != VNC_CONNECTION_AUTH_SASL) {
-		VNC_DEBUG("Unsupported auth type %u", type);
-		g_signal_emit(conn, VNC_AUTH_UNSUPPORTED, 0, type);
-                priv->has_error = TRUE;
-                return !vnc_connection_has_error(conn);
-        }
-        VNC_DEBUG("Decided on auth type %u", type);
-        priv->auth_type = type;
-        priv->auth_subtype = VNC_CONNECTION_AUTH_INVALID;
-
-	return !vnc_connection_has_error(conn);
+    VncConnectionPrivate *priv = conn->priv;
+
+    VNC_DEBUG("Thinking about auth type %u", type);
+    if (priv->auth_type != VNC_CONNECTION_AUTH_INVALID) {
+        priv->has_error = TRUE;
+        return !vnc_connection_has_error(conn);
+    }
+    if (type != VNC_CONNECTION_AUTH_NONE &&
+        type != VNC_CONNECTION_AUTH_VNC &&
+        type != VNC_CONNECTION_AUTH_MSLOGON &&
+        type != VNC_CONNECTION_AUTH_ARD &&
+        type != VNC_CONNECTION_AUTH_TLS &&
+        type != VNC_CONNECTION_AUTH_VENCRYPT &&
+        type != VNC_CONNECTION_AUTH_SASL) {
+        VNC_DEBUG("Unsupported auth type %u", type);
+        g_signal_emit(conn, VNC_AUTH_UNSUPPORTED, 0, type);
+        priv->has_error = TRUE;
+        return !vnc_connection_has_error(conn);
+    }
+    VNC_DEBUG("Decided on auth type %u", type);
+    priv->auth_type = type;
+    priv->auth_subtype = VNC_CONNECTION_AUTH_INVALID;
+
+    return !vnc_connection_has_error(conn);
 }
 
 gboolean vnc_connection_set_auth_subtype(VncConnection *conn, unsigned int type)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-        VNC_DEBUG("Requested auth subtype %d", type);
-        if (priv->auth_type != VNC_CONNECTION_AUTH_VENCRYPT &&
-	    priv->auth_type != VNC_CONNECTION_AUTH_TLS) {
-                priv->has_error = TRUE;
-		return !vnc_connection_has_error(conn);
-        }
-        if (priv->auth_subtype != VNC_CONNECTION_AUTH_INVALID) {
-                priv->has_error = TRUE;
-		return !vnc_connection_has_error(conn);
-        }
-        priv->auth_subtype = type;
+    VNC_DEBUG("Requested auth subtype %d", type);
+    if (priv->auth_type != VNC_CONNECTION_AUTH_VENCRYPT &&
+        priv->auth_type != VNC_CONNECTION_AUTH_TLS) {
+        priv->has_error = TRUE;
+        return !vnc_connection_has_error(conn);
+    }
+    if (priv->auth_subtype != VNC_CONNECTION_AUTH_INVALID) {
+        priv->has_error = TRUE;
+        return !vnc_connection_has_error(conn);
+    }
+    priv->auth_subtype = type;
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 static int vnc_connection_best_path(char **buf,
-				    const char *basedir,
-				    const char *basefile,
-				    char **dirs,
-				    unsigned int ndirs)
-{
-	unsigned int i;
-	gchar *tmp;
-	for (i = 0 ; i < ndirs ; i++) {
-		struct stat sb;
-		tmp = g_strdup_printf("%s/%s/%s", dirs[i], basedir, basefile);
-		if (stat(tmp, &sb) == 0) {
-			*buf = tmp;
-			return 0;
-		}
-		g_free(tmp);
-	}
-	VNC_DEBUG("Failed to find certificate %s/%s", basedir, basefile);
-	return -1;
+                                    const char *basedir,
+                                    const char *basefile,
+                                    char **dirs,
+                                    unsigned int ndirs)
+{
+    unsigned int i;
+    gchar *tmp;
+    for (i = 0 ; i < ndirs ; i++) {
+        struct stat sb;
+        tmp = g_strdup_printf("%s/%s/%s", dirs[i], basedir, basefile);
+        if (stat(tmp, &sb) == 0) {
+            *buf = tmp;
+            return 0;
+        }
+        g_free(tmp);
+    }
+    VNC_DEBUG("Failed to find certificate %s/%s", basedir, basefile);
+    return -1;
 }
 
 
 
 static gboolean vnc_connection_set_credential_x509(VncConnection *conn,
-						   const gchar *name)
+                                                   const gchar *name)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	char *sysdir = g_strdup_printf("%s/pki", SYSCONFDIR);
+    VncConnectionPrivate *priv = conn->priv;
+    char *sysdir = g_strdup_printf("%s/pki", SYSCONFDIR);
 #ifndef WIN32
-	struct passwd *pw;
+    struct passwd *pw;
 
-	if (!(pw = getpwuid(getuid())))
-		return TRUE;
+    if (!(pw = getpwuid(getuid())))
+        return TRUE;
 
-	char *userdir = g_strdup_printf("%s/.pki", pw->pw_dir);
-	char *dirs[] = { sysdir, userdir };
+    char *userdir = g_strdup_printf("%s/.pki", pw->pw_dir);
+    char *dirs[] = { sysdir, userdir };
 #else
-	char *dirs[] = { sysdir };
+    char *dirs[] = { sysdir };
 #endif
-	for (int i = 0 ; i < sizeof(dirs)/sizeof(dirs[0]) ; i++)
-		VNC_DEBUG("Searching for certs in %s", dirs[i]);
+    for (int i = 0 ; i < sizeof(dirs)/sizeof(dirs[0]) ; i++)
+        VNC_DEBUG("Searching for certs in %s", dirs[i]);
 
-	if (vnc_connection_best_path(&priv->cred_x509_cacert, "CA", "cacert.pem",
-				     dirs, sizeof(dirs)/sizeof(dirs[0])) < 0)
-		return FALSE;
+    if (vnc_connection_best_path(&priv->cred_x509_cacert, "CA", "cacert.pem",
+                                 dirs, sizeof(dirs)/sizeof(dirs[0])) < 0)
+        return FALSE;
 
-	/* Don't mind failures of CRL */
-	vnc_connection_best_path(&priv->cred_x509_cacrl, "CA", "cacrl.pem",
-				 dirs, sizeof(dirs)/sizeof(dirs[0]));
+    /* Don't mind failures of CRL */
+    vnc_connection_best_path(&priv->cred_x509_cacrl, "CA", "cacrl.pem",
+                             dirs, sizeof(dirs)/sizeof(dirs[0]));
 
-	/* Set client key & cert if we have them. Server will reject auth
-	 * if it decides it requires them*/
-	vnc_connection_best_path(&priv->cred_x509_key, name, "private/clientkey.pem",
-				 dirs, sizeof(dirs)/sizeof(dirs[0]));
-	vnc_connection_best_path(&priv->cred_x509_cert, name, "clientcert.pem",
-				 dirs, sizeof(dirs)/sizeof(dirs[0]));
+    /* Set client key & cert if we have them. Server will reject auth
+     * if it decides it requires them*/
+    vnc_connection_best_path(&priv->cred_x509_key, name, "private/clientkey.pem",
+                             dirs, sizeof(dirs)/sizeof(dirs[0]));
+    vnc_connection_best_path(&priv->cred_x509_cert, name, "clientcert.pem",
+                             dirs, sizeof(dirs)/sizeof(dirs[0]));
 
-	return TRUE;
+    return TRUE;
 }
 
 gboolean vnc_connection_set_credential(VncConnection *conn, int type, const gchar *data)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-        VNC_DEBUG("Set credential %d %s", type, data);
-	switch (type) {
-	case VNC_CONNECTION_CREDENTIAL_PASSWORD:
-		g_free(priv->cred_password);
-		priv->cred_password = g_strdup(data);
-		break;
+    VNC_DEBUG("Set credential %d %s", type, data);
+    switch (type) {
+    case VNC_CONNECTION_CREDENTIAL_PASSWORD:
+        g_free(priv->cred_password);
+        priv->cred_password = g_strdup(data);
+        break;
 
-	case VNC_CONNECTION_CREDENTIAL_USERNAME:
-		g_free(priv->cred_username);
-		priv->cred_username = g_strdup(data);
-		break;
+    case VNC_CONNECTION_CREDENTIAL_USERNAME:
+        g_free(priv->cred_username);
+        priv->cred_username = g_strdup(data);
+        break;
 
-	case VNC_CONNECTION_CREDENTIAL_CLIENTNAME:
-                g_free(priv->cred_x509_cacert);
-		g_free(priv->cred_x509_cacrl);
-		g_free(priv->cred_x509_key);
-                g_free(priv->cred_x509_cert);
-		return vnc_connection_set_credential_x509(conn, data);
+    case VNC_CONNECTION_CREDENTIAL_CLIENTNAME:
+        g_free(priv->cred_x509_cacert);
+        g_free(priv->cred_x509_cacrl);
+        g_free(priv->cred_x509_key);
+        g_free(priv->cred_x509_cert);
+        return vnc_connection_set_credential_x509(conn, data);
 
-	default:
-		priv->has_error = TRUE;
-	}
+    default:
+        priv->has_error = TRUE;
+    }
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 
 gboolean vnc_connection_set_framebuffer(VncConnection *conn, VncFramebuffer *fb)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	const VncPixelFormat *remote;
-	int i;
+    VncConnectionPrivate *priv = conn->priv;
+    const VncPixelFormat *remote;
+    int i;
 
-	VNC_DEBUG("Set framebuffer %p", fb);
+    VNC_DEBUG("Set framebuffer %p", fb);
 
-	if (priv->fb)
-		g_object_unref(G_OBJECT(priv->fb));
-	priv->fb = fb;
-	g_object_ref(G_OBJECT(priv->fb));
+    if (priv->fb)
+        g_object_unref(G_OBJECT(priv->fb));
+    priv->fb = fb;
+    g_object_ref(G_OBJECT(priv->fb));
 
-	remote = vnc_framebuffer_get_remote_format(priv->fb);
+    remote = vnc_framebuffer_get_remote_format(priv->fb);
 
-	priv->fbSwapRemote = remote->byte_order != G_BYTE_ORDER;
+    priv->fbSwapRemote = remote->byte_order != G_BYTE_ORDER;
 
-        i = priv->fmt.bits_per_pixel / 8;
+    i = priv->fmt.bits_per_pixel / 8;
 
-        if (i == 4) i = 3;
+    if (i == 4) i = 3;
 
-	priv->rich_cursor_blt = vnc_connection_rich_cursor_blt_table[i - 1];
-	priv->tight_compute_predicted = vnc_connection_tight_compute_predicted_table[i - 1];
-	priv->tight_sum_pixel = vnc_connection_tight_sum_pixel_table[i - 1];
+    priv->rich_cursor_blt = vnc_connection_rich_cursor_blt_table[i - 1];
+    priv->tight_compute_predicted = vnc_connection_tight_compute_predicted_table[i - 1];
+    priv->tight_sum_pixel = vnc_connection_tight_sum_pixel_table[i - 1];
 
-	return !vnc_connection_has_error(conn);
+    return !vnc_connection_has_error(conn);
 }
 
 const char *vnc_connection_get_name(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->name;
+    return priv->name;
 }
 
 int vnc_connection_get_width(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->width;
+    return priv->width;
 }
 
 int vnc_connection_get_height(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->height;
+    return priv->height;
 }
 
 gboolean vnc_connection_get_ext_key_event(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->has_ext_key_event;
+    return priv->has_ext_key_event;
 }
 
 VncCursor *vnc_connection_get_cursor(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->cursor;
+    return priv->cursor;
 }
 
 
 gboolean vnc_connection_get_abs_pointer(VncConnection *conn)
 {
-	VncConnectionPrivate *priv = conn->priv;
+    VncConnectionPrivate *priv = conn->priv;
 
-	return priv->absPointer;
+    return priv->absPointer;
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncconnection.h b/src/vncconnection.h
index ee05d29..b8b1343 100644
--- a/src/vncconnection.h
+++ b/src/vncconnection.h
@@ -45,109 +45,109 @@ typedef struct _VncConnectionClass VncConnectionClass;
 
 struct _VncConnection
 {
-	GObject parent;
+    GObject parent;
 
-	VncConnectionPrivate *priv;
+    VncConnectionPrivate *priv;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 struct _VncConnectionClass
 {
-	GObjectClass parent_class;
-
-	/* Signals */
-	void (*vnc_cursor_changed)(VncConnection *conn, VncCursor *cursor);
-	void (*vnc_pointer_mode_changed)(VncConnection *conn, gboolean absPointer);
-	void (*vnc_bell)(VncConnection *conn);
-	void (*vnc_server_cut_text)(VncConnection *conn, const GString *text);
-	void (*vnc_framebuffer_update)(VncConnection *conn, guint16 x, guint16 y, guint16 width, guint16 height);
-	void (*vnc_desktop_resize)(VncConnection *conn, guint16 width, guint16 height);
-	void (*vnc_pixel_format_changed)(VncConnection *conn, VncPixelFormat *format);
-	void (*vnc_auth_failure)(VncConnection *conn, const char *reason);
-	void (*vnc_auth_unsupported)(VncConnection *conn, unsigned int authType);
-	void (*vnc_auth_credential)(VncConnection *conn, GValueArray *creds);
-	void (*vnc_auth_choose_type)(VncConnection *conn, GValueArray *types);
-	void (*vnc_auth_choose_subtype)(VncConnection *conn, unsigned int type, GValueArray *subtypes);
-	void (*vnc_connected)(VncConnection *conn);
-	void (*vnc_initialized)(VncConnection *conn);
-	void (*vnc_disconnected)(VncConnection *conn);
-
-	/*
-	 * If adding fields to this struct, remove corresponding
-	 * amount of padding to avoid changing overall struct size
-	 */
-	gpointer _vnc_reserved[VNC_PADDING_LARGE];
+    GObjectClass parent_class;
+
+    /* Signals */
+    void (*vnc_cursor_changed)(VncConnection *conn, VncCursor *cursor);
+    void (*vnc_pointer_mode_changed)(VncConnection *conn, gboolean absPointer);
+    void (*vnc_bell)(VncConnection *conn);
+    void (*vnc_server_cut_text)(VncConnection *conn, const GString *text);
+    void (*vnc_framebuffer_update)(VncConnection *conn, guint16 x, guint16 y, guint16 width, guint16 height);
+    void (*vnc_desktop_resize)(VncConnection *conn, guint16 width, guint16 height);
+    void (*vnc_pixel_format_changed)(VncConnection *conn, VncPixelFormat *format);
+    void (*vnc_auth_failure)(VncConnection *conn, const char *reason);
+    void (*vnc_auth_unsupported)(VncConnection *conn, unsigned int authType);
+    void (*vnc_auth_credential)(VncConnection *conn, GValueArray *creds);
+    void (*vnc_auth_choose_type)(VncConnection *conn, GValueArray *types);
+    void (*vnc_auth_choose_subtype)(VncConnection *conn, unsigned int type, GValueArray *subtypes);
+    void (*vnc_connected)(VncConnection *conn);
+    void (*vnc_initialized)(VncConnection *conn);
+    void (*vnc_disconnected)(VncConnection *conn);
+
+    /*
+     * If adding fields to this struct, remove corresponding
+     * amount of padding to avoid changing overall struct size
+     */
+    gpointer _vnc_reserved[VNC_PADDING_LARGE];
 };
 
 
 typedef enum {
-	VNC_CONNECTION_ENCODING_RAW = 0,
-	VNC_CONNECTION_ENCODING_COPY_RECT = 1,
-	VNC_CONNECTION_ENCODING_RRE = 2,
-	VNC_CONNECTION_ENCODING_CORRE = 4,
-	VNC_CONNECTION_ENCODING_HEXTILE = 5,
-	VNC_CONNECTION_ENCODING_TIGHT = 7,
-	VNC_CONNECTION_ENCODING_ZRLE = 16,
-
-	/* Tight JPEG quality levels */
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG0 = -32,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG1 = -31,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG2 = -30,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG3 = -29,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG4 = -28,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG5 = -27,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG6 = -26,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG7 = -25,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG8 = -24,
-	VNC_CONNECTION_ENCODING_TIGHT_JPEG9 = -23,
-
-	/* Pseudo encodings */
-	VNC_CONNECTION_ENCODING_DESKTOP_RESIZE = -223,
-        VNC_CONNECTION_ENCODING_WMVi = 0x574D5669,
-
-	VNC_CONNECTION_ENCODING_CURSOR_POS = -232,
-	VNC_CONNECTION_ENCODING_RICH_CURSOR = -239,
-	VNC_CONNECTION_ENCODING_XCURSOR = -240,
-
-	VNC_CONNECTION_ENCODING_POINTER_CHANGE = -257,
-	VNC_CONNECTION_ENCODING_EXT_KEY_EVENT = -258,
-	VNC_CONNECTION_ENCODING_AUDIO = -259,
+    VNC_CONNECTION_ENCODING_RAW = 0,
+    VNC_CONNECTION_ENCODING_COPY_RECT = 1,
+    VNC_CONNECTION_ENCODING_RRE = 2,
+    VNC_CONNECTION_ENCODING_CORRE = 4,
+    VNC_CONNECTION_ENCODING_HEXTILE = 5,
+    VNC_CONNECTION_ENCODING_TIGHT = 7,
+    VNC_CONNECTION_ENCODING_ZRLE = 16,
+
+    /* Tight JPEG quality levels */
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG0 = -32,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG1 = -31,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG2 = -30,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG3 = -29,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG4 = -28,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG5 = -27,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG6 = -26,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG7 = -25,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG8 = -24,
+    VNC_CONNECTION_ENCODING_TIGHT_JPEG9 = -23,
+
+    /* Pseudo encodings */
+    VNC_CONNECTION_ENCODING_DESKTOP_RESIZE = -223,
+    VNC_CONNECTION_ENCODING_WMVi = 0x574D5669,
+
+    VNC_CONNECTION_ENCODING_CURSOR_POS = -232,
+    VNC_CONNECTION_ENCODING_RICH_CURSOR = -239,
+    VNC_CONNECTION_ENCODING_XCURSOR = -240,
+
+    VNC_CONNECTION_ENCODING_POINTER_CHANGE = -257,
+    VNC_CONNECTION_ENCODING_EXT_KEY_EVENT = -258,
+    VNC_CONNECTION_ENCODING_AUDIO = -259,
 } VncConnectionEncoding;
 
 typedef enum {
-	VNC_CONNECTION_AUTH_INVALID = 0,
-	VNC_CONNECTION_AUTH_NONE = 1,
-	VNC_CONNECTION_AUTH_VNC = 2,
-	VNC_CONNECTION_AUTH_RA2 = 5,
-	VNC_CONNECTION_AUTH_RA2NE = 6,
-	VNC_CONNECTION_AUTH_TIGHT = 16,
-	VNC_CONNECTION_AUTH_ULTRA = 17,
-	VNC_CONNECTION_AUTH_TLS = 18,  /* Used by VINO */
-	VNC_CONNECTION_AUTH_VENCRYPT = 19, /* Used by VeNCrypt and QEMU */
- 	VNC_CONNECTION_AUTH_SASL = 20, /* SASL type used by VINO and QEMU */
-	VNC_CONNECTION_AUTH_ARD = 30, /* Apple remote desktop (screen sharing) */
-	VNC_CONNECTION_AUTH_MSLOGON = 0xfffffffa, /* Used by UltraVNC */
+    VNC_CONNECTION_AUTH_INVALID = 0,
+    VNC_CONNECTION_AUTH_NONE = 1,
+    VNC_CONNECTION_AUTH_VNC = 2,
+    VNC_CONNECTION_AUTH_RA2 = 5,
+    VNC_CONNECTION_AUTH_RA2NE = 6,
+    VNC_CONNECTION_AUTH_TIGHT = 16,
+    VNC_CONNECTION_AUTH_ULTRA = 17,
+    VNC_CONNECTION_AUTH_TLS = 18,  /* Used by VINO */
+    VNC_CONNECTION_AUTH_VENCRYPT = 19, /* Used by VeNCrypt and QEMU */
+    VNC_CONNECTION_AUTH_SASL = 20, /* SASL type used by VINO and QEMU */
+    VNC_CONNECTION_AUTH_ARD = 30, /* Apple remote desktop (screen sharing) */
+    VNC_CONNECTION_AUTH_MSLOGON = 0xfffffffa, /* Used by UltraVNC */
 } VncConnectionAuth;
 
 typedef enum {
-	VNC_CONNECTION_AUTH_VENCRYPT_PLAIN = 256,
-	VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE = 257,
-	VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC = 258,
-	VNC_CONNECTION_AUTH_VENCRYPT_TLSPLAIN = 259,
-	VNC_CONNECTION_AUTH_VENCRYPT_X509NONE = 260,
-	VNC_CONNECTION_AUTH_VENCRYPT_X509VNC = 261,
-	VNC_CONNECTION_AUTH_VENCRYPT_X509PLAIN = 262,
-	VNC_CONNECTION_AUTH_VENCRYPT_X509SASL = 263,
-	VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL = 264,
+    VNC_CONNECTION_AUTH_VENCRYPT_PLAIN = 256,
+    VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE = 257,
+    VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC = 258,
+    VNC_CONNECTION_AUTH_VENCRYPT_TLSPLAIN = 259,
+    VNC_CONNECTION_AUTH_VENCRYPT_X509NONE = 260,
+    VNC_CONNECTION_AUTH_VENCRYPT_X509VNC = 261,
+    VNC_CONNECTION_AUTH_VENCRYPT_X509PLAIN = 262,
+    VNC_CONNECTION_AUTH_VENCRYPT_X509SASL = 263,
+    VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL = 264,
 } VncConnectionAuthVencrypt;
 
 typedef enum
-{
-	VNC_CONNECTION_CREDENTIAL_PASSWORD,
-	VNC_CONNECTION_CREDENTIAL_USERNAME,
-	VNC_CONNECTION_CREDENTIAL_CLIENTNAME,
-} VncConnectionCredential;
+    {
+        VNC_CONNECTION_CREDENTIAL_PASSWORD,
+        VNC_CONNECTION_CREDENTIAL_USERNAME,
+        VNC_CONNECTION_CREDENTIAL_CLIENTNAME,
+    } VncConnectionCredential;
 
 GType vnc_connection_get_type(void) G_GNUC_CONST;
 
@@ -165,23 +165,23 @@ gboolean vnc_connection_set_credential(VncConnection *conn, int type, const gcha
 gboolean vnc_connection_is_initialized(VncConnection *conn);
 
 gboolean vnc_connection_client_cut_text(VncConnection *conn,
-					const void *data, size_t length);
+                                        const void *data, size_t length);
 
 gboolean vnc_connection_pointer_event(VncConnection *conn, guint8 button_mask,
-				      guint16 x, guint16 y);
+                                      guint16 x, guint16 y);
 
 gboolean vnc_connection_key_event(VncConnection *conn, gboolean down_flag,
-				  guint32 key, guint16 scancode);
+                                  guint32 key, guint16 scancode);
 
 gboolean vnc_connection_framebuffer_update_request(VncConnection *conn,
-						   gboolean incremental,
-						   guint16 x, guint16 y,
-						   guint16 width, guint16 height);
+                                                   gboolean incremental,
+                                                   guint16 x, guint16 y,
+                                                   guint16 width, guint16 height);
 
 gboolean vnc_connection_set_encodings(VncConnection *conn, int n_encoding, gint32 *encoding);
 
 gboolean vnc_connection_set_pixel_format(VncConnection *conn,
-					 const VncPixelFormat *fmt);
+                                         const VncPixelFormat *fmt);
 
 const VncPixelFormat *vnc_connection_get_pixel_format(VncConnection *conn);
 
@@ -191,7 +191,7 @@ gboolean vnc_connection_get_shared(VncConnection *conn);
 gboolean vnc_connection_has_error(VncConnection *conn);
 
 gboolean vnc_connection_set_framebuffer(VncConnection *conn,
-					VncFramebuffer *fb);
+                                        VncFramebuffer *fb);
 
 const char *vnc_connection_get_name(VncConnection *conn);
 int vnc_connection_get_width(VncConnection *conn);
@@ -203,10 +203,10 @@ gboolean vnc_connection_get_abs_pointer(VncConnection *conn);
 gboolean vnc_connection_get_ext_key_event(VncConnection *conn);
 
 gboolean vnc_connection_set_audio(VncConnection *conn,
-				  VncAudio *audio);
+                                  VncAudio *audio);
 
 gboolean vnc_connection_set_audio_format(VncConnection *conn,
-					 const VncAudioFormat *fmt);
+                                         const VncAudioFormat *fmt);
 const VncAudioFormat *vnc_connection_get_audio_format(VncConnection *conn);
 
 gboolean vnc_connection_audio_enable(VncConnection *conn);
@@ -218,8 +218,8 @@ G_END_DECLS
 #endif /* VNC_CONNECTION_H */
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncconnectionblt.h b/src/vncconnectionblt.h
index 705e2e9..2162d95 100644
--- a/src/vncconnectionblt.h
+++ b/src/vncconnectionblt.h
@@ -39,62 +39,62 @@
 /* We need to convert to a GdkPixbuf which is always 32-bit */
 #if DST == 32
 static void RICH_CURSOR_BLIT(VncConnection *conn, guint8 *pixbuf,
-			     guint8 *image, guint8 *mask, int pitch,
-			     guint16 width, guint16 height)
+                             guint8 *image, guint8 *mask, int pitch,
+                             guint16 width, guint16 height)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	int x1, y1;
-	guint32 *dst = (guint32 *)pixbuf;
-	guint8 *src = image;
-	guint8 *alpha = mask;
-	int as, rs, gs, bs, n;
-
-	/*
-	 * GdkPixbuf is always 32-bit RGB, so we can't use the precomputed
-	 * left / right shift data from conn->{r,g,b}{r,l}s. The latter
-	 * is set for the local display depth, which may be different
-	 * to GdkPixbuf's fixed 32-bit RGBA
-	 *
-	 * This function isn't called often, so just re-compute them now
-	 */
+    VncConnectionPrivate *priv = conn->priv;
+    int x1, y1;
+    guint32 *dst = (guint32 *)pixbuf;
+    guint8 *src = image;
+    guint8 *alpha = mask;
+    int as, rs, gs, bs, n;
+
+    /*
+     * GdkPixbuf is always 32-bit RGB, so we can't use the precomputed
+     * left / right shift data from conn->{r,g,b}{r,l}s. The latter
+     * is set for the local display depth, which may be different
+     * to GdkPixbuf's fixed 32-bit RGBA
+     *
+     * This function isn't called often, so just re-compute them now
+     */
 
 #if G_BYTE_ORDER == G_BIG_ENDIAN
-	as = 0;
-	rs = 8;
-	gs = 16;
-	bs = 24;
+    as = 0;
+    rs = 8;
+    gs = 16;
+    bs = 24;
 #else
-	as = 24;
-	rs = 16;
-	gs = 8;
-	bs = 0;
+    as = 24;
+    rs = 16;
+    gs = 8;
+    bs = 0;
 #endif
 
-	/* Then this adjusts for remote having less bpp than 32 */
-	for (n = 255 ; n > priv->fmt.red_max ; n>>= 1)
-		rs++;
-	for (n = 255 ; n > priv->fmt.green_max ; n>>= 1)
-		gs++;
-	for (n = 255 ; n > priv->fmt.blue_max ; n>>= 1)
-		bs++;
-
-	for (y1 = 0; y1 < height; y1++) {
-		src_pixel_t *sp = (src_pixel_t *)src;
-		guint8 *mp = alpha;
-		for (x1 = 0; x1 < width; x1++) {
-			*dst = (COMPONENT(red, *sp) << rs)
-				| (COMPONENT(green, *sp) << gs)
-				| (COMPONENT(blue, *sp) << bs);
-
-			if ((mp[x1 / 8] >> (7 - (x1 % 8))) & 1)
-				*dst |= (0xFF << as);
-
-			dst++;
-			sp++;
-		}
-		src += pitch;
-		alpha += ((width + 7) / 8);
-	}
+    /* Then this adjusts for remote having less bpp than 32 */
+    for (n = 255 ; n > priv->fmt.red_max ; n>>= 1)
+        rs++;
+    for (n = 255 ; n > priv->fmt.green_max ; n>>= 1)
+        gs++;
+    for (n = 255 ; n > priv->fmt.blue_max ; n>>= 1)
+        bs++;
+
+    for (y1 = 0; y1 < height; y1++) {
+        src_pixel_t *sp = (src_pixel_t *)src;
+        guint8 *mp = alpha;
+        for (x1 = 0; x1 < width; x1++) {
+            *dst = (COMPONENT(red, *sp) << rs)
+                | (COMPONENT(green, *sp) << gs)
+                | (COMPONENT(blue, *sp) << bs);
+
+            if ((mp[x1 / 8] >> (7 - (x1 % 8))) & 1)
+                *dst |= (0xFF << as);
+
+            dst++;
+            sp++;
+        }
+        src += pitch;
+        alpha += ((width + 7) / 8);
+    }
 }
 #endif
 
@@ -102,44 +102,44 @@ static void RICH_CURSOR_BLIT(VncConnection *conn, guint8 *pixbuf,
 #if SRC == DST
 
 static void TIGHT_COMPUTE_PREDICTED(VncConnection *conn, src_pixel_t *ppixel,
-				    src_pixel_t *lp, src_pixel_t *cp,
-				    src_pixel_t *llp)
+                                    src_pixel_t *lp, src_pixel_t *cp,
+                                    src_pixel_t *llp)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	ssrc_pixel_t red, green, blue;
+    VncConnectionPrivate *priv = conn->priv;
+    ssrc_pixel_t red, green, blue;
 
-	red = COMPONENT(red, *lp) + COMPONENT(red, *cp) - COMPONENT(red, *llp);
-	red = MAX(red, 0);
-	red = MIN(red, priv->fmt.red_max);
+    red = COMPONENT(red, *lp) + COMPONENT(red, *cp) - COMPONENT(red, *llp);
+    red = MAX(red, 0);
+    red = MIN(red, priv->fmt.red_max);
 
-	green = COMPONENT(green, *lp) + COMPONENT(green, *cp) - COMPONENT(green, *llp);
-	green = MAX(green, 0);
-	green = MIN(green, priv->fmt.green_max);
+    green = COMPONENT(green, *lp) + COMPONENT(green, *cp) - COMPONENT(green, *llp);
+    green = MAX(green, 0);
+    green = MIN(green, priv->fmt.green_max);
 
-	blue = COMPONENT(blue, *lp) + COMPONENT(blue, *cp) - COMPONENT(blue, *llp);
-	blue = MAX(blue, 0);
-	blue = MIN(blue, priv->fmt.blue_max);
+    blue = COMPONENT(blue, *lp) + COMPONENT(blue, *cp) - COMPONENT(blue, *llp);
+    blue = MAX(blue, 0);
+    blue = MIN(blue, priv->fmt.blue_max);
 
-	*ppixel = SWAP_RFB(conn,
-		       (red << priv->fmt.red_shift) |
-		       (green << priv->fmt.green_shift) |
-		       (blue << priv->fmt.blue_shift));
+    *ppixel = SWAP_RFB(conn,
+                       (red << priv->fmt.red_shift) |
+                       (green << priv->fmt.green_shift) |
+                       (blue << priv->fmt.blue_shift));
 }
 
 static void TIGHT_SUM_PIXEL(VncConnection *conn,
-			    src_pixel_t *lhs, src_pixel_t *rhs)
+                            src_pixel_t *lhs, src_pixel_t *rhs)
 {
-	VncConnectionPrivate *priv = conn->priv;
-	src_pixel_t red, green, blue;
+    VncConnectionPrivate *priv = conn->priv;
+    src_pixel_t red, green, blue;
 
-	red = COMPONENT(red, *lhs) + COMPONENT(red, *rhs);
-	green = COMPONENT(green, *lhs) + COMPONENT(green, *rhs);
-	blue = COMPONENT(blue, *lhs) + COMPONENT(blue, *rhs);
+    red = COMPONENT(red, *lhs) + COMPONENT(red, *rhs);
+    green = COMPONENT(green, *lhs) + COMPONENT(green, *rhs);
+    blue = COMPONENT(blue, *lhs) + COMPONENT(blue, *rhs);
 
-	*lhs = SWAP_RFB(conn,
-		    ((red & priv->fmt.red_max) << priv->fmt.red_shift) |
-		    ((green & priv->fmt.green_max) << priv->fmt.green_shift) |
-		    ((blue & priv->fmt.blue_max) << priv->fmt.blue_shift));
+    *lhs = SWAP_RFB(conn,
+                    ((red & priv->fmt.red_max) << priv->fmt.red_shift) |
+                    ((green & priv->fmt.green_max) << priv->fmt.green_shift) |
+                    ((blue & priv->fmt.blue_max) << priv->fmt.blue_shift));
 }
 
 #endif
@@ -160,8 +160,8 @@ static void TIGHT_SUM_PIXEL(VncConnection *conn,
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vnccursor.c b/src/vnccursor.c
index bb81d4e..5f38e05 100644
--- a/src/vnccursor.c
+++ b/src/vnccursor.c
@@ -25,16 +25,16 @@
 
 #include <string.h>
 
-#define VNC_CURSOR_GET_PRIVATE(obj) \
-      (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_CURSOR, VncCursorPrivate))
+#define VNC_CURSOR_GET_PRIVATE(obj)                                     \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_CURSOR, VncCursorPrivate))
 
 struct _VncCursorPrivate
 {
-	guint8 *data;
-	guint16 hotx;
-	guint16 hoty;
-	guint16 width;
-	guint16 height;
+    guint8 *data;
+    guint16 hotx;
+    guint16 hoty;
+    guint16 width;
+    guint16 height;
 };
 
 G_DEFINE_TYPE(VncCursor, vnc_cursor, G_TYPE_OBJECT)
@@ -42,227 +42,227 @@ G_DEFINE_TYPE(VncCursor, vnc_cursor, G_TYPE_OBJECT)
 /* Properties */
 enum
 {
-	PROP_0,
-	PROP_DATA,
-	PROP_HOTX,
-	PROP_HOTY,
-	PROP_WIDTH,
-	PROP_HEIGHT,
+    PROP_0,
+    PROP_DATA,
+    PROP_HOTX,
+    PROP_HOTY,
+    PROP_WIDTH,
+    PROP_HEIGHT,
 };
 
 static void
 vnc_cursor_get_property(GObject    *object,
-			guint       prop_id,
-			GValue     *value,
-			GParamSpec *pspec)
+                        guint       prop_id,
+                        GValue     *value,
+                        GParamSpec *pspec)
 {
-	VncCursor *cursor = VNC_CURSOR (object);
-	VncCursorPrivate *priv = cursor->priv;
-
-	switch (prop_id) {
-	case PROP_DATA:
-		g_value_set_pointer(value, priv->data);
-		break;
-
-	case PROP_HOTX:
-		g_value_set_int(value, priv->hotx);
-		break;
-
-	case PROP_HOTY:
-		g_value_set_int(value, priv->hoty);
-		break;
-
-	case PROP_WIDTH:
-		g_value_set_int(value, priv->width);
-		break;
-
-	case PROP_HEIGHT:
-		g_value_set_int(value, priv->height);
-		break;
-
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-		break;
-	}
+    VncCursor *cursor = VNC_CURSOR (object);
+    VncCursorPrivate *priv = cursor->priv;
+
+    switch (prop_id) {
+    case PROP_DATA:
+        g_value_set_pointer(value, priv->data);
+        break;
+
+    case PROP_HOTX:
+        g_value_set_int(value, priv->hotx);
+        break;
+
+    case PROP_HOTY:
+        g_value_set_int(value, priv->hoty);
+        break;
+
+    case PROP_WIDTH:
+        g_value_set_int(value, priv->width);
+        break;
+
+    case PROP_HEIGHT:
+        g_value_set_int(value, priv->height);
+        break;
+
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
 }
 
 static void
 vnc_cursor_set_property(GObject      *object,
-			guint         prop_id,
-			const GValue *value,
-			GParamSpec   *pspec)
+                        guint         prop_id,
+                        const GValue *value,
+                        GParamSpec   *pspec)
 {
-	VncCursor *cursor = VNC_CURSOR (object);
-	VncCursorPrivate *priv = cursor->priv;
-
-	switch (prop_id) {
-	case PROP_DATA:
-		if (priv->data)
-			g_free(priv->data);
-		priv->data = g_value_get_pointer(value);
-		break;
-
-	case PROP_HOTX:
-		priv->hotx = g_value_get_int(value);
-		break;
-
-	case PROP_HOTY:
-		priv->hoty = g_value_get_int(value);
-		break;
-
-	case PROP_WIDTH:
-		priv->width = g_value_get_int(value);
-		break;
-
-	case PROP_HEIGHT:
-		priv->height = g_value_get_int(value);
-		break;
-
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-		break;
-	}
+    VncCursor *cursor = VNC_CURSOR (object);
+    VncCursorPrivate *priv = cursor->priv;
+
+    switch (prop_id) {
+    case PROP_DATA:
+        if (priv->data)
+            g_free(priv->data);
+        priv->data = g_value_get_pointer(value);
+        break;
+
+    case PROP_HOTX:
+        priv->hotx = g_value_get_int(value);
+        break;
+
+    case PROP_HOTY:
+        priv->hoty = g_value_get_int(value);
+        break;
+
+    case PROP_WIDTH:
+        priv->width = g_value_get_int(value);
+        break;
+
+    case PROP_HEIGHT:
+        priv->height = g_value_get_int(value);
+        break;
+
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
 }
 
 VncCursor *vnc_cursor_new(guint8 *data,
-			  guint16 hotx, guint16 hoty,
-			  guint16 width, guint16 height)
+                          guint16 hotx, guint16 hoty,
+                          guint16 width, guint16 height)
 {
-	return VNC_CURSOR(g_object_new(VNC_TYPE_CURSOR,
-				       "data", data,
-				       "hotx", hotx,
-				       "hoty", hoty,
-				       "width", width,
-				       "height", height,
-				       NULL));
+    return VNC_CURSOR(g_object_new(VNC_TYPE_CURSOR,
+                                   "data", data,
+                                   "hotx", hotx,
+                                   "hoty", hoty,
+                                   "width", width,
+                                   "height", height,
+                                   NULL));
 }
 
 
 static void vnc_cursor_finalize (GObject *obj)
 {
-	VncCursor *cursor = VNC_CURSOR (obj);
-	VncCursorPrivate *priv = cursor->priv;
+    VncCursor *cursor = VNC_CURSOR (obj);
+    VncCursorPrivate *priv = cursor->priv;
 
-	g_free(priv->data);
+    g_free(priv->data);
 
-	G_OBJECT_CLASS (vnc_cursor_parent_class)->finalize (obj);
+    G_OBJECT_CLASS (vnc_cursor_parent_class)->finalize (obj);
 }
 
 static void vnc_cursor_class_init(VncCursorClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = vnc_cursor_finalize;
-	object_class->get_property = vnc_cursor_get_property;
-	object_class->set_property = vnc_cursor_set_property;
-
-	g_object_class_install_property(object_class,
-					PROP_DATA,
-					g_param_spec_pointer("data",
-							     "Cursor pixel data",
-							     "Cursor pixel data in RGBA24 format",
-							     G_PARAM_READWRITE |
-							     G_PARAM_CONSTRUCT |
-							     G_PARAM_STATIC_NAME |
-							     G_PARAM_STATIC_NICK |
-							     G_PARAM_STATIC_BLURB));
-	g_object_class_install_property(object_class,
-					PROP_HOTX,
-					g_param_spec_int("hotx",
-							 "Cursor x hotspot",
-							 "Cursor x axis hotspot",
-							 0, 1 << 15, 0,
-							 G_PARAM_READWRITE |
-							 G_PARAM_CONSTRUCT |
-							 G_PARAM_STATIC_NAME |
-							 G_PARAM_STATIC_NICK |
-							 G_PARAM_STATIC_BLURB));
-	g_object_class_install_property(object_class,
-					PROP_HOTY,
-					g_param_spec_int("hoty",
-							 "Cursor y hotspot",
-							 "Cursor y axis hotspot",
-							 0, 1 << 15, 0,
-							 G_PARAM_READWRITE |
-							 G_PARAM_CONSTRUCT |
-							 G_PARAM_STATIC_NAME |
-							 G_PARAM_STATIC_NICK |
-							 G_PARAM_STATIC_BLURB));
-	g_object_class_install_property(object_class,
-					PROP_WIDTH,
-					g_param_spec_int("width",
-							 "Cursor width",
-							 "Cursor pixel data width",
-							 0, 1 << 15, 0,
-							 G_PARAM_READWRITE |
-							 G_PARAM_CONSTRUCT |
-							 G_PARAM_STATIC_NAME |
-							 G_PARAM_STATIC_NICK |
-							 G_PARAM_STATIC_BLURB));
-	g_object_class_install_property(object_class,
-					PROP_HEIGHT,
-					g_param_spec_int("height",
-							 "Cursor height",
-							 "Cursor pixel data height",
-							 0, 1 << 15, 0,
-							 G_PARAM_READWRITE |
-							 G_PARAM_CONSTRUCT |
-							 G_PARAM_STATIC_NAME |
-							 G_PARAM_STATIC_NICK |
-							 G_PARAM_STATIC_BLURB));
-
-	g_type_class_add_private(klass, sizeof(VncCursorPrivate));
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = vnc_cursor_finalize;
+    object_class->get_property = vnc_cursor_get_property;
+    object_class->set_property = vnc_cursor_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_DATA,
+                                    g_param_spec_pointer("data",
+                                                         "Cursor pixel data",
+                                                         "Cursor pixel data in RGBA24 format",
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+    g_object_class_install_property(object_class,
+                                    PROP_HOTX,
+                                    g_param_spec_int("hotx",
+                                                     "Cursor x hotspot",
+                                                     "Cursor x axis hotspot",
+                                                     0, 1 << 15, 0,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT |
+                                                     G_PARAM_STATIC_NAME |
+                                                     G_PARAM_STATIC_NICK |
+                                                     G_PARAM_STATIC_BLURB));
+    g_object_class_install_property(object_class,
+                                    PROP_HOTY,
+                                    g_param_spec_int("hoty",
+                                                     "Cursor y hotspot",
+                                                     "Cursor y axis hotspot",
+                                                     0, 1 << 15, 0,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT |
+                                                     G_PARAM_STATIC_NAME |
+                                                     G_PARAM_STATIC_NICK |
+                                                     G_PARAM_STATIC_BLURB));
+    g_object_class_install_property(object_class,
+                                    PROP_WIDTH,
+                                    g_param_spec_int("width",
+                                                     "Cursor width",
+                                                     "Cursor pixel data width",
+                                                     0, 1 << 15, 0,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT |
+                                                     G_PARAM_STATIC_NAME |
+                                                     G_PARAM_STATIC_NICK |
+                                                     G_PARAM_STATIC_BLURB));
+    g_object_class_install_property(object_class,
+                                    PROP_HEIGHT,
+                                    g_param_spec_int("height",
+                                                     "Cursor height",
+                                                     "Cursor pixel data height",
+                                                     0, 1 << 15, 0,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT |
+                                                     G_PARAM_STATIC_NAME |
+                                                     G_PARAM_STATIC_NICK |
+                                                     G_PARAM_STATIC_BLURB));
+
+    g_type_class_add_private(klass, sizeof(VncCursorPrivate));
 }
 
 static void vnc_cursor_init(VncCursor *cursor)
 {
-	VncCursorPrivate *priv;
+    VncCursorPrivate *priv;
 
-	priv = cursor->priv = VNC_CURSOR_GET_PRIVATE(cursor);
-	memset(priv, 0, sizeof(VncCursorPrivate));
+    priv = cursor->priv = VNC_CURSOR_GET_PRIVATE(cursor);
+    memset(priv, 0, sizeof(VncCursorPrivate));
 }
 
 const guint8 *vnc_cursor_get_data(VncCursor *cursor)
 {
-	VncCursorPrivate *priv = cursor->priv;
+    VncCursorPrivate *priv = cursor->priv;
 
-	return priv->data;
+    return priv->data;
 }
 
 guint16 vnc_cursor_get_hotx(VncCursor *cursor)
 {
-	VncCursorPrivate *priv = cursor->priv;
+    VncCursorPrivate *priv = cursor->priv;
 
-	return priv->hotx;
+    return priv->hotx;
 }
 
 guint16 vnc_cursor_get_hoty(VncCursor *cursor)
 {
-	VncCursorPrivate *priv = cursor->priv;
+    VncCursorPrivate *priv = cursor->priv;
 
-	return priv->hoty;
+    return priv->hoty;
 }
 
 
 guint16 vnc_cursor_get_width(VncCursor *cursor)
 {
-	VncCursorPrivate *priv = cursor->priv;
+    VncCursorPrivate *priv = cursor->priv;
 
-	return priv->width;
+    return priv->width;
 }
 
 guint16 vnc_cursor_get_height(VncCursor *cursor)
 {
-	VncCursorPrivate *priv = cursor->priv;
+    VncCursorPrivate *priv = cursor->priv;
 
-	return priv->height;
+    return priv->height;
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vnccursor.h b/src/vnccursor.h
index 8e345e6..1cbaebc 100644
--- a/src/vnccursor.h
+++ b/src/vnccursor.h
@@ -41,29 +41,29 @@ typedef struct _VncCursorPrivate VncCursorPrivate;
 
 struct _VncCursor
 {
-	GObject parent;
+    GObject parent;
 
-	VncCursorPrivate *priv;
+    VncCursorPrivate *priv;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 struct _VncCursorClass
 {
-	GObjectClass parent_class;
+    GObjectClass parent_class;
 
-	/*
-	 * If adding fields to this struct, remove corresponding
-	 * amount of padding to avoid changing overall struct size
-	 */
-	gpointer _vnc_reserved[VNC_PADDING];
+    /*
+     * If adding fields to this struct, remove corresponding
+     * amount of padding to avoid changing overall struct size
+     */
+    gpointer _vnc_reserved[VNC_PADDING];
 };
 
 
 GType vnc_cursor_get_type(void);
 VncCursor *vnc_cursor_new(guint8 *rgba24data,
-			  guint16 hotx, guint16 hoty,
-			  guint16 width, guint16 height);
+                          guint16 hotx, guint16 hoty,
+                          guint16 width, guint16 height);
 
 const guint8 *vnc_cursor_get_data(VncCursor *cursor);
 
@@ -78,8 +78,8 @@ G_END_DECLS
 #endif /* VNC_CURSOR_H */
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index 1fdb36c..1a1ea2d 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -40,48 +40,48 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#define VNC_DISPLAY_GET_PRIVATE(obj) \
-      (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_DISPLAY, VncDisplayPrivate))
+#define VNC_DISPLAY_GET_PRIVATE(obj)                                    \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_DISPLAY, VncDisplayPrivate))
 
 struct _VncDisplayPrivate
 {
-	GdkCursor *null_cursor;
-	GdkCursor *remote_cursor;
+    GdkCursor *null_cursor;
+    GdkCursor *remote_cursor;
 
-	VncConnection *conn;
-	VncCairoFramebuffer *fb;
-	cairo_surface_t *fbCache; /* Cache on server display */
+    VncConnection *conn;
+    VncCairoFramebuffer *fb;
+    cairo_surface_t *fbCache; /* Cache on server display */
 
-	VncDisplayDepthColor depth;
+    VncDisplayDepthColor depth;
 
-	gboolean in_pointer_grab;
-	gboolean in_keyboard_grab;
+    gboolean in_pointer_grab;
+    gboolean in_keyboard_grab;
 
-	guint down_keyval[16];
-	guint down_scancode[16];
+    guint down_keyval[16];
+    guint down_scancode[16];
 
-	int button_mask;
-	int last_x;
-	int last_y;
+    int button_mask;
+    int last_x;
+    int last_y;
 
-	gboolean absolute;
+    gboolean absolute;
 
-	gboolean grab_pointer;
-	gboolean grab_keyboard;
-	gboolean local_pointer;
-	gboolean read_only;
-	gboolean allow_lossy;
-	gboolean allow_scaling;
-	gboolean shared_flag;
-	gboolean force_size;
+    gboolean grab_pointer;
+    gboolean grab_keyboard;
+    gboolean local_pointer;
+    gboolean read_only;
+    gboolean allow_lossy;
+    gboolean allow_scaling;
+    gboolean shared_flag;
+    gboolean force_size;
 
-	GSList *preferable_auths;
-	GSList *preferable_vencrypt_subauths;
-	size_t keycode_maplen;
-	const guint16 const *keycode_map;
+    GSList *preferable_auths;
+    GSList *preferable_vencrypt_subauths;
+    size_t keycode_maplen;
+    const guint16 const *keycode_map;
 
-	VncGrabSequence *vncgrabseq; /* the configured key sequence */
-	gboolean *vncactiveseq; /* the currently pressed keys */
+    VncGrabSequence *vncgrabseq; /* the configured key sequence */
+    gboolean *vncactiveseq; /* the currently pressed keys */
 };
 
 G_DEFINE_TYPE(VncDisplay, vnc_display, GTK_TYPE_DRAWING_AREA)
@@ -89,46 +89,46 @@ G_DEFINE_TYPE(VncDisplay, vnc_display, GTK_TYPE_DRAWING_AREA)
 /* Properties */
 enum
 {
-  PROP_0,
-  PROP_POINTER_LOCAL,
-  PROP_POINTER_GRAB,
-  PROP_KEYBOARD_GRAB,
-  PROP_READ_ONLY,
-  PROP_WIDTH,
-  PROP_HEIGHT,
-  PROP_NAME,
-  PROP_LOSSY_ENCODING,
-  PROP_SCALING,
-  PROP_SHARED_FLAG,
-  PROP_FORCE_SIZE,
-  PROP_DEPTH,
-  PROP_GRAB_KEYS,
-  PROP_CONNECTION,
+    PROP_0,
+    PROP_POINTER_LOCAL,
+    PROP_POINTER_GRAB,
+    PROP_KEYBOARD_GRAB,
+    PROP_READ_ONLY,
+    PROP_WIDTH,
+    PROP_HEIGHT,
+    PROP_NAME,
+    PROP_LOSSY_ENCODING,
+    PROP_SCALING,
+    PROP_SHARED_FLAG,
+    PROP_FORCE_SIZE,
+    PROP_DEPTH,
+    PROP_GRAB_KEYS,
+    PROP_CONNECTION,
 };
 
 /* Signals */
 typedef enum
-{
- 	VNC_POINTER_GRAB,
- 	VNC_POINTER_UNGRAB,
- 	VNC_KEYBOARD_GRAB,
- 	VNC_KEYBOARD_UNGRAB,
+    {
+        VNC_POINTER_GRAB,
+        VNC_POINTER_UNGRAB,
+        VNC_KEYBOARD_GRAB,
+        VNC_KEYBOARD_UNGRAB,
 
-	VNC_CONNECTED,
-	VNC_INITIALIZED,
-	VNC_DISCONNECTED,
- 	VNC_AUTH_CREDENTIAL,
+        VNC_CONNECTED,
+        VNC_INITIALIZED,
+        VNC_DISCONNECTED,
+        VNC_AUTH_CREDENTIAL,
 
-	VNC_DESKTOP_RESIZE,
+        VNC_DESKTOP_RESIZE,
 
-	VNC_AUTH_FAILURE,
-	VNC_AUTH_UNSUPPORTED,
+        VNC_AUTH_FAILURE,
+        VNC_AUTH_UNSUPPORTED,
 
-	VNC_SERVER_CUT_TEXT,
-	VNC_BELL,
+        VNC_SERVER_CUT_TEXT,
+        VNC_BELL,
 
-	LAST_SIGNAL
-} vnc_display_signals;
+        LAST_SIGNAL
+    } vnc_display_signals;
 
 
 /* Some compatibility defines to let us build on both Gtk2 and Gtk3 */
@@ -136,8 +136,8 @@ typedef enum
 
 static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
 {
-	*ww = gdk_window_get_width(w);
-	*wh = gdk_window_get_height(w);
+    *ww = gdk_window_get_width(w);
+    *wh = gdk_window_get_height(w);
 }
 
 #define GtkObject GtkWidget
@@ -147,417 +147,417 @@ static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
 #endif
 
 static guint signals[LAST_SIGNAL] = { 0, 0, 0, 0,
-				      0, 0, 0, 0,
-				      0, 0, 0, 0, 0,};
+                                      0, 0, 0, 0,
+                                      0, 0, 0, 0, 0,};
 
 static gboolean vnc_debug_option_arg(const gchar *option_name G_GNUC_UNUSED,
-				     const gchar *value G_GNUC_UNUSED,
-				     gpointer data G_GNUC_UNUSED,
-				     GError **error G_GNUC_UNUSED)
+                                     const gchar *value G_GNUC_UNUSED,
+                                     gpointer data G_GNUC_UNUSED,
+                                     GError **error G_GNUC_UNUSED)
 {
-	vnc_util_set_debug(TRUE);
-	return TRUE;
+    vnc_util_set_debug(TRUE);
+    return TRUE;
 }
 
 static const GOptionEntry gtk_vnc_args[] =
-{
-	{ "gtk-vnc-debug", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
-	  vnc_debug_option_arg, N_("Enables debug output"), 0 },
-	{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
-};
+    {
+        { "gtk-vnc-debug", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+          vnc_debug_option_arg, N_("Enables debug output"), 0 },
+        { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
+    };
 
 
 static void
 vnc_display_get_property (GObject    *object,
-			  guint       prop_id,
-			  GValue     *value,
-			  GParamSpec *pspec)
-{
-  VncDisplay *vnc = VNC_DISPLAY (object);
-
-  switch (prop_id)
-    {
-      case PROP_POINTER_LOCAL:
-        g_value_set_boolean (value, vnc->priv->local_pointer);
-	break;
-      case PROP_POINTER_GRAB:
-        g_value_set_boolean (value, vnc->priv->grab_pointer);
-	break;
-      case PROP_KEYBOARD_GRAB:
-        g_value_set_boolean (value, vnc->priv->grab_keyboard);
-	break;
-      case PROP_READ_ONLY:
-        g_value_set_boolean (value, vnc->priv->read_only);
-	break;
-      case PROP_WIDTH:
-        g_value_set_int (value, vnc_display_get_width (vnc));
-	break;
-      case PROP_HEIGHT:
-        g_value_set_int (value, vnc_display_get_height (vnc));
-	break;
-      case PROP_NAME:
-        g_value_set_string (value, vnc_display_get_name (vnc));
-	break;
-      case PROP_LOSSY_ENCODING:
-        g_value_set_boolean (value, vnc->priv->allow_lossy);
-	break;
-      case PROP_SCALING:
-        g_value_set_boolean (value, vnc->priv->allow_scaling);
-	break;
-      case PROP_SHARED_FLAG:
-        g_value_set_boolean (value, vnc->priv->shared_flag);
-	break;
-      case PROP_FORCE_SIZE:
-        g_value_set_boolean (value, vnc->priv->force_size);
-	break;
-      case PROP_DEPTH:
-        g_value_set_enum (value, vnc->priv->depth);
-	break;
-      case PROP_GRAB_KEYS:
-	g_value_set_boxed(value, vnc->priv->vncgrabseq);
-	break;
-      case PROP_CONNECTION:
-	g_value_set_object(value, vnc->priv->conn);
-	break;
-      default:
-	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-	break;
-    }
+                          guint       prop_id,
+                          GValue     *value,
+                          GParamSpec *pspec)
+{
+    VncDisplay *vnc = VNC_DISPLAY (object);
+
+    switch (prop_id)
+        {
+        case PROP_POINTER_LOCAL:
+            g_value_set_boolean (value, vnc->priv->local_pointer);
+            break;
+        case PROP_POINTER_GRAB:
+            g_value_set_boolean (value, vnc->priv->grab_pointer);
+            break;
+        case PROP_KEYBOARD_GRAB:
+            g_value_set_boolean (value, vnc->priv->grab_keyboard);
+            break;
+        case PROP_READ_ONLY:
+            g_value_set_boolean (value, vnc->priv->read_only);
+            break;
+        case PROP_WIDTH:
+            g_value_set_int (value, vnc_display_get_width (vnc));
+            break;
+        case PROP_HEIGHT:
+            g_value_set_int (value, vnc_display_get_height (vnc));
+            break;
+        case PROP_NAME:
+            g_value_set_string (value, vnc_display_get_name (vnc));
+            break;
+        case PROP_LOSSY_ENCODING:
+            g_value_set_boolean (value, vnc->priv->allow_lossy);
+            break;
+        case PROP_SCALING:
+            g_value_set_boolean (value, vnc->priv->allow_scaling);
+            break;
+        case PROP_SHARED_FLAG:
+            g_value_set_boolean (value, vnc->priv->shared_flag);
+            break;
+        case PROP_FORCE_SIZE:
+            g_value_set_boolean (value, vnc->priv->force_size);
+            break;
+        case PROP_DEPTH:
+            g_value_set_enum (value, vnc->priv->depth);
+            break;
+        case PROP_GRAB_KEYS:
+            g_value_set_boxed(value, vnc->priv->vncgrabseq);
+            break;
+        case PROP_CONNECTION:
+            g_value_set_object(value, vnc->priv->conn);
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+        }
 }
 
 static void
 vnc_display_set_property (GObject      *object,
-			  guint         prop_id,
-			  const GValue *value,
-			  GParamSpec   *pspec)
-{
-  VncDisplay *vnc = VNC_DISPLAY (object);
-
-  switch (prop_id)
-    {
-      case PROP_POINTER_LOCAL:
-        vnc_display_set_pointer_local (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_POINTER_GRAB:
-        vnc_display_set_pointer_grab (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_KEYBOARD_GRAB:
-        vnc_display_set_keyboard_grab (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_READ_ONLY:
-        vnc_display_set_read_only (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_LOSSY_ENCODING:
-        vnc_display_set_lossy_encoding (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_SCALING:
-        vnc_display_set_scaling (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_SHARED_FLAG:
-        vnc_display_set_shared_flag (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_FORCE_SIZE:
-        vnc_display_set_force_size (vnc, g_value_get_boolean (value));
-        break;
-      case PROP_DEPTH:
-        vnc_display_set_depth (vnc, g_value_get_enum (value));
-        break;
-      case PROP_GRAB_KEYS:
-	vnc_display_set_grab_keys(vnc, g_value_get_boxed(value));
-	break;
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-        break;
-    }
+                          guint         prop_id,
+                          const GValue *value,
+                          GParamSpec   *pspec)
+{
+    VncDisplay *vnc = VNC_DISPLAY (object);
+
+    switch (prop_id)
+        {
+        case PROP_POINTER_LOCAL:
+            vnc_display_set_pointer_local (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_POINTER_GRAB:
+            vnc_display_set_pointer_grab (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_KEYBOARD_GRAB:
+            vnc_display_set_keyboard_grab (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_READ_ONLY:
+            vnc_display_set_read_only (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_LOSSY_ENCODING:
+            vnc_display_set_lossy_encoding (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_SCALING:
+            vnc_display_set_scaling (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_SHARED_FLAG:
+            vnc_display_set_shared_flag (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_FORCE_SIZE:
+            vnc_display_set_force_size (vnc, g_value_get_boolean (value));
+            break;
+        case PROP_DEPTH:
+            vnc_display_set_depth (vnc, g_value_get_enum (value));
+            break;
+        case PROP_GRAB_KEYS:
+            vnc_display_set_grab_keys(vnc, g_value_get_boxed(value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+        }
 }
 
 GtkWidget *vnc_display_new(void)
 {
-	return GTK_WIDGET(g_object_new(VNC_TYPE_DISPLAY, NULL));
+    return GTK_WIDGET(g_object_new(VNC_TYPE_DISPLAY, NULL));
 }
 
 static GdkCursor *create_null_cursor(void)
 {
-	GdkCursor *cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
+    GdkCursor *cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
 
-	return cursor;
+    return cursor;
 }
 
 
 static void setup_surface_cache(VncDisplay *dpy, cairo_t *crWin, int w, int h)
 {
-	VncDisplayPrivate *priv = dpy->priv;
-	cairo_surface_t *win = cairo_get_target(crWin);
-	cairo_t *crCache;
+    VncDisplayPrivate *priv = dpy->priv;
+    cairo_surface_t *win = cairo_get_target(crWin);
+    cairo_t *crCache;
 
-	if (priv->fbCache)
-		return;
+    if (priv->fbCache)
+        return;
 
-	/* Creates a Pixmap on the X11 server matching the Window */
-	priv->fbCache = cairo_surface_create_similar(win,
-						     CAIRO_CONTENT_COLOR,
-						     w, h);
-	crCache = cairo_create(priv->fbCache);
+    /* Creates a Pixmap on the X11 server matching the Window */
+    priv->fbCache = cairo_surface_create_similar(win,
+                                                 CAIRO_CONTENT_COLOR,
+                                                 w, h);
+    crCache = cairo_create(priv->fbCache);
 
-	/* Copy our local framebuffer contents to the Pixmap */
-	cairo_set_source_surface(crCache,
-				 vnc_cairo_framebuffer_get_surface(priv->fb),
-				 0,
-				 0);
-	cairo_paint(crCache);
+    /* Copy our local framebuffer contents to the Pixmap */
+    cairo_set_source_surface(crCache,
+                             vnc_cairo_framebuffer_get_surface(priv->fb),
+                             0,
+                             0);
+    cairo_paint(crCache);
 
-	cairo_destroy(crCache);
+    cairo_destroy(crCache);
 }
 
 static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
 {
-	VncDisplay *obj = VNC_DISPLAY(widget);
-	VncDisplayPrivate *priv = obj->priv;
-	int ww, wh;
-	int mx = 0, my = 0;
-	int fbw = 0, fbh = 0;
-
-	if (priv->fb) {
-		fbw = vnc_framebuffer_get_width(VNC_FRAMEBUFFER(priv->fb));
-		fbh = vnc_framebuffer_get_height(VNC_FRAMEBUFFER(priv->fb));
-
-		setup_surface_cache(obj, cr, fbw, fbh);
-	}
-
-	gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
-
-	if (ww > fbw)
-		mx = (ww - fbw) / 2;
-	if (wh > fbh)
-		my = (wh - fbh) / 2;
-
-	/* If we don't have a pixmap, or we're not scaling, then
-	   we need to fill with background color */
-	if (!priv->fb ||
-	    !priv->allow_scaling) {
-		cairo_rectangle(cr, 0, 0, ww, wh);
-		/* Optionally cut out the inner area where the pixmap
-		   will be drawn. This avoids 'flashing' since we're
-		   not double-buffering. Note we're using the undocumented
-		   behaviour of drawing the rectangle from right to left
-		   to cut out the whole */
-		if (priv->fb)
-			cairo_rectangle(cr, mx + fbw, my,
-					-1 * fbw, fbh);
-		cairo_fill(cr);
-	}
-
-	/* Draw the VNC display */
-	if (priv->fb) {
-		if (priv->allow_scaling) {
-			double sx, sy;
-			/* Scale to fill window */
-			sx = (double)ww / (double)fbw;
-			sy = (double)wh / (double)fbh;
-			cairo_scale(cr, sx, sy);
-			cairo_set_source_surface(cr,
-						 priv->fbCache,
-						 0,
-						 0);
-		} else {
-			cairo_set_source_surface(cr,
-						 priv->fbCache,
-						 mx,
-						 my);
-		}
-		cairo_paint(cr);
-	}
-
-	return TRUE;
+    VncDisplay *obj = VNC_DISPLAY(widget);
+    VncDisplayPrivate *priv = obj->priv;
+    int ww, wh;
+    int mx = 0, my = 0;
+    int fbw = 0, fbh = 0;
+
+    if (priv->fb) {
+        fbw = vnc_framebuffer_get_width(VNC_FRAMEBUFFER(priv->fb));
+        fbh = vnc_framebuffer_get_height(VNC_FRAMEBUFFER(priv->fb));
+
+        setup_surface_cache(obj, cr, fbw, fbh);
+    }
+
+    gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
+
+    if (ww > fbw)
+        mx = (ww - fbw) / 2;
+    if (wh > fbh)
+        my = (wh - fbh) / 2;
+
+    /* If we don't have a pixmap, or we're not scaling, then
+       we need to fill with background color */
+    if (!priv->fb ||
+        !priv->allow_scaling) {
+        cairo_rectangle(cr, 0, 0, ww, wh);
+        /* Optionally cut out the inner area where the pixmap
+           will be drawn. This avoids 'flashing' since we're
+           not double-buffering. Note we're using the undocumented
+           behaviour of drawing the rectangle from right to left
+           to cut out the whole */
+        if (priv->fb)
+            cairo_rectangle(cr, mx + fbw, my,
+                            -1 * fbw, fbh);
+        cairo_fill(cr);
+    }
+
+    /* Draw the VNC display */
+    if (priv->fb) {
+        if (priv->allow_scaling) {
+            double sx, sy;
+            /* Scale to fill window */
+            sx = (double)ww / (double)fbw;
+            sy = (double)wh / (double)fbh;
+            cairo_scale(cr, sx, sy);
+            cairo_set_source_surface(cr,
+                                     priv->fbCache,
+                                     0,
+                                     0);
+        } else {
+            cairo_set_source_surface(cr,
+                                     priv->fbCache,
+                                     mx,
+                                     my);
+        }
+        cairo_paint(cr);
+    }
+
+    return TRUE;
 }
 
 
 #if !GTK_CHECK_VERSION (2, 91, 0)
 static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose)
 {
-	VncDisplay *obj = VNC_DISPLAY(widget);
-	cairo_t *cr;
-	gboolean ret;
+    VncDisplay *obj = VNC_DISPLAY(widget);
+    cairo_t *cr;
+    gboolean ret;
 
-	cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(obj)));
-	cairo_rectangle(cr,
-			expose->area.x,
-			expose->area.y,
-			expose->area.width,
-			expose->area.height);
-	cairo_clip(cr);
+    cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(obj)));
+    cairo_rectangle(cr,
+                    expose->area.x,
+                    expose->area.y,
+                    expose->area.width,
+                    expose->area.height);
+    cairo_clip(cr);
 
-	ret = draw_event(widget, cr);
+    ret = draw_event(widget, cr);
 
-	cairo_destroy(cr);
+    cairo_destroy(cr);
 
-	return ret;
+    return ret;
 }
 #endif
 
 static void do_keyboard_grab(VncDisplay *obj, gboolean quiet)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	gdk_keyboard_grab(gtk_widget_get_window(GTK_WIDGET(obj)),
-			  FALSE,
-			  GDK_CURRENT_TIME);
-	priv->in_keyboard_grab = TRUE;
-	if (!quiet)
-		g_signal_emit(obj, signals[VNC_KEYBOARD_GRAB], 0);
+    gdk_keyboard_grab(gtk_widget_get_window(GTK_WIDGET(obj)),
+                      FALSE,
+                      GDK_CURRENT_TIME);
+    priv->in_keyboard_grab = TRUE;
+    if (!quiet)
+        g_signal_emit(obj, signals[VNC_KEYBOARD_GRAB], 0);
 }
 
 
 static void do_keyboard_ungrab(VncDisplay *obj, gboolean quiet)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	gdk_keyboard_ungrab(GDK_CURRENT_TIME);
-	priv->in_keyboard_grab = FALSE;
-	if (!quiet)
-		g_signal_emit(obj, signals[VNC_KEYBOARD_UNGRAB], 0);
+    gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+    priv->in_keyboard_grab = FALSE;
+    if (!quiet)
+        g_signal_emit(obj, signals[VNC_KEYBOARD_UNGRAB], 0);
 }
 
 static void do_pointer_hide(VncDisplay *obj)
 {
-	VncDisplayPrivate *priv = obj->priv;
-	gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(obj)),
-			      priv->remote_cursor ? priv->remote_cursor : priv->null_cursor);
+    VncDisplayPrivate *priv = obj->priv;
+    gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(obj)),
+                          priv->remote_cursor ? priv->remote_cursor : priv->null_cursor);
 }
 
 static void do_pointer_show(VncDisplay *obj)
 {
-	VncDisplayPrivate *priv = obj->priv;
-	gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(obj)),
-			      priv->remote_cursor);
+    VncDisplayPrivate *priv = obj->priv;
+    gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(obj)),
+                          priv->remote_cursor);
 }
 
 static void do_pointer_grab(VncDisplay *obj, gboolean quiet)
 {
-	VncDisplayPrivate *priv = obj->priv;
-
-	/* If we're not already grabbing keyboard, grab it now */
-	if (!priv->grab_keyboard)
-		do_keyboard_grab(obj, quiet);
-
-	/*
-	 * For relative mouse to work correctly when grabbed we need to
-	 * allow the pointer to move anywhere on the local desktop, so
-	 * use NULL for the 'confine_to' argument. Furthermore we need
-	 * the coords to be reported to our VNC window, regardless of
-	 * what window the pointer is actally over, so use 'FALSE' for
-	 * 'owner_events' parameter
-	 */
-	gdk_pointer_grab(gtk_widget_get_window(GTK_WIDGET(obj)),
-			 FALSE, /* All events to come to our window directly */
-			 GDK_POINTER_MOTION_MASK |
-			 GDK_BUTTON_PRESS_MASK |
-			 GDK_BUTTON_RELEASE_MASK |
-			 GDK_BUTTON_MOTION_MASK |
-			 GDK_SCROLL_MASK,
-			 NULL, /* Allow cursor to move over entire desktop */
-			 priv->remote_cursor ? priv->remote_cursor : priv->null_cursor,
-			 GDK_CURRENT_TIME);
-	priv->in_pointer_grab = TRUE;
-	if (!quiet)
-		g_signal_emit(obj, signals[VNC_POINTER_GRAB], 0);
+    VncDisplayPrivate *priv = obj->priv;
+
+    /* If we're not already grabbing keyboard, grab it now */
+    if (!priv->grab_keyboard)
+        do_keyboard_grab(obj, quiet);
+
+    /*
+     * For relative mouse to work correctly when grabbed we need to
+     * allow the pointer to move anywhere on the local desktop, so
+     * use NULL for the 'confine_to' argument. Furthermore we need
+     * the coords to be reported to our VNC window, regardless of
+     * what window the pointer is actally over, so use 'FALSE' for
+     * 'owner_events' parameter
+     */
+    gdk_pointer_grab(gtk_widget_get_window(GTK_WIDGET(obj)),
+                     FALSE, /* All events to come to our window directly */
+                     GDK_POINTER_MOTION_MASK |
+                     GDK_BUTTON_PRESS_MASK |
+                     GDK_BUTTON_RELEASE_MASK |
+                     GDK_BUTTON_MOTION_MASK |
+                     GDK_SCROLL_MASK,
+                     NULL, /* Allow cursor to move over entire desktop */
+                     priv->remote_cursor ? priv->remote_cursor : priv->null_cursor,
+                     GDK_CURRENT_TIME);
+    priv->in_pointer_grab = TRUE;
+    if (!quiet)
+        g_signal_emit(obj, signals[VNC_POINTER_GRAB], 0);
 }
 
 static void do_pointer_ungrab(VncDisplay *obj, gboolean quiet)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	/* If we grabbed keyboard upon pointer grab, then ungrab it now */
-	if (!priv->grab_keyboard)
-		do_keyboard_ungrab(obj, quiet);
+    /* If we grabbed keyboard upon pointer grab, then ungrab it now */
+    if (!priv->grab_keyboard)
+        do_keyboard_ungrab(obj, quiet);
 
-	gdk_pointer_ungrab(GDK_CURRENT_TIME);
-	priv->in_pointer_grab = FALSE;
+    gdk_pointer_ungrab(GDK_CURRENT_TIME);
+    priv->in_pointer_grab = FALSE;
 
-	if (priv->absolute)
-		do_pointer_hide(obj);
+    if (priv->absolute)
+        do_pointer_hide(obj);
 
-	if (!quiet)
-		g_signal_emit(obj, signals[VNC_POINTER_UNGRAB], 0);
+    if (!quiet)
+        g_signal_emit(obj, signals[VNC_POINTER_UNGRAB], 0);
 }
 
 void vnc_display_force_grab(VncDisplay *obj, gboolean enable)
 {
-	if (enable)
-		do_pointer_grab(obj, FALSE);
-	else
-		do_pointer_ungrab(obj, FALSE);
+    if (enable)
+        do_pointer_grab(obj, FALSE);
+    else
+        do_pointer_ungrab(obj, FALSE);
 }
 
 static gboolean button_event(GtkWidget *widget, GdkEventButton *button)
 {
-	VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
-	int n;
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    int n;
 
-	if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-		return FALSE;
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return FALSE;
 
-	if (priv->read_only)
-		return FALSE;
+    if (priv->read_only)
+        return FALSE;
 
-	gtk_widget_grab_focus (widget);
+    gtk_widget_grab_focus (widget);
 
-	if (priv->grab_pointer && !priv->absolute && !priv->in_pointer_grab &&
-	    button->button == 1 && button->type == GDK_BUTTON_PRESS)
-		do_pointer_grab(VNC_DISPLAY(widget), FALSE);
+    if (priv->grab_pointer && !priv->absolute && !priv->in_pointer_grab &&
+        button->button == 1 && button->type == GDK_BUTTON_PRESS)
+        do_pointer_grab(VNC_DISPLAY(widget), FALSE);
 
-	n = 1 << (button->button - 1);
-	if (button->type == GDK_BUTTON_PRESS)
-		priv->button_mask |= n;
-	else if (button->type == GDK_BUTTON_RELEASE)
-		priv->button_mask &= ~n;
+    n = 1 << (button->button - 1);
+    if (button->type == GDK_BUTTON_PRESS)
+        priv->button_mask |= n;
+    else if (button->type == GDK_BUTTON_RELEASE)
+        priv->button_mask &= ~n;
 
-	if (priv->absolute) {
-		vnc_connection_pointer_event(priv->conn, priv->button_mask,
-				   priv->last_x, priv->last_y);
-	} else {
-		vnc_connection_pointer_event(priv->conn, priv->button_mask,
-				   0x7FFF, 0x7FFF);
-	}
+    if (priv->absolute) {
+        vnc_connection_pointer_event(priv->conn, priv->button_mask,
+                                     priv->last_x, priv->last_y);
+    } else {
+        vnc_connection_pointer_event(priv->conn, priv->button_mask,
+                                     0x7FFF, 0x7FFF);
+    }
 
-	return TRUE;
+    return TRUE;
 }
 
 static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *scroll)
 {
-	VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
-	int mask;
-
-	if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-		return FALSE;
-
-	if (priv->read_only)
-		return FALSE;
-
-	if (scroll->direction == GDK_SCROLL_UP)
-		mask = (1 << 3);
-	else if (scroll->direction == GDK_SCROLL_DOWN)
-		mask = (1 << 4);
-	else if (scroll->direction == GDK_SCROLL_LEFT)
-		mask = (1 << 5);
-	else if (scroll->direction == GDK_SCROLL_RIGHT)
-		mask = (1 << 6);
-	else
-		return FALSE;
-
-	if (priv->absolute) {
-		vnc_connection_pointer_event(priv->conn, priv->button_mask | mask,
-				   priv->last_x, priv->last_y);
-		vnc_connection_pointer_event(priv->conn, priv->button_mask,
-				   priv->last_x, priv->last_y);
-	} else {
-		vnc_connection_pointer_event(priv->conn, priv->button_mask | mask,
-				   0x7FFF, 0x7FFF);
-		vnc_connection_pointer_event(priv->conn, priv->button_mask,
-				   0x7FFF, 0x7FFF);
-	}
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    int mask;
+
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return FALSE;
+
+    if (priv->read_only)
+        return FALSE;
+
+    if (scroll->direction == GDK_SCROLL_UP)
+        mask = (1 << 3);
+    else if (scroll->direction == GDK_SCROLL_DOWN)
+        mask = (1 << 4);
+    else if (scroll->direction == GDK_SCROLL_LEFT)
+        mask = (1 << 5);
+    else if (scroll->direction == GDK_SCROLL_RIGHT)
+        mask = (1 << 6);
+    else
+        return FALSE;
+
+    if (priv->absolute) {
+        vnc_connection_pointer_event(priv->conn, priv->button_mask | mask,
+                                     priv->last_x, priv->last_y);
+        vnc_connection_pointer_event(priv->conn, priv->button_mask,
+                                     priv->last_x, priv->last_y);
+    } else {
+        vnc_connection_pointer_event(priv->conn, priv->button_mask | mask,
+                                     0x7FFF, 0x7FFF);
+        vnc_connection_pointer_event(priv->conn, priv->button_mask,
+                                     0x7FFF, 0x7FFF);
+    }
 
-	return TRUE;
+    return TRUE;
 }
 
 
@@ -579,1542 +579,1542 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *scroll)
  */
 static gboolean motion_event(GtkWidget *widget, GdkEventMotion *motion)
 {
-	VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
-	int ww, wh;
-	int fbw, fbh;
-
-	if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-		return FALSE;
-
-	if (!priv->fb)
-		return FALSE;
-
-	fbw = vnc_framebuffer_get_width(VNC_FRAMEBUFFER(priv->fb));
-	fbh = vnc_framebuffer_get_height(VNC_FRAMEBUFFER(priv->fb));
-
-	/* In relative mode, only move the server mouse pointer
-	 * if the client grab is active */
-	if (!priv->absolute && !priv->in_pointer_grab)
-		return FALSE;
-
-	if (priv->read_only)
-		return FALSE;
-
-	gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
-
-	/* First apply adjustments to the coords in the motion event */
-	if (priv->allow_scaling) {
-		double sx, sy;
-		sx = (double)fbw / (double)ww;
-		sy = (double)fbh / (double)wh;
-
-		/* Scaling the desktop, so scale the mouse coords
-		 * by same ratio */
-		motion->x *= sx;
-		motion->y *= sy;
-	} else {
-		int mw = 0, mh = 0;
-
-		if (ww > fbw)
-			mw = (ww - fbw) / 2;
-		if (wh > fbh)
-			mh = (wh - fbh) / 2;
-
-		/* Not scaling, drawing the desktop centered
-		 * in the larger window, so offset the mouse
-		 * coords to match centering */
-		motion->x -= mw;
-		motion->y -= mh;
-	}
-
-	/* Next adjust the real client pointer */
-	if (!priv->absolute) {
-		GdkDisplay *display = gtk_widget_get_display(widget);
-		GdkScreen *screen = gtk_widget_get_screen(widget);
-		int x = (int)motion->x_root;
-		int y = (int)motion->y_root;
-
-		/* In relative mode check to see if client pointer hit
-		 * one of the screen edges, and if so move it back by
-		 * 200 pixels. This is important because the pointer
-		 * in the server doesn't correspond 1-for-1, and so
-		 * may still be only half way across the screen. Without
-		 * this warp, the server pointer would thus appear to hit
-		 * an invisible wall */
-		if (x <= 0) x += 200;
-		if (y <= 0) y += 200;
-		if (x >= (gdk_screen_get_width(screen) - 1)) x -= 200;
-		if (y >= (gdk_screen_get_height(screen) - 1)) y -= 200;
-
-		if (x != (int)motion->x_root || y != (int)motion->y_root) {
-			gdk_display_warp_pointer(display, screen, x, y);
-			priv->last_x = -1;
-			priv->last_y = -1;
-			return FALSE;
-		}
-	}
-
-	/* Finally send the event to server */
-	if (priv->last_x != -1) {
-		int dx, dy;
-		if (priv->absolute) {
-			dx = (int)motion->x;
-			dy = (int)motion->y;
-
-			/* Drop out of bounds motion to avoid upsetting
-			 * the server */
-			if (dx < 0 || dx >= fbw ||
-			    dy < 0 || dy >= fbh)
-				return FALSE;
-		} else {
-			/* Just send the delta since last motion event */
-			dx = (int)motion->x + 0x7FFF - priv->last_x;
-			dy = (int)motion->y + 0x7FFF - priv->last_y;
-		}
-
-		vnc_connection_pointer_event(priv->conn, priv->button_mask, dx, dy);
-	}
-
-	priv->last_x = (int)motion->x;
-	priv->last_y = (int)motion->y;
-
-	return TRUE;
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    int ww, wh;
+    int fbw, fbh;
+
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return FALSE;
+
+    if (!priv->fb)
+        return FALSE;
+
+    fbw = vnc_framebuffer_get_width(VNC_FRAMEBUFFER(priv->fb));
+    fbh = vnc_framebuffer_get_height(VNC_FRAMEBUFFER(priv->fb));
+
+    /* In relative mode, only move the server mouse pointer
+     * if the client grab is active */
+    if (!priv->absolute && !priv->in_pointer_grab)
+        return FALSE;
+
+    if (priv->read_only)
+        return FALSE;
+
+    gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
+
+    /* First apply adjustments to the coords in the motion event */
+    if (priv->allow_scaling) {
+        double sx, sy;
+        sx = (double)fbw / (double)ww;
+        sy = (double)fbh / (double)wh;
+
+        /* Scaling the desktop, so scale the mouse coords
+         * by same ratio */
+        motion->x *= sx;
+        motion->y *= sy;
+    } else {
+        int mw = 0, mh = 0;
+
+        if (ww > fbw)
+            mw = (ww - fbw) / 2;
+        if (wh > fbh)
+            mh = (wh - fbh) / 2;
+
+        /* Not scaling, drawing the desktop centered
+         * in the larger window, so offset the mouse
+         * coords to match centering */
+        motion->x -= mw;
+        motion->y -= mh;
+    }
+
+    /* Next adjust the real client pointer */
+    if (!priv->absolute) {
+        GdkDisplay *display = gtk_widget_get_display(widget);
+        GdkScreen *screen = gtk_widget_get_screen(widget);
+        int x = (int)motion->x_root;
+        int y = (int)motion->y_root;
+
+        /* In relative mode check to see if client pointer hit
+         * one of the screen edges, and if so move it back by
+         * 200 pixels. This is important because the pointer
+         * in the server doesn't correspond 1-for-1, and so
+         * may still be only half way across the screen. Without
+         * this warp, the server pointer would thus appear to hit
+         * an invisible wall */
+        if (x <= 0) x += 200;
+        if (y <= 0) y += 200;
+        if (x >= (gdk_screen_get_width(screen) - 1)) x -= 200;
+        if (y >= (gdk_screen_get_height(screen) - 1)) y -= 200;
+
+        if (x != (int)motion->x_root || y != (int)motion->y_root) {
+            gdk_display_warp_pointer(display, screen, x, y);
+            priv->last_x = -1;
+            priv->last_y = -1;
+            return FALSE;
+        }
+    }
+
+    /* Finally send the event to server */
+    if (priv->last_x != -1) {
+        int dx, dy;
+        if (priv->absolute) {
+            dx = (int)motion->x;
+            dy = (int)motion->y;
+
+            /* Drop out of bounds motion to avoid upsetting
+             * the server */
+            if (dx < 0 || dx >= fbw ||
+                dy < 0 || dy >= fbh)
+                return FALSE;
+        } else {
+            /* Just send the delta since last motion event */
+            dx = (int)motion->x + 0x7FFF - priv->last_x;
+            dy = (int)motion->y + 0x7FFF - priv->last_y;
+        }
+
+        vnc_connection_pointer_event(priv->conn, priv->button_mask, dx, dy);
+    }
+
+    priv->last_x = (int)motion->x;
+    priv->last_y = (int)motion->y;
+
+    return TRUE;
 }
 
 
 static gboolean check_for_grab_key(GtkWidget *widget, int type, int keyval)
 {
-	VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
-	int i;
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    int i;
 
-	if (!priv->vncgrabseq->nkeysyms)
-		return FALSE;
+    if (!priv->vncgrabseq->nkeysyms)
+        return FALSE;
 
-	if (type == GDK_KEY_RELEASE) {
-		/* Any key release resets the whole grab sequence */
-		memset(priv->vncactiveseq, 0,
-		       sizeof(gboolean)*priv->vncgrabseq->nkeysyms);
+    if (type == GDK_KEY_RELEASE) {
+        /* Any key release resets the whole grab sequence */
+        memset(priv->vncactiveseq, 0,
+               sizeof(gboolean)*priv->vncgrabseq->nkeysyms);
 
-		return FALSE;
-	} else {
-		/* Record the new key press */
-		for (i = 0 ; i < priv->vncgrabseq->nkeysyms ; i++)
-			if (priv->vncgrabseq->keysyms[i] == keyval)
-				priv->vncactiveseq[i] = TRUE;
+        return FALSE;
+    } else {
+        /* Record the new key press */
+        for (i = 0 ; i < priv->vncgrabseq->nkeysyms ; i++)
+            if (priv->vncgrabseq->keysyms[i] == keyval)
+                priv->vncactiveseq[i] = TRUE;
 
-		/* Return if any key is not pressed */
-		for (i = 0 ; i < priv->vncgrabseq->nkeysyms ; i++)
-			if (priv->vncactiveseq[i] == FALSE)
-				return FALSE;
+        /* Return if any key is not pressed */
+        for (i = 0 ; i < priv->vncgrabseq->nkeysyms ; i++)
+            if (priv->vncactiveseq[i] == FALSE)
+                return FALSE;
 
-		return TRUE;
-	}
+        return TRUE;
+    }
 }
 
 
 static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
 {
-	VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
-	int i;
-	int keyval = key->keyval;
-
-	if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-		return FALSE;
-
-	if (priv->read_only)
-		return FALSE;
-
-	VNC_DEBUG("%s keycode: %d  state: %d  group %d, keyval: %d",
-		   key->type == GDK_KEY_PRESS ? "press" : "release",
-		   key->hardware_keycode, key->state, key->group, keyval);
-
-	keyval = vnc_display_keyval_from_keycode(key->hardware_keycode, keyval);
-
-	/*
-	 * Some VNC suckiness with key state & modifiers in particular
-	 *
-	 * Because VNC has no concept of modifiers, we have to track what keys are
-	 * pressed and when the widget looses focus send fake key up events for all
-	 * keys current held down. This is because upon gaining focus any keys held
-	 * down are no longer likely to be down. This would thus result in keys
-	 * being 'stuck on' in the remote server. eg upon Alt-Tab to switch window
-	 * focus you'd never see key up for the Alt or Tab keys without this :-(
-	 *
-	 * This is mostly a problem with modifier keys, but its best to just track
-	 * all key presses regardless. There's a limit to how many keys a user can
-	 * press at once due to a max of 10 fingers (normally :-), so down_key_vals
-	 * is only storing upto 16 for now. Should be plenty...
-	 *
-	 * Arggggh.
-	 */
-
-	/*
-	 * First the key release handling. This is *always* run, even for Key press
-	 * events, because GTK will often merge sequential press+release pairs of
-	 * the same key into a sequence of press+press+press+press+release. VNC
-	 * servers don't like this, so we have to see if we're already pressed
-	 * send release events. So, we run the release handling code all the time.
-	 */
-	for (i = 0 ; i < (int)(sizeof(priv->down_keyval)/sizeof(priv->down_keyval[0])) ; i++) {
-		/* We were pressed, and now we're released, so... */
-		if (priv->down_scancode[i] == key->hardware_keycode) {
-			guint16 scancode = vnc_display_keymap_gdk2rfb(priv->keycode_map,
-								      priv->keycode_maplen,
-								      key->hardware_keycode);
-			/*
-			 * ..send the key release event we're dealing with
-			 *
-			 * NB, we use priv->down_keyval[i], and not our
-			 * current 'keyval', because we need to make sure
-			 * that the release keyval is identical to the
-			 * press keyval. In some layouts, this isn't always
-			 * true, with "Tab" generating Tab on press, and
-			 * ISO_Prev_Group on release.
-			 */
-			vnc_connection_key_event(priv->conn, 0, priv->down_keyval[i], scancode);
-			priv->down_keyval[i] = 0;
-			priv->down_scancode[i] = 0;
-			break;
-		}
-	}
-
-	if (key->type == GDK_KEY_PRESS) {
-		for (i = 0 ; i < (int)(sizeof(priv->down_keyval)/sizeof(priv->down_keyval[0])) ; i++) {
-			if (priv->down_scancode[i] == 0) {
-				guint16 scancode = vnc_display_keymap_gdk2rfb(priv->keycode_map,
-									      priv->keycode_maplen,
-									      key->hardware_keycode);
-				priv->down_keyval[i] = keyval;
-				priv->down_scancode[i] = key->hardware_keycode;
-				/* Send the actual key event we're dealing with */
-				vnc_connection_key_event(priv->conn, 1, keyval, scancode);
-				break;
-			}
-		}
-	}
-
-	if (check_for_grab_key(widget, key->type, key->keyval)) {
-		if (priv->in_pointer_grab)
-			do_pointer_ungrab(VNC_DISPLAY(widget), FALSE);
-		else if (!priv->grab_keyboard || !priv->absolute)
-			do_pointer_grab(VNC_DISPLAY(widget), FALSE);
-	}
-
-	return TRUE;
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    int i;
+    int keyval = key->keyval;
+
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return FALSE;
+
+    if (priv->read_only)
+        return FALSE;
+
+    VNC_DEBUG("%s keycode: %d  state: %d  group %d, keyval: %d",
+              key->type == GDK_KEY_PRESS ? "press" : "release",
+              key->hardware_keycode, key->state, key->group, keyval);
+
+    keyval = vnc_display_keyval_from_keycode(key->hardware_keycode, keyval);
+
+    /*
+     * Some VNC suckiness with key state & modifiers in particular
+     *
+     * Because VNC has no concept of modifiers, we have to track what keys are
+     * pressed and when the widget looses focus send fake key up events for all
+     * keys current held down. This is because upon gaining focus any keys held
+     * down are no longer likely to be down. This would thus result in keys
+     * being 'stuck on' in the remote server. eg upon Alt-Tab to switch window
+     * focus you'd never see key up for the Alt or Tab keys without this :-(
+     *
+     * This is mostly a problem with modifier keys, but its best to just track
+     * all key presses regardless. There's a limit to how many keys a user can
+     * press at once due to a max of 10 fingers (normally :-), so down_key_vals
+     * is only storing upto 16 for now. Should be plenty...
+     *
+     * Arggggh.
+     */
+
+    /*
+     * First the key release handling. This is *always* run, even for Key press
+     * events, because GTK will often merge sequential press+release pairs of
+     * the same key into a sequence of press+press+press+press+release. VNC
+     * servers don't like this, so we have to see if we're already pressed
+     * send release events. So, we run the release handling code all the time.
+     */
+    for (i = 0 ; i < (int)(sizeof(priv->down_keyval)/sizeof(priv->down_keyval[0])) ; i++) {
+        /* We were pressed, and now we're released, so... */
+        if (priv->down_scancode[i] == key->hardware_keycode) {
+            guint16 scancode = vnc_display_keymap_gdk2rfb(priv->keycode_map,
+                                                          priv->keycode_maplen,
+                                                          key->hardware_keycode);
+            /*
+             * ..send the key release event we're dealing with
+             *
+             * NB, we use priv->down_keyval[i], and not our
+             * current 'keyval', because we need to make sure
+             * that the release keyval is identical to the
+             * press keyval. In some layouts, this isn't always
+             * true, with "Tab" generating Tab on press, and
+             * ISO_Prev_Group on release.
+             */
+            vnc_connection_key_event(priv->conn, 0, priv->down_keyval[i], scancode);
+            priv->down_keyval[i] = 0;
+            priv->down_scancode[i] = 0;
+            break;
+        }
+    }
+
+    if (key->type == GDK_KEY_PRESS) {
+        for (i = 0 ; i < (int)(sizeof(priv->down_keyval)/sizeof(priv->down_keyval[0])) ; i++) {
+            if (priv->down_scancode[i] == 0) {
+                guint16 scancode = vnc_display_keymap_gdk2rfb(priv->keycode_map,
+                                                              priv->keycode_maplen,
+                                                              key->hardware_keycode);
+                priv->down_keyval[i] = keyval;
+                priv->down_scancode[i] = key->hardware_keycode;
+                /* Send the actual key event we're dealing with */
+                vnc_connection_key_event(priv->conn, 1, keyval, scancode);
+                break;
+            }
+        }
+    }
+
+    if (check_for_grab_key(widget, key->type, key->keyval)) {
+        if (priv->in_pointer_grab)
+            do_pointer_ungrab(VNC_DISPLAY(widget), FALSE);
+        else if (!priv->grab_keyboard || !priv->absolute)
+            do_pointer_grab(VNC_DISPLAY(widget), FALSE);
+    }
+
+    return TRUE;
 }
 
 static gboolean enter_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC_UNUSED)
 {
-        VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
 
-        if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-                return FALSE;
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return FALSE;
 
-        if (priv->grab_keyboard)
-                do_keyboard_grab(VNC_DISPLAY(widget), FALSE);
+    if (priv->grab_keyboard)
+        do_keyboard_grab(VNC_DISPLAY(widget), FALSE);
 
-        if (priv->local_pointer)
-                do_pointer_show(VNC_DISPLAY(widget));
+    if (priv->local_pointer)
+        do_pointer_show(VNC_DISPLAY(widget));
 
-        return TRUE;
+    return TRUE;
 }
 
 static gboolean leave_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC_UNUSED)
 {
-        VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
 
-        if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-                return FALSE;
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return FALSE;
 
-        if (priv->grab_keyboard)
-                do_keyboard_ungrab(VNC_DISPLAY(widget), FALSE);
+    if (priv->grab_keyboard)
+        do_keyboard_ungrab(VNC_DISPLAY(widget), FALSE);
 
-        if (priv->grab_pointer)
-                do_pointer_ungrab(VNC_DISPLAY(widget), FALSE);
+    if (priv->grab_pointer)
+        do_pointer_ungrab(VNC_DISPLAY(widget), FALSE);
 
-        return TRUE;
+    return TRUE;
 }
 
 
 static gboolean focus_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_UNUSED)
 {
-        VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
-	int i;
-
-        if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-                return FALSE;
-
-	for (i = 0 ; i < (int)(sizeof(priv->down_keyval)/sizeof(priv->down_keyval[0])) ; i++) {
-		/* We are currently pressed so... */
-		if (priv->down_scancode[i] != 0) {
-			guint16 scancode = vnc_display_keymap_gdk2rfb(priv->keycode_map,
-								      priv->keycode_maplen,
-								      priv->down_scancode[i]);
-			/* ..send the fake key release event to match */
-			vnc_connection_key_event(priv->conn, 0,
-						 priv->down_keyval[i], scancode);
-			priv->down_keyval[i] = 0;
-			priv->down_scancode[i] = 0;
-		}
-	}
+    VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
+    int i;
+
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return FALSE;
+
+    for (i = 0 ; i < (int)(sizeof(priv->down_keyval)/sizeof(priv->down_keyval[0])) ; i++) {
+        /* We are currently pressed so... */
+        if (priv->down_scancode[i] != 0) {
+            guint16 scancode = vnc_display_keymap_gdk2rfb(priv->keycode_map,
+                                                          priv->keycode_maplen,
+                                                          priv->down_scancode[i]);
+            /* ..send the fake key release event to match */
+            vnc_connection_key_event(priv->conn, 0,
+                                     priv->down_keyval[i], scancode);
+            priv->down_keyval[i] = 0;
+            priv->down_scancode[i] = 0;
+        }
+    }
 
-        return TRUE;
+    return TRUE;
 }
 
 static void on_framebuffer_update(VncConnection *conn G_GNUC_UNUSED,
-				  int x, int y, int w, int h,
-				  gpointer opaque)
-{
-	GtkWidget *widget = GTK_WIDGET(opaque);
-	VncDisplay *obj = VNC_DISPLAY(widget);
-	VncDisplayPrivate *priv = obj->priv;
-	int ww, wh;
-	int fbw, fbh;
-
-	fbw = vnc_framebuffer_get_width(VNC_FRAMEBUFFER(priv->fb));
-	fbh = vnc_framebuffer_get_height(VNC_FRAMEBUFFER(priv->fb));
-
-	gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
-
-	/* If we have a pixmap, update the region which changed.
-	 * If we don't have a pixmap, the entire thing will be
-	 * created & rendered during the drawing handler
-	 */
-	if (priv->fbCache) {
-		cairo_t *cr = cairo_create(priv->fbCache);
-		cairo_surface_t *surface = vnc_cairo_framebuffer_get_surface(priv->fb);
-
-		cairo_rectangle(cr, x, y, w, h);
-		cairo_clip(cr);
-		cairo_set_source_surface(cr, surface, 0, 0);
-		cairo_paint(cr);
-
-		cairo_destroy(cr);
-	}
+                                  int x, int y, int w, int h,
+                                  gpointer opaque)
+{
+    GtkWidget *widget = GTK_WIDGET(opaque);
+    VncDisplay *obj = VNC_DISPLAY(widget);
+    VncDisplayPrivate *priv = obj->priv;
+    int ww, wh;
+    int fbw, fbh;
+
+    fbw = vnc_framebuffer_get_width(VNC_FRAMEBUFFER(priv->fb));
+    fbh = vnc_framebuffer_get_height(VNC_FRAMEBUFFER(priv->fb));
+
+    gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
+
+    /* If we have a pixmap, update the region which changed.
+     * If we don't have a pixmap, the entire thing will be
+     * created & rendered during the drawing handler
+     */
+    if (priv->fbCache) {
+        cairo_t *cr = cairo_create(priv->fbCache);
+        cairo_surface_t *surface = vnc_cairo_framebuffer_get_surface(priv->fb);
+
+        cairo_rectangle(cr, x, y, w, h);
+        cairo_clip(cr);
+        cairo_set_source_surface(cr, surface, 0, 0);
+        cairo_paint(cr);
+
+        cairo_destroy(cr);
+    }
 
-	if (priv->allow_scaling) {
-		double sx, sy;
+    if (priv->allow_scaling) {
+        double sx, sy;
 
-		/* Scale the VNC region to produce expose region */
+        /* Scale the VNC region to produce expose region */
 
-		sx = (double)ww / (double)fbw;
-		sy = (double)wh / (double)fbh;
+        sx = (double)ww / (double)fbw;
+        sy = (double)wh / (double)fbh;
 
-		x *= sx;
-		y *= sy;
-		w *= sx;
-		h *= sy;
+        x *= sx;
+        y *= sy;
+        w *= sx;
+        h *= sy;
 
-		/* Without this, we get horizontal & vertical line artifacts
-		 * when drawing. This "fix" is somewhat dubious though. The
-		 * true mistake & fix almost certainly lies elsewhere.
-		 */
-		x -= 2;
-		y -= 2;
-		w += 4;
-		h += 4;
-	} else {
-		int mw = 0, mh = 0;
+        /* Without this, we get horizontal & vertical line artifacts
+         * when drawing. This "fix" is somewhat dubious though. The
+         * true mistake & fix almost certainly lies elsewhere.
+         */
+        x -= 2;
+        y -= 2;
+        w += 4;
+        h += 4;
+    } else {
+        int mw = 0, mh = 0;
 
-		/* Offset the VNC region to produce expose region */
+        /* Offset the VNC region to produce expose region */
 
-		if (ww > fbw)
-			mw = (ww - fbw) / 2;
-		if (wh > fbh)
-			mh = (wh - fbh) / 2;
+        if (ww > fbw)
+            mw = (ww - fbw) / 2;
+        if (wh > fbh)
+            mh = (wh - fbh) / 2;
 
-		x += mw;
-		y += mh;
-	}
+        x += mw;
+        y += mh;
+    }
 
-	gtk_widget_queue_draw_area(widget, x, y, w, h);
+    gtk_widget_queue_draw_area(widget, x, y, w, h);
 
-	vnc_connection_framebuffer_update_request(priv->conn, 1,
-						  0, 0,
-						  vnc_connection_get_width(priv->conn),
-						  vnc_connection_get_height(priv->conn));
+    vnc_connection_framebuffer_update_request(priv->conn, 1,
+                                              0, 0,
+                                              vnc_connection_get_width(priv->conn),
+                                              vnc_connection_get_height(priv->conn));
 }
 
 
 static void do_framebuffer_init(VncDisplay *obj,
-				const VncPixelFormat *remoteFormat,
-				int width, int height, gboolean quiet)
+                                const VncPixelFormat *remoteFormat,
+                                int width, int height, gboolean quiet)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
-		return;
+    if (priv->conn == NULL || !vnc_connection_is_initialized(priv->conn))
+        return;
 
-	if (priv->fb) {
-		g_object_unref(priv->fb);
-		priv->fb = NULL;
-	}
-	if (priv->fbCache) {
-		cairo_surface_destroy(priv->fbCache);
-		priv->fbCache = NULL;
-	}
+    if (priv->fb) {
+        g_object_unref(priv->fb);
+        priv->fb = NULL;
+    }
+    if (priv->fbCache) {
+        cairo_surface_destroy(priv->fbCache);
+        priv->fbCache = NULL;
+    }
 
-	if (priv->null_cursor == NULL) {
-		priv->null_cursor = create_null_cursor();
-		if (priv->local_pointer)
-			do_pointer_show(obj);
-		else if (priv->in_pointer_grab || priv->absolute)
-			do_pointer_hide(obj);
-	}
+    if (priv->null_cursor == NULL) {
+        priv->null_cursor = create_null_cursor();
+        if (priv->local_pointer)
+            do_pointer_show(obj);
+        else if (priv->in_pointer_grab || priv->absolute)
+            do_pointer_hide(obj);
+    }
 
-	priv->fb = vnc_cairo_framebuffer_new(width, height, remoteFormat);
-	vnc_connection_set_framebuffer(priv->conn, VNC_FRAMEBUFFER(priv->fb));
+    priv->fb = vnc_cairo_framebuffer_new(width, height, remoteFormat);
+    vnc_connection_set_framebuffer(priv->conn, VNC_FRAMEBUFFER(priv->fb));
 
-	if (priv->force_size)
-		gtk_widget_set_size_request(GTK_WIDGET(obj), width, height);
+    if (priv->force_size)
+        gtk_widget_set_size_request(GTK_WIDGET(obj), width, height);
 
-	if (!quiet) {
-		g_signal_emit(G_OBJECT(obj),
-			      signals[VNC_DESKTOP_RESIZE],
-			      0,
-			      width, height);
-	}
+    if (!quiet) {
+        g_signal_emit(G_OBJECT(obj),
+                      signals[VNC_DESKTOP_RESIZE],
+                      0,
+                      width, height);
+    }
 }
 
 static void on_desktop_resize(VncConnection *conn G_GNUC_UNUSED,
-			      int width, int height,
-			      gpointer opaque)
+                              int width, int height,
+                              gpointer opaque)
 {
-        VncDisplay *obj = VNC_DISPLAY(opaque);
-	VncDisplayPrivate *priv = obj->priv;
-	const VncPixelFormat *remoteFormat;
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplayPrivate *priv = obj->priv;
+    const VncPixelFormat *remoteFormat;
 
-	remoteFormat = vnc_connection_get_pixel_format(priv->conn);
+    remoteFormat = vnc_connection_get_pixel_format(priv->conn);
 
-	do_framebuffer_init(opaque, remoteFormat, width, height, FALSE);
+    do_framebuffer_init(opaque, remoteFormat, width, height, FALSE);
 
-	vnc_connection_framebuffer_update_request(priv->conn, 0, 0, 0, width, height);
+    vnc_connection_framebuffer_update_request(priv->conn, 0, 0, 0, width, height);
 }
 
 static void on_pixel_format_changed(VncConnection *conn G_GNUC_UNUSED,
-				    VncPixelFormat *remoteFormat,
-				    gpointer opaque)
+                                    VncPixelFormat *remoteFormat,
+                                    gpointer opaque)
 {
-        VncDisplay *obj = VNC_DISPLAY(opaque);
-        VncDisplayPrivate *priv = obj->priv;
-	gint16 width = vnc_connection_get_width(priv->conn);
-	gint16 height = vnc_connection_get_height(priv->conn);
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplayPrivate *priv = obj->priv;
+    gint16 width = vnc_connection_get_width(priv->conn);
+    gint16 height = vnc_connection_get_height(priv->conn);
 
-	do_framebuffer_init(opaque, remoteFormat, width, height, TRUE);
+    do_framebuffer_init(opaque, remoteFormat, width, height, TRUE);
 
-	vnc_connection_framebuffer_update_request(priv->conn, 0, 0, 0, width, height);
+    vnc_connection_framebuffer_update_request(priv->conn, 0, 0, 0, width, height);
 }
 
 static gboolean vnc_display_set_preferred_pixel_format(VncDisplay *display)
 {
-	VncDisplayPrivate *priv = display->priv;
-	GdkVisual *v =  gtk_widget_get_visual(GTK_WIDGET(display));
-	VncPixelFormat fmt;
-	const VncPixelFormat *currentFormat;
+    VncDisplayPrivate *priv = display->priv;
+    GdkVisual *v =  gtk_widget_get_visual(GTK_WIDGET(display));
+    VncPixelFormat fmt;
+    const VncPixelFormat *currentFormat;
 
-	memset(&fmt, 0, sizeof(fmt));
+    memset(&fmt, 0, sizeof(fmt));
 
-	/* Get current pixel format for server */
-	currentFormat = vnc_connection_get_pixel_format(priv->conn);
+    /* Get current pixel format for server */
+    currentFormat = vnc_connection_get_pixel_format(priv->conn);
 
-	switch (priv->depth) {
-	case VNC_DISPLAY_DEPTH_COLOR_DEFAULT:
-		VNC_DEBUG ("Using default colour depth %d (%d bpp) (true color? %d)",
-			   currentFormat->depth, currentFormat->bits_per_pixel,
-			   currentFormat->true_color_flag);
+    switch (priv->depth) {
+    case VNC_DISPLAY_DEPTH_COLOR_DEFAULT:
+        VNC_DEBUG ("Using default colour depth %d (%d bpp) (true color? %d)",
+                   currentFormat->depth, currentFormat->bits_per_pixel,
+                   currentFormat->true_color_flag);
 #if 0
-		/* TigerVNC always sends back the encoding even if
-		   unchanged from what the server suggested. This
-		   does not appear to matter, so lets save the bytes */
-		memcpy(&fmt, currentFormat, sizeof(fmt));
-		break;
+        /* TigerVNC always sends back the encoding even if
+           unchanged from what the server suggested. This
+           does not appear to matter, so lets save the bytes */
+        memcpy(&fmt, currentFormat, sizeof(fmt));
+        break;
 #else
-		return TRUE;
+        return TRUE;
 #endif
 
-	case VNC_DISPLAY_DEPTH_COLOR_FULL:
-		fmt.depth = 24;
-		fmt.bits_per_pixel = 32;
-		fmt.red_max = 255;
-		fmt.green_max = 255;
-		fmt.blue_max = 255;
-		fmt.red_shift = 16;
-		fmt.green_shift = 8;
-		fmt.blue_shift = 0;
-		fmt.true_color_flag = 1;
-		break;
-
-	case VNC_DISPLAY_DEPTH_COLOR_MEDIUM:
-		fmt.depth = 15;
-		fmt.bits_per_pixel = 16;
-		fmt.red_max = 31;
-		fmt.green_max = 31;
-		fmt.blue_max = 31;
-		fmt.red_shift = 11;
-		fmt.green_shift = 6;
-		fmt.blue_shift = 1;
-		fmt.true_color_flag = 1;
-		break;
-
-	case VNC_DISPLAY_DEPTH_COLOR_LOW:
-		fmt.depth = 8;
-		fmt.bits_per_pixel = 8;
-		fmt.red_max = 7;
-		fmt.green_max = 7;
-		fmt.blue_max = 3;
-		fmt.red_shift = 5;
-		fmt.green_shift = 2;
-		fmt.blue_shift = 0;
-		fmt.true_color_flag = 1;
-		break;
-
-	case VNC_DISPLAY_DEPTH_COLOR_ULTRA_LOW:
-		fmt.depth = 3;
-		fmt.bits_per_pixel = 8;
-		fmt.red_max = 1;
-		fmt.green_max = 1;
-		fmt.blue_max = 1;
-		fmt.red_shift = 7;
-		fmt.green_shift = 6;
-		fmt.blue_shift = 5;
-		fmt.true_color_flag = 1;
-		break;
-
-	default:
-		g_assert_not_reached ();
-	}
-
-	#if GTK_CHECK_VERSION (2, 21, 1)
-	fmt.byte_order = gdk_visual_get_byte_order (v) == GDK_LSB_FIRST ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
-	#else
-	fmt.byte_order = v->byte_order == GDK_LSB_FIRST ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
-	#endif
-
-	VNC_DEBUG ("Set depth color to %d (%d bpp)", fmt.depth, fmt.bits_per_pixel);
-	if (!vnc_connection_set_pixel_format(priv->conn, &fmt))
-		return FALSE;
-
-	return TRUE;
+    case VNC_DISPLAY_DEPTH_COLOR_FULL:
+        fmt.depth = 24;
+        fmt.bits_per_pixel = 32;
+        fmt.red_max = 255;
+        fmt.green_max = 255;
+        fmt.blue_max = 255;
+        fmt.red_shift = 16;
+        fmt.green_shift = 8;
+        fmt.blue_shift = 0;
+        fmt.true_color_flag = 1;
+        break;
+
+    case VNC_DISPLAY_DEPTH_COLOR_MEDIUM:
+        fmt.depth = 15;
+        fmt.bits_per_pixel = 16;
+        fmt.red_max = 31;
+        fmt.green_max = 31;
+        fmt.blue_max = 31;
+        fmt.red_shift = 11;
+        fmt.green_shift = 6;
+        fmt.blue_shift = 1;
+        fmt.true_color_flag = 1;
+        break;
+
+    case VNC_DISPLAY_DEPTH_COLOR_LOW:
+        fmt.depth = 8;
+        fmt.bits_per_pixel = 8;
+        fmt.red_max = 7;
+        fmt.green_max = 7;
+        fmt.blue_max = 3;
+        fmt.red_shift = 5;
+        fmt.green_shift = 2;
+        fmt.blue_shift = 0;
+        fmt.true_color_flag = 1;
+        break;
+
+    case VNC_DISPLAY_DEPTH_COLOR_ULTRA_LOW:
+        fmt.depth = 3;
+        fmt.bits_per_pixel = 8;
+        fmt.red_max = 1;
+        fmt.green_max = 1;
+        fmt.blue_max = 1;
+        fmt.red_shift = 7;
+        fmt.green_shift = 6;
+        fmt.blue_shift = 5;
+        fmt.true_color_flag = 1;
+        break;
+
+    default:
+        g_assert_not_reached ();
+    }
+
+#if GTK_CHECK_VERSION (2, 21, 1)
+    fmt.byte_order = gdk_visual_get_byte_order (v) == GDK_LSB_FIRST ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+#else
+    fmt.byte_order = v->byte_order == GDK_LSB_FIRST ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+#endif
+
+    VNC_DEBUG ("Set depth color to %d (%d bpp)", fmt.depth, fmt.bits_per_pixel);
+    if (!vnc_connection_set_pixel_format(priv->conn, &fmt))
+        return FALSE;
+
+    return TRUE;
 }
 
 static void on_pointer_mode_changed(VncConnection *conn G_GNUC_UNUSED,
-				    gboolean absPointer,
-				    gpointer opaque)
+                                    gboolean absPointer,
+                                    gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplayPrivate *priv = obj->priv;
 
-	if (absPointer && priv->in_pointer_grab && priv->grab_pointer)
-		do_pointer_ungrab(obj, FALSE);
+    if (absPointer && priv->in_pointer_grab && priv->grab_pointer)
+        do_pointer_ungrab(obj, FALSE);
 
-	priv->absolute = absPointer;
+    priv->absolute = absPointer;
 
-	if (!priv->in_pointer_grab && !priv->absolute)
-		do_pointer_show(obj);
+    if (!priv->in_pointer_grab && !priv->absolute)
+        do_pointer_show(obj);
 }
 
 static void on_auth_cred(VncConnection *conn G_GNUC_UNUSED,
-			 GValueArray *creds,
-			 gpointer opaque)
+                         GValueArray *creds,
+                         gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplay *obj = VNC_DISPLAY(opaque);
 
-	g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_CREDENTIAL], 0, creds);
+    g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_CREDENTIAL], 0, creds);
 }
 
 static void on_auth_choose_type(VncConnection *conn,
-				GValueArray *types,
-				gpointer opaque)
-{
-	VncDisplay *obj = VNC_DISPLAY(opaque);
-	VncDisplayPrivate *priv = obj->priv;
-	GSList *l;
-	guint i;
-
-	if (!types->n_values) {
-		VNC_DEBUG("No auth types available to choose from");
-		vnc_connection_shutdown(conn);
-		return;
-	}
+                                GValueArray *types,
+                                gpointer opaque)
+{
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplayPrivate *priv = obj->priv;
+    GSList *l;
+    guint i;
+
+    if (!types->n_values) {
+        VNC_DEBUG("No auth types available to choose from");
+        vnc_connection_shutdown(conn);
+        return;
+    }
 
-	for (l = priv->preferable_auths; l; l=l->next) {
-		int pref = GPOINTER_TO_UINT (l->data);
+    for (l = priv->preferable_auths; l; l=l->next) {
+        int pref = GPOINTER_TO_UINT (l->data);
 
-		for (i=0; i< types->n_values; i++) {
-			GValue *type = g_value_array_get_nth(types, i);
-			if (pref == g_value_get_enum(type)) {
-				vnc_connection_set_auth_type(conn, pref);
-				return;
-			}
-		}
-	}
+        for (i=0; i< types->n_values; i++) {
+            GValue *type = g_value_array_get_nth(types, i);
+            if (pref == g_value_get_enum(type)) {
+                vnc_connection_set_auth_type(conn, pref);
+                return;
+            }
+        }
+    }
 
-	/* No sub-auth matching our supported auth so have to give up */
-	VNC_DEBUG("No preferred auth type found");
-	vnc_connection_shutdown(conn);
+    /* No sub-auth matching our supported auth so have to give up */
+    VNC_DEBUG("No preferred auth type found");
+    vnc_connection_shutdown(conn);
 }
 
 static void on_auth_choose_subtype(VncConnection *conn,
-				   unsigned int type,
-				   GValueArray *subtypes,
-				   gpointer opaque)
-{
-	VncDisplay *obj = VNC_DISPLAY(opaque);
-	VncDisplayPrivate *priv = obj->priv;
-	GSList *l;
-	guint i;
-
-	if (!subtypes->n_values) {
-		VNC_DEBUG("No subtypes available to choose from");
-		vnc_connection_shutdown(conn);
-		return;
-	}
-
-	if (type == VNC_CONNECTION_AUTH_TLS) {
-		l = priv->preferable_auths;
-	} else if (type == VNC_CONNECTION_AUTH_VENCRYPT) {
-		l = priv->preferable_vencrypt_subauths;
-	} else {
-		VNC_DEBUG("Unexpected stackable auth type %d", type);
-		vnc_connection_shutdown(conn);
-		return;
-	}
-
-	for (; l; l=l->next) {
-		int pref = GPOINTER_TO_UINT (l->data);
-
-		/* Don't want to recursively do the same major auth */
-		if (pref == type)
-			continue;
-
-		for (i=0; i< subtypes->n_values; i++) {
-			GValue *subtype = g_value_array_get_nth(subtypes, i);
-			if (pref == g_value_get_enum(subtype)) {
-				vnc_connection_set_auth_subtype(conn, pref);
-				return;
-			}
-		}
-	}
-
-	/* No sub-auth matching our supported auth so have to give up */
-	VNC_DEBUG("No preferred auth subtype found");
-	vnc_connection_shutdown(conn);
+                                   unsigned int type,
+                                   GValueArray *subtypes,
+                                   gpointer opaque)
+{
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplayPrivate *priv = obj->priv;
+    GSList *l;
+    guint i;
+
+    if (!subtypes->n_values) {
+        VNC_DEBUG("No subtypes available to choose from");
+        vnc_connection_shutdown(conn);
+        return;
+    }
+
+    if (type == VNC_CONNECTION_AUTH_TLS) {
+        l = priv->preferable_auths;
+    } else if (type == VNC_CONNECTION_AUTH_VENCRYPT) {
+        l = priv->preferable_vencrypt_subauths;
+    } else {
+        VNC_DEBUG("Unexpected stackable auth type %d", type);
+        vnc_connection_shutdown(conn);
+        return;
+    }
+
+    for (; l; l=l->next) {
+        int pref = GPOINTER_TO_UINT (l->data);
+
+        /* Don't want to recursively do the same major auth */
+        if (pref == type)
+            continue;
+
+        for (i=0; i< subtypes->n_values; i++) {
+            GValue *subtype = g_value_array_get_nth(subtypes, i);
+            if (pref == g_value_get_enum(subtype)) {
+                vnc_connection_set_auth_subtype(conn, pref);
+                return;
+            }
+        }
+    }
+
+    /* No sub-auth matching our supported auth so have to give up */
+    VNC_DEBUG("No preferred auth subtype found");
+    vnc_connection_shutdown(conn);
 }
 
 static void on_auth_failure(VncConnection *conn G_GNUC_UNUSED,
-			    const char *reason,
-			    gpointer opaque)
+                            const char *reason,
+                            gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplay *obj = VNC_DISPLAY(opaque);
 
-	g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_FAILURE], 0, reason);
+    g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_FAILURE], 0, reason);
 }
 
 static void on_auth_unsupported(VncConnection *conn G_GNUC_UNUSED,
-				unsigned int authType,
-				gpointer opaque)
+                                unsigned int authType,
+                                gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplay *obj = VNC_DISPLAY(opaque);
 
-	g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_UNSUPPORTED], 0, authType);
+    g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_UNSUPPORTED], 0, authType);
 }
 
 static void on_server_cut_text(VncConnection *conn G_GNUC_UNUSED,
-			       const gchar *text,
-			       gpointer opaque)
+                               const gchar *text,
+                               gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplay *obj = VNC_DISPLAY(opaque);
 
-	if (obj->priv->read_only)
-		return;
+    if (obj->priv->read_only)
+        return;
 
-	g_signal_emit(G_OBJECT(obj), signals[VNC_SERVER_CUT_TEXT], 0, text);
+    g_signal_emit(G_OBJECT(obj), signals[VNC_SERVER_CUT_TEXT], 0, text);
 }
 
 static void on_bell(VncConnection *conn G_GNUC_UNUSED,
-		    gpointer opaque)
+                    gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplay *obj = VNC_DISPLAY(opaque);
 
-	g_signal_emit(G_OBJECT(obj), signals[VNC_BELL], 0);
+    g_signal_emit(G_OBJECT(obj), signals[VNC_BELL], 0);
 }
 
 static void on_cursor_changed(VncConnection *conn G_GNUC_UNUSED,
-			      VncCursor *cursor,
-			      gpointer opaque)
-{
-	VncDisplay *obj = VNC_DISPLAY(opaque);
-	VncDisplayPrivate *priv = obj->priv;
-
-	VNC_DEBUG("Cursor changed %p x=%d y=%d w=%d h=%d",
-		   cursor,
-		   cursor ? vnc_cursor_get_hotx(cursor) : -1,
-		   cursor ? vnc_cursor_get_hoty(cursor) : -1,
-		   cursor ? vnc_cursor_get_width(cursor) : -1,
-		   cursor ? vnc_cursor_get_height(cursor) : -1);
-
-	if (priv->remote_cursor) {
-		gdk_cursor_unref(priv->remote_cursor);
-		priv->remote_cursor = NULL;
-	}
-
-	if (cursor) {
-		GdkDisplay *display = gtk_widget_get_display(GTK_WIDGET(obj));
-		GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(vnc_cursor_get_data(cursor),
-							     GDK_COLORSPACE_RGB,
-							     TRUE, 8,
-							     vnc_cursor_get_width(cursor),
-							     vnc_cursor_get_height(cursor),
-							     vnc_cursor_get_width(cursor) * 4,
-							     NULL, NULL);
-		priv->remote_cursor = gdk_cursor_new_from_pixbuf(display,
-								 pixbuf,
-								 vnc_cursor_get_hotx(cursor),
-								 vnc_cursor_get_hoty(cursor));
-		g_object_unref(pixbuf);
-	}
-
-	if (priv->in_pointer_grab) {
-		do_pointer_ungrab(obj, TRUE);
-		do_pointer_grab(obj, TRUE);
-	} else if (priv->absolute) {
-		do_pointer_hide(obj);
-	}
+                              VncCursor *cursor,
+                              gpointer opaque)
+{
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplayPrivate *priv = obj->priv;
+
+    VNC_DEBUG("Cursor changed %p x=%d y=%d w=%d h=%d",
+              cursor,
+              cursor ? vnc_cursor_get_hotx(cursor) : -1,
+              cursor ? vnc_cursor_get_hoty(cursor) : -1,
+              cursor ? vnc_cursor_get_width(cursor) : -1,
+              cursor ? vnc_cursor_get_height(cursor) : -1);
+
+    if (priv->remote_cursor) {
+        gdk_cursor_unref(priv->remote_cursor);
+        priv->remote_cursor = NULL;
+    }
+
+    if (cursor) {
+        GdkDisplay *display = gtk_widget_get_display(GTK_WIDGET(obj));
+        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(vnc_cursor_get_data(cursor),
+                                                     GDK_COLORSPACE_RGB,
+                                                     TRUE, 8,
+                                                     vnc_cursor_get_width(cursor),
+                                                     vnc_cursor_get_height(cursor),
+                                                     vnc_cursor_get_width(cursor) * 4,
+                                                     NULL, NULL);
+        priv->remote_cursor = gdk_cursor_new_from_pixbuf(display,
+                                                         pixbuf,
+                                                         vnc_cursor_get_hotx(cursor),
+                                                         vnc_cursor_get_hoty(cursor));
+        g_object_unref(pixbuf);
+    }
+
+    if (priv->in_pointer_grab) {
+        do_pointer_ungrab(obj, TRUE);
+        do_pointer_grab(obj, TRUE);
+    } else if (priv->absolute) {
+        do_pointer_hide(obj);
+    }
 }
 
 static gboolean check_pixbuf_support(const char *name)
 {
-	GSList *list, *i;
+    GSList *list, *i;
 
-	list = gdk_pixbuf_get_formats();
+    list = gdk_pixbuf_get_formats();
 
-	for (i = list; i; i = i->next) {
-		GdkPixbufFormat *fmt = i->data;
-		gchar *fmt_name = gdk_pixbuf_format_get_name(fmt);
-		int cmp;
+    for (i = list; i; i = i->next) {
+        GdkPixbufFormat *fmt = i->data;
+        gchar *fmt_name = gdk_pixbuf_format_get_name(fmt);
+        int cmp;
 
-		cmp = strcmp(fmt_name, name);
-		g_free (fmt_name);
+        cmp = strcmp(fmt_name, name);
+        g_free (fmt_name);
 
-		if (!cmp)
-			break;
-	}
+        if (!cmp)
+            break;
+    }
 
-	g_slist_free(list);
+    g_slist_free(list);
 
-	return !!(i);
+    return !!(i);
 }
 
 static void on_connected(VncConnection *conn G_GNUC_UNUSED,
-			 gpointer opaque)
+                         gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplay *obj = VNC_DISPLAY(opaque);
 
-	g_signal_emit(G_OBJECT(obj), signals[VNC_CONNECTED], 0);
-	VNC_DEBUG("Connected to VNC server");
+    g_signal_emit(G_OBJECT(obj), signals[VNC_CONNECTED], 0);
+    VNC_DEBUG("Connected to VNC server");
 }
 
 
 static void on_initialized(VncConnection *conn G_GNUC_UNUSED,
-			   gpointer opaque)
-{
-	VncDisplay *obj = VNC_DISPLAY(opaque);
-	VncDisplayPrivate *priv = obj->priv;
-	int i;
-
-	/* The order determines which encodings the
-	 * server prefers when it has a choice to use */
-	gint32 encodings[] = {  VNC_CONNECTION_ENCODING_TIGHT_JPEG5,
-				VNC_CONNECTION_ENCODING_TIGHT,
-				VNC_CONNECTION_ENCODING_EXT_KEY_EVENT,
-				VNC_CONNECTION_ENCODING_DESKTOP_RESIZE,
-                                VNC_CONNECTION_ENCODING_WMVi,
-                                VNC_CONNECTION_ENCODING_AUDIO,
-				VNC_CONNECTION_ENCODING_RICH_CURSOR,
-				VNC_CONNECTION_ENCODING_XCURSOR,
-				VNC_CONNECTION_ENCODING_POINTER_CHANGE,
-				VNC_CONNECTION_ENCODING_ZRLE,
-				VNC_CONNECTION_ENCODING_HEXTILE,
-				VNC_CONNECTION_ENCODING_RRE,
-				VNC_CONNECTION_ENCODING_COPY_RECT,
-				VNC_CONNECTION_ENCODING_RAW };
-	int n_encodings = G_N_ELEMENTS(encodings);
-
-#define REMOVE_ENCODING(e)                                             \
-	for (i = 0 ; i < n_encodings ; i++) {			       \
-		if (encodings[i] == e) {			       \
-			if (i < (n_encodings - 1))		       \
-				memmove(encodings + i,		       \
-					encodings + (i + 1),	       \
-					sizeof(gint32) *	       \
-					(n_encodings - (i + 1)));      \
-			n_encodings--;				       \
-			VNC_DEBUG("Removed encoding %d", e);	       \
-			break;					       \
-		}						       \
-	}
-
-	if (!vnc_display_set_preferred_pixel_format(obj))
-		goto error;
-
-	do_framebuffer_init(obj,
-			    vnc_connection_get_pixel_format(priv->conn),
-			    vnc_connection_get_width(priv->conn),
-			    vnc_connection_get_height(priv->conn),
-			    FALSE);
-
-	if (check_pixbuf_support("jpeg")) {
-		if (!priv->allow_lossy)
-			REMOVE_ENCODING(VNC_CONNECTION_ENCODING_TIGHT_JPEG5);
-	} else {
-		REMOVE_ENCODING(VNC_CONNECTION_ENCODING_TIGHT_JPEG5);
-		REMOVE_ENCODING(VNC_CONNECTION_ENCODING_TIGHT);
-	}
-
-	if (priv->keycode_map == NULL)
-		REMOVE_ENCODING(VNC_CONNECTION_ENCODING_EXT_KEY_EVENT);
-
-	VNC_DEBUG("Sending %d encodings", n_encodings);
-	if (!vnc_connection_set_encodings(priv->conn, n_encodings, encodings))
-		goto error;
-
-	VNC_DEBUG("Requesting first framebuffer update");
-	if (!vnc_connection_framebuffer_update_request(priv->conn, 0, 0, 0,
-						       vnc_connection_get_width(priv->conn),
-						       vnc_connection_get_height(priv->conn)))
-		goto error;
-
-	g_signal_emit(G_OBJECT(obj), signals[VNC_INITIALIZED], 0);
-
-	VNC_DEBUG("Initialized VNC server");
-	return;
+                           gpointer opaque)
+{
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VncDisplayPrivate *priv = obj->priv;
+    int i;
+
+    /* The order determines which encodings the
+     * server prefers when it has a choice to use */
+    gint32 encodings[] = {  VNC_CONNECTION_ENCODING_TIGHT_JPEG5,
+                            VNC_CONNECTION_ENCODING_TIGHT,
+                            VNC_CONNECTION_ENCODING_EXT_KEY_EVENT,
+                            VNC_CONNECTION_ENCODING_DESKTOP_RESIZE,
+                            VNC_CONNECTION_ENCODING_WMVi,
+                            VNC_CONNECTION_ENCODING_AUDIO,
+                            VNC_CONNECTION_ENCODING_RICH_CURSOR,
+                            VNC_CONNECTION_ENCODING_XCURSOR,
+                            VNC_CONNECTION_ENCODING_POINTER_CHANGE,
+                            VNC_CONNECTION_ENCODING_ZRLE,
+                            VNC_CONNECTION_ENCODING_HEXTILE,
+                            VNC_CONNECTION_ENCODING_RRE,
+                            VNC_CONNECTION_ENCODING_COPY_RECT,
+                            VNC_CONNECTION_ENCODING_RAW };
+    int n_encodings = G_N_ELEMENTS(encodings);
+
+#define REMOVE_ENCODING(e)                              \
+    for (i = 0 ; i < n_encodings ; i++) {               \
+        if (encodings[i] == e) {                        \
+            if (i < (n_encodings - 1))                  \
+                memmove(encodings + i,                  \
+                        encodings + (i + 1),            \
+                        sizeof(gint32) *                \
+                        (n_encodings - (i + 1)));       \
+            n_encodings--;                              \
+            VNC_DEBUG("Removed encoding %d", e);        \
+            break;                                      \
+        }                                               \
+    }
+
+    if (!vnc_display_set_preferred_pixel_format(obj))
+        goto error;
+
+    do_framebuffer_init(obj,
+                        vnc_connection_get_pixel_format(priv->conn),
+                        vnc_connection_get_width(priv->conn),
+                        vnc_connection_get_height(priv->conn),
+                        FALSE);
+
+    if (check_pixbuf_support("jpeg")) {
+        if (!priv->allow_lossy)
+            REMOVE_ENCODING(VNC_CONNECTION_ENCODING_TIGHT_JPEG5);
+    } else {
+        REMOVE_ENCODING(VNC_CONNECTION_ENCODING_TIGHT_JPEG5);
+        REMOVE_ENCODING(VNC_CONNECTION_ENCODING_TIGHT);
+    }
+
+    if (priv->keycode_map == NULL)
+        REMOVE_ENCODING(VNC_CONNECTION_ENCODING_EXT_KEY_EVENT);
+
+    VNC_DEBUG("Sending %d encodings", n_encodings);
+    if (!vnc_connection_set_encodings(priv->conn, n_encodings, encodings))
+        goto error;
+
+    VNC_DEBUG("Requesting first framebuffer update");
+    if (!vnc_connection_framebuffer_update_request(priv->conn, 0, 0, 0,
+                                                   vnc_connection_get_width(priv->conn),
+                                                   vnc_connection_get_height(priv->conn)))
+        goto error;
+
+    g_signal_emit(G_OBJECT(obj), signals[VNC_INITIALIZED], 0);
+
+    VNC_DEBUG("Initialized VNC server");
+    return;
 
  error:
-	vnc_connection_shutdown(priv->conn);
+    vnc_connection_shutdown(priv->conn);
 }
 
 
 static void on_disconnected(VncConnection *conn G_GNUC_UNUSED,
-			    gpointer opaque)
+                            gpointer opaque)
 {
-	VncDisplay *obj = VNC_DISPLAY(opaque);
-	VNC_DEBUG("Disconnected from VNC server");
+    VncDisplay *obj = VNC_DISPLAY(opaque);
+    VNC_DEBUG("Disconnected from VNC server");
 
-	g_signal_emit(G_OBJECT(obj), signals[VNC_DISCONNECTED], 0);
-	g_object_unref(G_OBJECT(obj));
+    g_signal_emit(G_OBJECT(obj), signals[VNC_DISCONNECTED], 0);
+    g_object_unref(G_OBJECT(obj));
 }
 
 
 gboolean vnc_display_open_fd(VncDisplay *obj, int fd)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	if (vnc_connection_is_open(priv->conn))
-		return FALSE;
+    if (vnc_connection_is_open(priv->conn))
+        return FALSE;
 
-	if (!vnc_connection_set_shared(priv->conn, priv->shared_flag))
-		return FALSE;
+    if (!vnc_connection_set_shared(priv->conn, priv->shared_flag))
+        return FALSE;
 
-	if (!vnc_connection_open_fd(priv->conn, fd))
-		return FALSE;
+    if (!vnc_connection_open_fd(priv->conn, fd))
+        return FALSE;
 
-	g_object_ref(G_OBJECT(obj));
+    g_object_ref(G_OBJECT(obj));
 
-	return TRUE;
+    return TRUE;
 }
 
 gboolean vnc_display_open_host(VncDisplay *obj, const char *host, const char *port)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	if (vnc_connection_is_open(priv->conn))
-		return FALSE;
+    if (vnc_connection_is_open(priv->conn))
+        return FALSE;
 
-	if (!vnc_connection_set_shared(priv->conn, priv->shared_flag))
-		return FALSE;
+    if (!vnc_connection_set_shared(priv->conn, priv->shared_flag))
+        return FALSE;
 
-	if (!vnc_connection_open_host(priv->conn, host, port))
-		return FALSE;
+    if (!vnc_connection_open_host(priv->conn, host, port))
+        return FALSE;
 
-	g_object_ref(G_OBJECT(obj));
+    g_object_ref(G_OBJECT(obj));
 
-	return TRUE;
+    return TRUE;
 }
 
 gboolean vnc_display_is_open(VncDisplay *obj)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	return vnc_connection_is_open(priv->conn);
+    return vnc_connection_is_open(priv->conn);
 }
 
 void vnc_display_close(VncDisplay *obj)
 {
-	VncDisplayPrivate *priv = obj->priv;
-	GtkWidget *widget = GTK_WIDGET(obj);
+    VncDisplayPrivate *priv = obj->priv;
+    GtkWidget *widget = GTK_WIDGET(obj);
 
-	if (vnc_connection_is_open(priv->conn)) {
-		VNC_DEBUG("Requesting graceful shutdown of connection");
-		vnc_connection_shutdown(priv->conn);
-	}
+    if (vnc_connection_is_open(priv->conn)) {
+        VNC_DEBUG("Requesting graceful shutdown of connection");
+        vnc_connection_shutdown(priv->conn);
+    }
 
-	if (gtk_widget_get_window(widget)) {
-		gint width, height;
+    if (gtk_widget_get_window(widget)) {
+        gint width, height;
 
-		gdk_drawable_get_size(gtk_widget_get_window(widget), &width, &height);
-		gtk_widget_queue_draw_area(widget, 0, 0, width, height);
-	}
+        gdk_drawable_get_size(gtk_widget_get_window(widget), &width, &height);
+        gtk_widget_queue_draw_area(widget, 0, 0, width, height);
+    }
 }
 
 
 VncConnection * vnc_display_get_connection(VncDisplay *obj)
 {
-	VncDisplayPrivate *priv = obj->priv;
-	return priv->conn;
+    VncDisplayPrivate *priv = obj->priv;
+    return priv->conn;
 }
 
 
 void vnc_display_send_keys(VncDisplay *obj, const guint *keyvals, int nkeyvals)
 {
-	vnc_display_send_keys_ex(obj, keyvals,
-				 nkeyvals, VNC_DISPLAY_KEY_EVENT_CLICK);
+    vnc_display_send_keys_ex(obj, keyvals,
+                             nkeyvals, VNC_DISPLAY_KEY_EVENT_CLICK);
 }
 
 static guint get_scancode_from_keyval(VncDisplay *obj, guint keyval)
 {
-	VncDisplayPrivate *priv = obj->priv;
-	guint keycode = 0;
-	GdkKeymapKey *keys = NULL;
-	gint n_keys = 0;
+    VncDisplayPrivate *priv = obj->priv;
+    guint keycode = 0;
+    GdkKeymapKey *keys = NULL;
+    gint n_keys = 0;
 
-	if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
-					      keyval, &keys, &n_keys)) {
-		/* FIXME what about levels? */
-		keycode = keys[0].keycode;
-		g_free(keys);
-	}
+    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
+                                          keyval, &keys, &n_keys)) {
+        /* FIXME what about levels? */
+        keycode = keys[0].keycode;
+        g_free(keys);
+    }
 
-	return vnc_display_keymap_gdk2rfb(priv->keycode_map, priv->keycode_maplen, keycode);
+    return vnc_display_keymap_gdk2rfb(priv->keycode_map, priv->keycode_maplen, keycode);
 }
 
 void vnc_display_send_keys_ex(VncDisplay *obj, const guint *keyvals,
-			      int nkeyvals, VncDisplayKeyEvent kind)
+                              int nkeyvals, VncDisplayKeyEvent kind)
 {
-	int i;
+    int i;
 
-	if (obj->priv->conn == NULL || !vnc_connection_is_open(obj->priv->conn) || obj->priv->read_only)
-		return;
+    if (obj->priv->conn == NULL || !vnc_connection_is_open(obj->priv->conn) || obj->priv->read_only)
+        return;
 
-	if (kind & VNC_DISPLAY_KEY_EVENT_PRESS) {
-		for (i = 0 ; i < nkeyvals ; i++)
-			vnc_connection_key_event(obj->priv->conn, 1, keyvals[i],
-						 get_scancode_from_keyval(obj, keyvals[i]));
-	}
+    if (kind & VNC_DISPLAY_KEY_EVENT_PRESS) {
+        for (i = 0 ; i < nkeyvals ; i++)
+            vnc_connection_key_event(obj->priv->conn, 1, keyvals[i],
+                                     get_scancode_from_keyval(obj, keyvals[i]));
+    }
 
-	if (kind & VNC_DISPLAY_KEY_EVENT_RELEASE) {
-		for (i = (nkeyvals-1) ; i >= 0 ; i--)
-			vnc_connection_key_event(obj->priv->conn, 0, keyvals[i],
-						 get_scancode_from_keyval(obj, keyvals[i]));
-	}
+    if (kind & VNC_DISPLAY_KEY_EVENT_RELEASE) {
+        for (i = (nkeyvals-1) ; i >= 0 ; i--)
+            vnc_connection_key_event(obj->priv->conn, 0, keyvals[i],
+                                     get_scancode_from_keyval(obj, keyvals[i]));
+    }
 }
 
 void vnc_display_send_pointer(VncDisplay *obj, gint x, gint y, int button_mask)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	if (priv->conn == NULL || !vnc_connection_is_open(obj->priv->conn))
-		return;
+    if (priv->conn == NULL || !vnc_connection_is_open(obj->priv->conn))
+        return;
 
-	if (priv->absolute) {
-		priv->button_mask = button_mask;
-		priv->last_x = x;
-		priv->last_y = y;
-		vnc_connection_pointer_event(priv->conn, priv->button_mask, x, y);
-	}
+    if (priv->absolute) {
+        priv->button_mask = button_mask;
+        priv->last_x = x;
+        priv->last_y = y;
+        vnc_connection_pointer_event(priv->conn, priv->button_mask, x, y);
+    }
 }
 
 static void vnc_display_destroy (GtkObject *obj)
 {
-	VncDisplay *display = VNC_DISPLAY (obj);
-	VNC_DEBUG("Display destroy, requesting that VNC connection close");
-	vnc_display_close(display);
-	GTK_OBJECT_CLASS (vnc_display_parent_class)->destroy (obj);
+    VncDisplay *display = VNC_DISPLAY (obj);
+    VNC_DEBUG("Display destroy, requesting that VNC connection close");
+    vnc_display_close(display);
+    GTK_OBJECT_CLASS (vnc_display_parent_class)->destroy (obj);
 }
 
 
 static void vnc_display_finalize (GObject *obj)
 {
-	VncDisplay *display = VNC_DISPLAY (obj);
-	VncDisplayPrivate *priv = display->priv;
+    VncDisplay *display = VNC_DISPLAY (obj);
+    VncDisplayPrivate *priv = display->priv;
 
-	VNC_DEBUG("Releasing VNC widget");
-	if (vnc_connection_is_open(priv->conn)) {
-		g_warning("VNC widget finalized before the connection finished shutting down\n");
-	}
-	g_object_unref(G_OBJECT(priv->conn));
-	display->priv->conn = NULL;
+    VNC_DEBUG("Releasing VNC widget");
+    if (vnc_connection_is_open(priv->conn)) {
+        g_warning("VNC widget finalized before the connection finished shutting down\n");
+    }
+    g_object_unref(G_OBJECT(priv->conn));
+    display->priv->conn = NULL;
 
-	if (priv->fb) {
-		g_object_unref(priv->fb);
-		priv->fb = NULL;
-	}
-	if (priv->fbCache) {
-		cairo_surface_destroy(priv->fbCache);
-		priv->fbCache = NULL;
-	}
+    if (priv->fb) {
+        g_object_unref(priv->fb);
+        priv->fb = NULL;
+    }
+    if (priv->fbCache) {
+        cairo_surface_destroy(priv->fbCache);
+        priv->fbCache = NULL;
+    }
 
-	if (priv->null_cursor) {
-		gdk_cursor_unref (priv->null_cursor);
-		priv->null_cursor = NULL;
-	}
+    if (priv->null_cursor) {
+        gdk_cursor_unref (priv->null_cursor);
+        priv->null_cursor = NULL;
+    }
 
-	if (priv->remote_cursor) {
-		gdk_cursor_unref(priv->remote_cursor);
-		priv->remote_cursor = NULL;
-	}
+    if (priv->remote_cursor) {
+        gdk_cursor_unref(priv->remote_cursor);
+        priv->remote_cursor = NULL;
+    }
 
-	if (priv->vncgrabseq) {
-		vnc_grab_sequence_free(priv->vncgrabseq);
-		priv->vncgrabseq = NULL;
-	}
+    if (priv->vncgrabseq) {
+        vnc_grab_sequence_free(priv->vncgrabseq);
+        priv->vncgrabseq = NULL;
+    }
 
-	g_slist_free (priv->preferable_auths);
-	g_slist_free (priv->preferable_vencrypt_subauths);
+    g_slist_free (priv->preferable_auths);
+    g_slist_free (priv->preferable_vencrypt_subauths);
 
-	vnc_display_keyval_free_entries();
+    vnc_display_keyval_free_entries();
 
-	G_OBJECT_CLASS (vnc_display_parent_class)->finalize (obj);
+    G_OBJECT_CLASS (vnc_display_parent_class)->finalize (obj);
 }
 
 static void vnc_display_class_init(VncDisplayClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
-	GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
+    GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
 
 #if GTK_CHECK_VERSION (2, 91, 0)
-	gtkwidget_class->draw = draw_event;
+    gtkwidget_class->draw = draw_event;
 #else
-	gtkwidget_class->expose_event = expose_event;
+    gtkwidget_class->expose_event = expose_event;
 #endif
-	gtkwidget_class->motion_notify_event = motion_event;
-	gtkwidget_class->button_press_event = button_event;
-	gtkwidget_class->button_release_event = button_event;
-	gtkwidget_class->scroll_event = scroll_event;
-	gtkwidget_class->key_press_event = key_event;
-	gtkwidget_class->key_release_event = key_event;
-	gtkwidget_class->enter_notify_event = enter_event;
-	gtkwidget_class->leave_notify_event = leave_event;
-	gtkwidget_class->focus_out_event = focus_event;
-
-	object_class->finalize = vnc_display_finalize;
-	object_class->get_property = vnc_display_get_property;
-	object_class->set_property = vnc_display_set_property;
-
-	gtkobject_class->destroy = vnc_display_destroy;
-
-	g_object_class_install_property (object_class,
-					 PROP_POINTER_LOCAL,
-					 g_param_spec_boolean ( "local-pointer",
-								"Local Pointer",
-								"Whether we should use the local pointer",
-								FALSE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_POINTER_GRAB,
-					 g_param_spec_boolean ( "grab-pointer",
-								"Grab Pointer",
-								"Whether we should grab the pointer",
-								FALSE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_KEYBOARD_GRAB,
-					 g_param_spec_boolean ( "grab-keyboard",
-								"Grab Keyboard",
-								"Whether we should grab the keyboard",
-								FALSE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_READ_ONLY,
-					 g_param_spec_boolean ( "read-only",
-								"Read Only",
-								"Whether this connection is read-only mode",
-								FALSE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_WIDTH,
-					 g_param_spec_int     ( "width",
-								"Width",
-								"The width of the remote screen",
-								0,
-								G_MAXINT,
-								0,
-								G_PARAM_READABLE |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_HEIGHT,
-					 g_param_spec_int     ( "height",
-								"Height",
-								"The height of the remote screen",
-								0,
-								G_MAXINT,
-								0,
-								G_PARAM_READABLE |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_NAME,
-					 g_param_spec_string  ( "name",
-								"Name",
-								"The screen name of the remote connection",
-								NULL,
-								G_PARAM_READABLE |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_LOSSY_ENCODING,
-					 g_param_spec_boolean ( "lossy-encoding",
-								"Lossy Encoding",
-								"Whether we should use a lossy encoding",
-								FALSE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_SCALING,
-					 g_param_spec_boolean ( "scaling",
-								"Scaling",
-								"Whether we should use scaling",
-								FALSE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_SHARED_FLAG,
-					 g_param_spec_boolean ( "shared-flag",
-								"Shared Flag",
-								"Whether we should leave other clients connected to the server",
-								FALSE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_FORCE_SIZE,
-					 g_param_spec_boolean ( "force-size",
-								"Force widget size",
-								"Whether we should define the widget size",
-								TRUE,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-
-	g_object_class_install_property (object_class,
-					 PROP_DEPTH,
-					 g_param_spec_enum    ( "depth",
-								"Depth",
-								"The color depth",
-								VNC_TYPE_DISPLAY_DEPTH_COLOR,
-								VNC_DISPLAY_DEPTH_COLOR_DEFAULT,
-								G_PARAM_READWRITE |
-								G_PARAM_CONSTRUCT |
-								G_PARAM_STATIC_NAME |
-								G_PARAM_STATIC_NICK |
-								G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_GRAB_KEYS,
-					 g_param_spec_boxed( "grab-keys",
-							     "Grab keys",
-							     "The key grab sequence",
-							     VNC_TYPE_GRAB_SEQUENCE,
-							     G_PARAM_READWRITE |
-							     G_PARAM_CONSTRUCT |
-							     G_PARAM_STATIC_NAME |
-							     G_PARAM_STATIC_NICK |
-							     G_PARAM_STATIC_BLURB));
-	g_object_class_install_property (object_class,
-					 PROP_CONNECTION,
-					 g_param_spec_object("connection",
-							     "Connection",
-							     "The VNC connection",
-							     VNC_TYPE_CONNECTION,
-							     G_PARAM_READABLE |
-							     G_PARAM_STATIC_NAME |
-							     G_PARAM_STATIC_NICK |
-							     G_PARAM_STATIC_BLURB));
-
-	signals[VNC_CONNECTED] =
-		g_signal_new ("vnc-connected",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncDisplayClass, vnc_connected),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-
-	signals[VNC_INITIALIZED] =
-		g_signal_new ("vnc-initialized",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncDisplayClass, vnc_initialized),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-
-	signals[VNC_DISCONNECTED] =
-		g_signal_new ("vnc-disconnected",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncDisplayClass, vnc_disconnected),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-
-	signals[VNC_AUTH_CREDENTIAL] =
-		g_signal_new ("vnc-auth-credential",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (VncDisplayClass, vnc_auth_credential),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__BOXED,
-			      G_TYPE_NONE,
-			      1,
-			      G_TYPE_VALUE_ARRAY);
-
-
-	signals[VNC_POINTER_GRAB] =
-		g_signal_new("vnc-pointer-grab",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__VOID,
-			     G_TYPE_NONE,
-			     0);
-
-	signals[VNC_POINTER_UNGRAB] =
-		g_signal_new("vnc-pointer-ungrab",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__VOID,
-			     G_TYPE_NONE,
-			     0);
-
-	signals[VNC_KEYBOARD_GRAB] =
-		g_signal_new("vnc-keyboard-grab",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__VOID,
-			     G_TYPE_NONE,
-			     0);
-
-	signals[VNC_KEYBOARD_UNGRAB] =
-		g_signal_new("vnc-keyboard-ungrab",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__VOID,
-			     G_TYPE_NONE,
-			     0);
-
-
-	signals[VNC_DESKTOP_RESIZE] =
-		g_signal_new("vnc-desktop-resize",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_user_marshal_VOID__INT_INT,
-			     G_TYPE_NONE,
-			     2,
-			     G_TYPE_INT, G_TYPE_INT);
-
-	signals[VNC_AUTH_FAILURE] =
-		g_signal_new("vnc-auth-failure",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__STRING,
-			     G_TYPE_NONE,
-			     1,
-			     G_TYPE_STRING);
-
-	signals[VNC_AUTH_UNSUPPORTED] =
-		g_signal_new("vnc-auth-unsupported",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__UINT,
-			     G_TYPE_NONE,
-			     1,
-			     G_TYPE_UINT);
-
-	signals[VNC_SERVER_CUT_TEXT] =
-		g_signal_new("vnc-server-cut-text",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__STRING,
-			     G_TYPE_NONE,
-			     1,
-			     G_TYPE_STRING);
-
-	signals[VNC_BELL] =
-		g_signal_new("vnc-bell",
-			     G_TYPE_FROM_CLASS(klass),
-			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
-			     0,
-			     NULL,
-			     NULL,
-			     g_cclosure_marshal_VOID__VOID,
-			     G_TYPE_NONE,
-			     0);
-
-	g_type_class_add_private(klass, sizeof(VncDisplayPrivate));
+    gtkwidget_class->motion_notify_event = motion_event;
+    gtkwidget_class->button_press_event = button_event;
+    gtkwidget_class->button_release_event = button_event;
+    gtkwidget_class->scroll_event = scroll_event;
+    gtkwidget_class->key_press_event = key_event;
+    gtkwidget_class->key_release_event = key_event;
+    gtkwidget_class->enter_notify_event = enter_event;
+    gtkwidget_class->leave_notify_event = leave_event;
+    gtkwidget_class->focus_out_event = focus_event;
+
+    object_class->finalize = vnc_display_finalize;
+    object_class->get_property = vnc_display_get_property;
+    object_class->set_property = vnc_display_set_property;
+
+    gtkobject_class->destroy = vnc_display_destroy;
+
+    g_object_class_install_property (object_class,
+                                     PROP_POINTER_LOCAL,
+                                     g_param_spec_boolean ( "local-pointer",
+                                                            "Local Pointer",
+                                                            "Whether we should use the local pointer",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_POINTER_GRAB,
+                                     g_param_spec_boolean ( "grab-pointer",
+                                                            "Grab Pointer",
+                                                            "Whether we should grab the pointer",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_KEYBOARD_GRAB,
+                                     g_param_spec_boolean ( "grab-keyboard",
+                                                            "Grab Keyboard",
+                                                            "Whether we should grab the keyboard",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_READ_ONLY,
+                                     g_param_spec_boolean ( "read-only",
+                                                            "Read Only",
+                                                            "Whether this connection is read-only mode",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_WIDTH,
+                                     g_param_spec_int     ( "width",
+                                                            "Width",
+                                                            "The width of the remote screen",
+                                                            0,
+                                                            G_MAXINT,
+                                                            0,
+                                                            G_PARAM_READABLE |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_HEIGHT,
+                                     g_param_spec_int     ( "height",
+                                                            "Height",
+                                                            "The height of the remote screen",
+                                                            0,
+                                                            G_MAXINT,
+                                                            0,
+                                                            G_PARAM_READABLE |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_NAME,
+                                     g_param_spec_string  ( "name",
+                                                            "Name",
+                                                            "The screen name of the remote connection",
+                                                            NULL,
+                                                            G_PARAM_READABLE |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_LOSSY_ENCODING,
+                                     g_param_spec_boolean ( "lossy-encoding",
+                                                            "Lossy Encoding",
+                                                            "Whether we should use a lossy encoding",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_SCALING,
+                                     g_param_spec_boolean ( "scaling",
+                                                            "Scaling",
+                                                            "Whether we should use scaling",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_SHARED_FLAG,
+                                     g_param_spec_boolean ( "shared-flag",
+                                                            "Shared Flag",
+                                                            "Whether we should leave other clients connected to the server",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_FORCE_SIZE,
+                                     g_param_spec_boolean ( "force-size",
+                                                            "Force widget size",
+                                                            "Whether we should define the widget size",
+                                                            TRUE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+
+    g_object_class_install_property (object_class,
+                                     PROP_DEPTH,
+                                     g_param_spec_enum    ( "depth",
+                                                            "Depth",
+                                                            "The color depth",
+                                                            VNC_TYPE_DISPLAY_DEPTH_COLOR,
+                                                            VNC_DISPLAY_DEPTH_COLOR_DEFAULT,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_GRAB_KEYS,
+                                     g_param_spec_boxed( "grab-keys",
+                                                         "Grab keys",
+                                                         "The key grab sequence",
+                                                         VNC_TYPE_GRAB_SEQUENCE,
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_CONNECTION,
+                                     g_param_spec_object("connection",
+                                                         "Connection",
+                                                         "The VNC connection",
+                                                         VNC_TYPE_CONNECTION,
+                                                         G_PARAM_READABLE |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+
+    signals[VNC_CONNECTED] =
+        g_signal_new ("vnc-connected",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncDisplayClass, vnc_connected),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
+    signals[VNC_INITIALIZED] =
+        g_signal_new ("vnc-initialized",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncDisplayClass, vnc_initialized),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
+    signals[VNC_DISCONNECTED] =
+        g_signal_new ("vnc-disconnected",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncDisplayClass, vnc_disconnected),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
+    signals[VNC_AUTH_CREDENTIAL] =
+        g_signal_new ("vnc-auth-credential",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_FIRST,
+                      G_STRUCT_OFFSET (VncDisplayClass, vnc_auth_credential),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOXED,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_VALUE_ARRAY);
+
+
+    signals[VNC_POINTER_GRAB] =
+        g_signal_new("vnc-pointer-grab",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE,
+                     0);
+
+    signals[VNC_POINTER_UNGRAB] =
+        g_signal_new("vnc-pointer-ungrab",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE,
+                     0);
+
+    signals[VNC_KEYBOARD_GRAB] =
+        g_signal_new("vnc-keyboard-grab",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE,
+                     0);
+
+    signals[VNC_KEYBOARD_UNGRAB] =
+        g_signal_new("vnc-keyboard-ungrab",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE,
+                     0);
+
+
+    signals[VNC_DESKTOP_RESIZE] =
+        g_signal_new("vnc-desktop-resize",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_user_marshal_VOID__INT_INT,
+                     G_TYPE_NONE,
+                     2,
+                     G_TYPE_INT, G_TYPE_INT);
+
+    signals[VNC_AUTH_FAILURE] =
+        g_signal_new("vnc-auth-failure",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__STRING,
+                     G_TYPE_NONE,
+                     1,
+                     G_TYPE_STRING);
+
+    signals[VNC_AUTH_UNSUPPORTED] =
+        g_signal_new("vnc-auth-unsupported",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__UINT,
+                     G_TYPE_NONE,
+                     1,
+                     G_TYPE_UINT);
+
+    signals[VNC_SERVER_CUT_TEXT] =
+        g_signal_new("vnc-server-cut-text",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__STRING,
+                     G_TYPE_NONE,
+                     1,
+                     G_TYPE_STRING);
+
+    signals[VNC_BELL] =
+        g_signal_new("vnc-bell",
+                     G_TYPE_FROM_CLASS(klass),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE,
+                     0);
+
+    g_type_class_add_private(klass, sizeof(VncDisplayPrivate));
 }
 
 static void vnc_display_init(VncDisplay *display)
 {
-	GtkWidget *widget = GTK_WIDGET(display);
-	VncDisplayPrivate *priv;
-
-	gtk_widget_set_can_focus (widget, TRUE);
-
-	vnc_display_keyval_set_entries();
-
-	gtk_widget_add_events(widget,
-			      GDK_POINTER_MOTION_MASK |
-			      GDK_BUTTON_PRESS_MASK |
-			      GDK_BUTTON_RELEASE_MASK |
-			      GDK_BUTTON_MOTION_MASK |
-			      GDK_ENTER_NOTIFY_MASK |
-			      GDK_LEAVE_NOTIFY_MASK |
-			      GDK_SCROLL_MASK |
-			      GDK_KEY_PRESS_MASK);
-	gtk_widget_set_double_buffered(widget, FALSE);
-
-	priv = display->priv = VNC_DISPLAY_GET_PRIVATE(display);
-	memset(priv, 0, sizeof(VncDisplayPrivate));
-	priv->last_x = -1;
-	priv->last_y = -1;
-	priv->absolute = TRUE;
-	priv->read_only = FALSE;
-	priv->allow_lossy = FALSE;
-	priv->allow_scaling = FALSE;
-	priv->grab_pointer = FALSE;
-	priv->grab_keyboard = FALSE;
-	priv->local_pointer = FALSE;
-	priv->shared_flag = FALSE;
-	priv->force_size = TRUE;
-	priv->vncgrabseq = vnc_grab_sequence_new_from_string("Control_L+Alt_L");
-	priv->vncactiveseq = g_new0(gboolean, priv->vncgrabseq->nkeysyms);
-
-	/*
-	 * Both these two provide TLS based auth, and can layer
-	 * all the other auth types on top. So these two must
-	 * be the first listed
-	 */
-	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_VENCRYPT));
-	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_TLS));
-
-	/*
-	 * Then stackable auth types in order of preference
-	 */
-	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_SASL));
-	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_MSLOGON));
-	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_ARD));
-	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_VNC));
-
-	/*
-	 * Or nothing at all
-	 */
-	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_NONE));
-
-
-	/* Prefered order for VeNCrypt subtypes */
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509SASL));
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509PLAIN));
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509VNC));
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509NONE));
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL));
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSPLAIN));
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC));
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE));
-	/*
-	 * Refuse fully cleartext passwords
-	priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
-							    GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_PLAIN));
-	*/
-
-	priv->conn = vnc_connection_new();
-
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-cursor-changed",
-			 G_CALLBACK(on_cursor_changed), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-pointer-mode-changed",
-			 G_CALLBACK(on_pointer_mode_changed), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-bell",
-			 G_CALLBACK(on_bell), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-server-cut-text",
-			 G_CALLBACK(on_server_cut_text), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-framebuffer-update",
-			 G_CALLBACK(on_framebuffer_update), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-desktop-resize",
-			 G_CALLBACK(on_desktop_resize), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-pixel-format-changed",
-			 G_CALLBACK(on_pixel_format_changed), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-failure",
-			 G_CALLBACK(on_auth_failure), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-unsupported",
-			 G_CALLBACK(on_auth_unsupported), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-credential",
-			 G_CALLBACK(on_auth_cred), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-choose-type",
-			 G_CALLBACK(on_auth_choose_type), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-choose-subtype",
-			 G_CALLBACK(on_auth_choose_subtype), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-connected",
-			 G_CALLBACK(on_connected), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-initialized",
-			 G_CALLBACK(on_initialized), display);
-	g_signal_connect(G_OBJECT(priv->conn), "vnc-disconnected",
-			 G_CALLBACK(on_disconnected), display);
-
-	priv->keycode_map = vnc_display_keymap_gdk2rfb_table(&priv->keycode_maplen);
+    GtkWidget *widget = GTK_WIDGET(display);
+    VncDisplayPrivate *priv;
+
+    gtk_widget_set_can_focus (widget, TRUE);
+
+    vnc_display_keyval_set_entries();
+
+    gtk_widget_add_events(widget,
+                          GDK_POINTER_MOTION_MASK |
+                          GDK_BUTTON_PRESS_MASK |
+                          GDK_BUTTON_RELEASE_MASK |
+                          GDK_BUTTON_MOTION_MASK |
+                          GDK_ENTER_NOTIFY_MASK |
+                          GDK_LEAVE_NOTIFY_MASK |
+                          GDK_SCROLL_MASK |
+                          GDK_KEY_PRESS_MASK);
+    gtk_widget_set_double_buffered(widget, FALSE);
+
+    priv = display->priv = VNC_DISPLAY_GET_PRIVATE(display);
+    memset(priv, 0, sizeof(VncDisplayPrivate));
+    priv->last_x = -1;
+    priv->last_y = -1;
+    priv->absolute = TRUE;
+    priv->read_only = FALSE;
+    priv->allow_lossy = FALSE;
+    priv->allow_scaling = FALSE;
+    priv->grab_pointer = FALSE;
+    priv->grab_keyboard = FALSE;
+    priv->local_pointer = FALSE;
+    priv->shared_flag = FALSE;
+    priv->force_size = TRUE;
+    priv->vncgrabseq = vnc_grab_sequence_new_from_string("Control_L+Alt_L");
+    priv->vncactiveseq = g_new0(gboolean, priv->vncgrabseq->nkeysyms);
+
+    /*
+     * Both these two provide TLS based auth, and can layer
+     * all the other auth types on top. So these two must
+     * be the first listed
+     */
+    priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_VENCRYPT));
+    priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_TLS));
+
+    /*
+     * Then stackable auth types in order of preference
+     */
+    priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_SASL));
+    priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_MSLOGON));
+    priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_ARD));
+    priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_VNC));
+
+    /*
+     * Or nothing at all
+     */
+    priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (VNC_CONNECTION_AUTH_NONE));
+
+
+    /* Prefered order for VeNCrypt subtypes */
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509SASL));
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509PLAIN));
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509VNC));
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_X509NONE));
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSSASL));
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSPLAIN));
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSVNC));
+    priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+                                                        GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_TLSNONE));
+    /*
+     * Refuse fully cleartext passwords
+     priv->preferable_vencrypt_subauths = g_slist_append(priv->preferable_vencrypt_subauths,
+     GUINT_TO_POINTER(VNC_CONNECTION_AUTH_VENCRYPT_PLAIN));
+    */
+
+    priv->conn = vnc_connection_new();
+
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-cursor-changed",
+                     G_CALLBACK(on_cursor_changed), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-pointer-mode-changed",
+                     G_CALLBACK(on_pointer_mode_changed), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-bell",
+                     G_CALLBACK(on_bell), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-server-cut-text",
+                     G_CALLBACK(on_server_cut_text), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-framebuffer-update",
+                     G_CALLBACK(on_framebuffer_update), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-desktop-resize",
+                     G_CALLBACK(on_desktop_resize), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-pixel-format-changed",
+                     G_CALLBACK(on_pixel_format_changed), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-failure",
+                     G_CALLBACK(on_auth_failure), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-unsupported",
+                     G_CALLBACK(on_auth_unsupported), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-credential",
+                     G_CALLBACK(on_auth_cred), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-choose-type",
+                     G_CALLBACK(on_auth_choose_type), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-choose-subtype",
+                     G_CALLBACK(on_auth_choose_subtype), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-connected",
+                     G_CALLBACK(on_connected), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-initialized",
+                     G_CALLBACK(on_initialized), display);
+    g_signal_connect(G_OBJECT(priv->conn), "vnc-disconnected",
+                     G_CALLBACK(on_disconnected), display);
+
+    priv->keycode_map = vnc_display_keymap_gdk2rfb_table(&priv->keycode_maplen);
 }
 
 gboolean vnc_display_set_credential(VncDisplay *obj, int type, const gchar *data)
 {
-	return !vnc_connection_set_credential(obj->priv->conn, type, data);
+    return !vnc_connection_set_credential(obj->priv->conn, type, data);
 }
 
 void vnc_display_set_pointer_local(VncDisplay *obj, gboolean enable)
 {
-	if (obj->priv->null_cursor) {
-		if (enable)
-			do_pointer_show(obj);
-		else if (obj->priv->in_pointer_grab || obj->priv->absolute)
-			do_pointer_hide(obj);
-	}
-	obj->priv->local_pointer = enable;
+    if (obj->priv->null_cursor) {
+        if (enable)
+            do_pointer_show(obj);
+        else if (obj->priv->in_pointer_grab || obj->priv->absolute)
+            do_pointer_hide(obj);
+    }
+    obj->priv->local_pointer = enable;
 }
 
 void vnc_display_set_pointer_grab(VncDisplay *obj, gboolean enable)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	priv->grab_pointer = enable;
-	if (!enable && priv->absolute && priv->in_pointer_grab)
-		do_pointer_ungrab(obj, FALSE);
+    priv->grab_pointer = enable;
+    if (!enable && priv->absolute && priv->in_pointer_grab)
+        do_pointer_ungrab(obj, FALSE);
 }
 
 void vnc_display_set_grab_keys(VncDisplay *obj, VncGrabSequence *seq)
 {
-	if (obj->priv->vncgrabseq) {
-		vnc_grab_sequence_free(obj->priv->vncgrabseq);
-		g_free(obj->priv->vncactiveseq);
-	}
-	if (seq)
-		obj->priv->vncgrabseq = vnc_grab_sequence_copy(seq);
-	else
-		obj->priv->vncgrabseq = vnc_grab_sequence_new_from_string("Control_L+Alt_L");
-	obj->priv->vncactiveseq = g_new0(gboolean, obj->priv->vncgrabseq->nkeysyms);
+    if (obj->priv->vncgrabseq) {
+        vnc_grab_sequence_free(obj->priv->vncgrabseq);
+        g_free(obj->priv->vncactiveseq);
+    }
+    if (seq)
+        obj->priv->vncgrabseq = vnc_grab_sequence_copy(seq);
+    else
+        obj->priv->vncgrabseq = vnc_grab_sequence_new_from_string("Control_L+Alt_L");
+    obj->priv->vncactiveseq = g_new0(gboolean, obj->priv->vncgrabseq->nkeysyms);
 }
 
 VncGrabSequence *vnc_display_get_grab_keys(VncDisplay *obj)
 {
-	return obj->priv->vncgrabseq;
+    return obj->priv->vncgrabseq;
 }
 
 void vnc_display_set_keyboard_grab(VncDisplay *obj, gboolean enable)
 {
-	VncDisplayPrivate *priv = obj->priv;
+    VncDisplayPrivate *priv = obj->priv;
 
-	priv->grab_keyboard = enable;
-	if (!enable && priv->in_keyboard_grab && !priv->in_pointer_grab)
-		do_keyboard_ungrab(obj, FALSE);
+    priv->grab_keyboard = enable;
+    if (!enable && priv->in_keyboard_grab && !priv->in_pointer_grab)
+        do_keyboard_ungrab(obj, FALSE);
 }
 
 void vnc_display_set_read_only(VncDisplay *obj, gboolean enable)
 {
-	obj->priv->read_only = enable;
+    obj->priv->read_only = enable;
 }
 
 static void vnc_display_convert_data(GdkPixbuf *pixbuf,
-				     cairo_surface_t *surface,
-				     int      width,
-				     int      height)
-{
-	int x, y;
-	guchar  *dest_data = gdk_pixbuf_get_pixels(pixbuf);
-	int      dest_stride = gdk_pixbuf_get_rowstride(pixbuf);
-	guchar  *src_data = cairo_image_surface_get_data(surface);
-	int      src_stride = cairo_image_surface_get_stride(surface);
-
-	for (y = 0; y < height; y++) {
-		guint32 *src = (guint32 *) src_data;
-		for (x = 0; x < width; x++) {
-			dest_data[x * 3 + 0] = src[x] >> 16;
-			dest_data[x * 3 + 1] = src[x] >>  8;
-			dest_data[x * 3 + 2] = src[x];
-		}
-
-		src_data += src_stride;
-		dest_data += dest_stride;
-	}
+                                     cairo_surface_t *surface,
+                                     int      width,
+                                     int      height)
+{
+    int x, y;
+    guchar  *dest_data = gdk_pixbuf_get_pixels(pixbuf);
+    int      dest_stride = gdk_pixbuf_get_rowstride(pixbuf);
+    guchar  *src_data = cairo_image_surface_get_data(surface);
+    int      src_stride = cairo_image_surface_get_stride(surface);
+
+    for (y = 0; y < height; y++) {
+        guint32 *src = (guint32 *) src_data;
+        for (x = 0; x < width; x++) {
+            dest_data[x * 3 + 0] = src[x] >> 16;
+            dest_data[x * 3 + 1] = src[x] >>  8;
+            dest_data[x * 3 + 2] = src[x];
+        }
+
+        src_data += src_stride;
+        dest_data += dest_stride;
+    }
 }
 
 /**
@@ -2127,221 +2127,221 @@ static void vnc_display_convert_data(GdkPixbuf *pixbuf,
  **/
 GdkPixbuf *vnc_display_get_pixbuf(VncDisplay *obj)
 {
-	VncDisplayPrivate *priv = obj->priv;
-	VncFramebuffer *fb;
-	cairo_content_t content;
-	cairo_surface_t *surface;
-	GdkPixbuf *pixbuf;
+    VncDisplayPrivate *priv = obj->priv;
+    VncFramebuffer *fb;
+    cairo_content_t content;
+    cairo_surface_t *surface;
+    GdkPixbuf *pixbuf;
 
-	if (!priv->conn ||
-	    !vnc_connection_is_initialized(priv->conn))
-		return NULL;
+    if (!priv->conn ||
+        !vnc_connection_is_initialized(priv->conn))
+        return NULL;
 
-	if (!priv->fb)
-		return NULL;
+    if (!priv->fb)
+        return NULL;
 
-	fb = VNC_FRAMEBUFFER(priv->fb);
-	surface = vnc_cairo_framebuffer_get_surface(priv->fb);
-	content = cairo_surface_get_content(surface) | CAIRO_CONTENT_COLOR;
-	pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
-				!!(content & CAIRO_CONTENT_ALPHA),
-				8,
-				vnc_framebuffer_get_width(fb),
-				vnc_framebuffer_get_height(fb));
+    fb = VNC_FRAMEBUFFER(priv->fb);
+    surface = vnc_cairo_framebuffer_get_surface(priv->fb);
+    content = cairo_surface_get_content(surface) | CAIRO_CONTENT_COLOR;
+    pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+                            !!(content & CAIRO_CONTENT_ALPHA),
+                            8,
+                            vnc_framebuffer_get_width(fb),
+                            vnc_framebuffer_get_height(fb));
 
-	vnc_display_convert_data(pixbuf, surface,
-				 vnc_framebuffer_get_width(fb),
-				 vnc_framebuffer_get_height(fb));
+    vnc_display_convert_data(pixbuf, surface,
+                             vnc_framebuffer_get_width(fb),
+                             vnc_framebuffer_get_height(fb));
 
-	return pixbuf;
+    return pixbuf;
 }
 
 
 int vnc_display_get_width(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), -1);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), -1);
 
-	return vnc_connection_get_width (obj->priv->conn);
+    return vnc_connection_get_width (obj->priv->conn);
 }
 
 int vnc_display_get_height(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), -1);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), -1);
 
-	return vnc_connection_get_height (obj->priv->conn);
+    return vnc_connection_get_height (obj->priv->conn);
 }
 
 const char * vnc_display_get_name(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), NULL);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), NULL);
 
-	return vnc_connection_get_name (obj->priv->conn);
+    return vnc_connection_get_name (obj->priv->conn);
 }
 
 void vnc_display_client_cut_text(VncDisplay *obj, const gchar *text)
 {
-	g_return_if_fail (VNC_IS_DISPLAY (obj));
+    g_return_if_fail (VNC_IS_DISPLAY (obj));
 
-	if (!obj->priv->read_only)
-		vnc_connection_client_cut_text(obj->priv->conn, text, strlen (text));
+    if (!obj->priv->read_only)
+        vnc_connection_client_cut_text(obj->priv->conn, text, strlen (text));
 }
 
 void vnc_display_set_lossy_encoding(VncDisplay *obj, gboolean enable)
 {
-	g_return_if_fail (VNC_IS_DISPLAY (obj));
-	obj->priv->allow_lossy = enable;
+    g_return_if_fail (VNC_IS_DISPLAY (obj));
+    obj->priv->allow_lossy = enable;
 }
 
 void vnc_display_set_shared_flag(VncDisplay *obj, gboolean shared)
 {
-	g_return_if_fail (VNC_IS_DISPLAY (obj));
-	obj->priv->shared_flag = shared;
+    g_return_if_fail (VNC_IS_DISPLAY (obj));
+    obj->priv->shared_flag = shared;
 }
 
 gboolean vnc_display_set_scaling(VncDisplay *obj,
-				 gboolean enable)
+                                 gboolean enable)
 {
-	int ww, wh;
+    int ww, wh;
 
-	obj->priv->allow_scaling = enable;
+    obj->priv->allow_scaling = enable;
 
-	if (obj->priv->fb != NULL) {
-		gdk_drawable_get_size(gtk_widget_get_window(GTK_WIDGET(obj)), &ww, &wh);
-		gtk_widget_queue_draw_area(GTK_WIDGET(obj), 0, 0, ww, wh);
-	}
+    if (obj->priv->fb != NULL) {
+        gdk_drawable_get_size(gtk_widget_get_window(GTK_WIDGET(obj)), &ww, &wh);
+        gtk_widget_queue_draw_area(GTK_WIDGET(obj), 0, 0, ww, wh);
+    }
 
-	return TRUE;
+    return TRUE;
 }
 
 
 void vnc_display_set_force_size(VncDisplay *obj, gboolean enabled)
 {
-	g_return_if_fail (VNC_IS_DISPLAY (obj));
-	obj->priv->force_size = enabled;
+    g_return_if_fail (VNC_IS_DISPLAY (obj));
+    obj->priv->force_size = enabled;
 }
 
 void vnc_display_set_depth(VncDisplay *obj, VncDisplayDepthColor depth)
 {
-	g_return_if_fail (VNC_IS_DISPLAY (obj));
+    g_return_if_fail (VNC_IS_DISPLAY (obj));
 
-	/* Ignore if we are already connected */
-	if (obj->priv->conn && vnc_connection_is_initialized(obj->priv->conn))
-		return;
+    /* Ignore if we are already connected */
+    if (obj->priv->conn && vnc_connection_is_initialized(obj->priv->conn))
+        return;
 
-	if (obj->priv->depth == depth)
-		return;
+    if (obj->priv->depth == depth)
+        return;
 
-	obj->priv->depth = depth;
+    obj->priv->depth = depth;
 }
 
 VncDisplayDepthColor vnc_display_get_depth(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), 0);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), 0);
 
-	return obj->priv->depth;
+    return obj->priv->depth;
 }
 
 gboolean vnc_display_get_force_size(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->force_size;
+    return obj->priv->force_size;
 }
 
 gboolean vnc_display_get_scaling(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->allow_scaling;
+    return obj->priv->allow_scaling;
 }
 
 gboolean vnc_display_get_lossy_encoding(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->allow_lossy;
+    return obj->priv->allow_lossy;
 }
 
 gboolean vnc_display_get_shared_flag(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->shared_flag;
+    return obj->priv->shared_flag;
 }
 
 gboolean vnc_display_get_pointer_local(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->local_pointer;
+    return obj->priv->local_pointer;
 }
 
 gboolean vnc_display_get_pointer_grab(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->grab_pointer;
+    return obj->priv->grab_pointer;
 }
 
 gboolean vnc_display_get_keyboard_grab(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->grab_keyboard;
+    return obj->priv->grab_keyboard;
 }
 
 gboolean vnc_display_get_read_only(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	return obj->priv->read_only;
+    return obj->priv->read_only;
 }
 
 gboolean vnc_display_is_pointer_absolute(VncDisplay *obj)
 {
-	return obj->priv->absolute;
+    return obj->priv->absolute;
 }
 
 GOptionGroup *
 vnc_display_get_option_group (void)
 {
-	GOptionGroup *group;
+    GOptionGroup *group;
 
-	group = g_option_group_new ("gtk-vnc", N_("GTK-VNC Options:"), N_("Show GTK-VNC Options"), NULL, NULL);
-	g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
+    group = g_option_group_new ("gtk-vnc", N_("GTK-VNC Options:"), N_("Show GTK-VNC Options"), NULL, NULL);
+    g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
 
-	g_option_group_add_entries (group, gtk_vnc_args);
+    g_option_group_add_entries (group, gtk_vnc_args);
 
-	return group;
+    return group;
 }
 
 const GOptionEntry *
 vnc_display_get_option_entries (void)
 {
-	return gtk_vnc_args;
+    return gtk_vnc_args;
 }
 
 gboolean
 vnc_display_request_update(VncDisplay *obj)
 {
-	g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
 
-	if (!obj->priv->conn || !vnc_connection_is_initialized(obj->priv->conn))
-		return FALSE;
+    if (!obj->priv->conn || !vnc_connection_is_initialized(obj->priv->conn))
+        return FALSE;
 
-	VNC_DEBUG ("Requesting a full update");
-	return vnc_connection_framebuffer_update_request(obj->priv->conn,
-							 0,
-							 0,
-							 0,
-							 vnc_connection_get_width(obj->priv->conn),
-							 vnc_connection_get_width(obj->priv->conn));
+    VNC_DEBUG ("Requesting a full update");
+    return vnc_connection_framebuffer_update_request(obj->priv->conn,
+                                                     0,
+                                                     0,
+                                                     0,
+                                                     vnc_connection_get_width(obj->priv->conn),
+                                                     vnc_connection_get_width(obj->priv->conn));
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncdisplay.h b/src/vncdisplay.h
index 029f2ab..b2c9a22 100644
--- a/src/vncdisplay.h
+++ b/src/vncdisplay.h
@@ -43,121 +43,117 @@ typedef struct _VncDisplayPrivate VncDisplayPrivate;
 
 struct _VncDisplay
 {
-	GtkDrawingArea parent;
+    GtkDrawingArea parent;
 
-	VncDisplayPrivate *priv;
+    VncDisplayPrivate *priv;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 struct _VncDisplayClass
 {
-	GtkDrawingAreaClass parent_class;
+    GtkDrawingAreaClass parent_class;
 
-	/* Signals */
-	void		(* vnc_connected)	(VncDisplay *display);
-	void		(* vnc_initialized)	(VncDisplay *display);
-	void		(* vnc_disconnected)	(VncDisplay *display);
-	void		(* vnc_auth_credential)	(VncDisplay *display, GValueArray *credList);
+    /* Signals */
+    void (* vnc_connected)(VncDisplay *display);
+    void (* vnc_initialized)(VncDisplay *display);
+    void (* vnc_disconnected)(VncDisplay *display);
+    void (* vnc_auth_credential)(VncDisplay *display, GValueArray *credList);
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
-typedef enum
-{
-	VNC_DISPLAY_CREDENTIAL_PASSWORD,
-	VNC_DISPLAY_CREDENTIAL_USERNAME,
-	VNC_DISPLAY_CREDENTIAL_CLIENTNAME,
+typedef enum {
+    VNC_DISPLAY_CREDENTIAL_PASSWORD,
+    VNC_DISPLAY_CREDENTIAL_USERNAME,
+    VNC_DISPLAY_CREDENTIAL_CLIENTNAME,
 } VncDisplayCredential;
 
-typedef enum
-{
-	VNC_DISPLAY_KEY_EVENT_PRESS = 1,
-	VNC_DISPLAY_KEY_EVENT_RELEASE = 2,
-	VNC_DISPLAY_KEY_EVENT_CLICK = 3,
+typedef enum {
+    VNC_DISPLAY_KEY_EVENT_PRESS = 1,
+    VNC_DISPLAY_KEY_EVENT_RELEASE = 2,
+    VNC_DISPLAY_KEY_EVENT_CLICK = 3,
 } VncDisplayKeyEvent;
 
-typedef enum
-{
-	VNC_DISPLAY_DEPTH_COLOR_DEFAULT = 0,
-	VNC_DISPLAY_DEPTH_COLOR_FULL,
-	VNC_DISPLAY_DEPTH_COLOR_MEDIUM,
-	VNC_DISPLAY_DEPTH_COLOR_LOW,
-	VNC_DISPLAY_DEPTH_COLOR_ULTRA_LOW
+typedef enum {
+    VNC_DISPLAY_DEPTH_COLOR_DEFAULT = 0,
+    VNC_DISPLAY_DEPTH_COLOR_FULL,
+    VNC_DISPLAY_DEPTH_COLOR_MEDIUM,
+    VNC_DISPLAY_DEPTH_COLOR_LOW,
+    VNC_DISPLAY_DEPTH_COLOR_ULTRA_LOW
 } VncDisplayDepthColor;
 
-GType		vnc_display_get_type(void);
-GtkWidget *	vnc_display_new(void);
+GType vnc_display_get_type(void);
+GtkWidget *vnc_display_new(void);
 
-gboolean	vnc_display_open_fd(VncDisplay *obj, int fd);
-gboolean	vnc_display_open_host(VncDisplay *obj, const char *host, const char *port);
-gboolean	vnc_display_is_open(VncDisplay *obj);
-void		vnc_display_close(VncDisplay *obj);
+gboolean vnc_display_open_fd(VncDisplay *obj, int fd);
+gboolean vnc_display_open_host(VncDisplay *obj, const char *host, const char *port);
+gboolean vnc_display_is_open(VncDisplay *obj);
+void vnc_display_close(VncDisplay *obj);
 
-VncConnection * vnc_display_get_connection(VncDisplay *obj);
+VncConnection *vnc_display_get_connection(VncDisplay *obj);
 
-void            vnc_display_send_keys(VncDisplay *obj, const guint *keyvals, int nkeyvals);
-/* FIXME: can we just eliminate the old send_keys interface? */
-void            vnc_display_send_keys_ex(VncDisplay *obj, const guint *keyvals,
-					 int nkeyvals, VncDisplayKeyEvent kind);
+void vnc_display_send_keys(VncDisplay *obj, const guint *keyvals, int nkeyvals);
+void vnc_display_send_keys_ex(VncDisplay *obj, const guint *keyvals,
+                              int nkeyvals, VncDisplayKeyEvent kind);
 
-void		vnc_display_send_pointer(VncDisplay *obj, gint x, gint y, int button_mask);
-void		vnc_display_set_grab_keys(VncDisplay *obj, VncGrabSequence *seq);
-VncGrabSequence	*vnc_display_get_grab_keys(VncDisplay *obj);
+void vnc_display_send_pointer(VncDisplay *obj, gint x, gint y, int button_mask);
+void vnc_display_set_grab_keys(VncDisplay *obj, VncGrabSequence *seq);
+VncGrabSequence        *vnc_display_get_grab_keys(VncDisplay *obj);
 
-gboolean	vnc_display_set_credential(VncDisplay *obj, int type, const gchar *data);
+gboolean vnc_display_set_credential(VncDisplay *obj, int type, const gchar *data);
 
-void		vnc_display_set_pointer_local(VncDisplay *obj, gboolean enable);
-gboolean	vnc_display_get_pointer_local(VncDisplay *obj);
+void vnc_display_set_pointer_local(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_pointer_local(VncDisplay *obj);
 
-void		vnc_display_set_pointer_grab(VncDisplay *obj, gboolean enable);
-gboolean	vnc_display_get_pointer_grab(VncDisplay *obj);
+void vnc_display_set_pointer_grab(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_pointer_grab(VncDisplay *obj);
 
-void		vnc_display_set_keyboard_grab(VncDisplay *obj, gboolean enable);
-gboolean	vnc_display_get_keyboard_grab(VncDisplay *obj);
+void vnc_display_set_keyboard_grab(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_keyboard_grab(VncDisplay *obj);
 
-void		vnc_display_set_read_only(VncDisplay *obj, gboolean enable);
-gboolean	vnc_display_get_read_only(VncDisplay *obj);
+void vnc_display_set_read_only(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_read_only(VncDisplay *obj);
 
-GdkPixbuf *	vnc_display_get_pixbuf(VncDisplay *obj);
+GdkPixbuf *vnc_display_get_pixbuf(VncDisplay *obj);
 
-int		vnc_display_get_width(VncDisplay *obj);
-int		vnc_display_get_height(VncDisplay *obj);
-const char *	vnc_display_get_name(VncDisplay *obj);
+int vnc_display_get_width(VncDisplay *obj);
+int vnc_display_get_height(VncDisplay *obj);
+const char *vnc_display_get_name(VncDisplay *obj);
 
-void		vnc_display_client_cut_text(VncDisplay *obj, const gchar *text);
+void vnc_display_client_cut_text(VncDisplay *obj, const gchar *text);
 
-void		vnc_display_set_lossy_encoding(VncDisplay *obj, gboolean enable);
-gboolean	vnc_display_get_lossy_encoding(VncDisplay *obj);
+void vnc_display_set_lossy_encoding(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_lossy_encoding(VncDisplay *obj);
 
-gboolean	vnc_display_set_scaling(VncDisplay *obj, gboolean enable);
-gboolean	vnc_display_get_scaling(VncDisplay *obj);
+gboolean vnc_display_set_scaling(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_scaling(VncDisplay *obj);
 
-void		vnc_display_set_force_size(VncDisplay *obj, gboolean enable);
-gboolean	vnc_display_get_force_size(VncDisplay *obj);
+void vnc_display_set_force_size(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_force_size(VncDisplay *obj);
 
-void		vnc_display_set_shared_flag(VncDisplay *obj, gboolean shared);
-gboolean	vnc_display_get_shared_flag(VncDisplay *obj);
+void vnc_display_set_shared_flag(VncDisplay *obj, gboolean shared);
+gboolean vnc_display_get_shared_flag(VncDisplay *obj);
 
-void			vnc_display_set_depth(VncDisplay *obj, VncDisplayDepthColor depth);
-VncDisplayDepthColor	vnc_display_get_depth(VncDisplay *obj);
+void vnc_display_set_depth(VncDisplay *obj, VncDisplayDepthColor depth);
+VncDisplayDepthColor vnc_display_get_depth(VncDisplay *obj);
 
-void		vnc_display_force_grab(VncDisplay *obj, gboolean enable);
+void vnc_display_force_grab(VncDisplay *obj, gboolean enable);
 
-gboolean	vnc_display_is_pointer_absolute(VncDisplay *obj);
+gboolean vnc_display_is_pointer_absolute(VncDisplay *obj);
 
-GOptionGroup *  vnc_display_get_option_group(void);
-const GOptionEntry *  vnc_display_get_option_entries(void);
+GOptionGroup *vnc_display_get_option_group(void);
+const GOptionEntry *vnc_display_get_option_entries(void);
 
-gboolean	vnc_display_request_update(VncDisplay *obj);
+gboolean vnc_display_request_update(VncDisplay *obj);
 
 G_END_DECLS
 
 #endif /* VNC_DISPLAY_H */
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncdisplaykeymap.c b/src/vncdisplaykeymap.c
index f94852f..4c4d374 100644
--- a/src/vncdisplaykeymap.c
+++ b/src/vncdisplaykeymap.c
@@ -47,9 +47,9 @@
  * to vncserver
  */
 static struct {
-	GdkKeymapKey *keys;
-	gint n_keys;
-	guint keyval;
+    GdkKeymapKey *keys;
+    gint n_keys;
+    guint keyval;
 } untranslated_keys[] = {{NULL, 0, GDK_Tab}};
 
 static unsigned int ref_count_for_untranslated_keys = 0;
@@ -101,175 +101,175 @@ static unsigned int ref_count_for_untranslated_keys = 0;
 
 static gboolean check_for_xwin(GdkDisplay *dpy)
 {
-	char *vendor = ServerVendor(gdk_x11_display_get_xdisplay(dpy));
+    char *vendor = ServerVendor(gdk_x11_display_get_xdisplay(dpy));
 
-	if (strstr(vendor, "Cygwin/X"))
-		return TRUE;
+    if (strstr(vendor, "Cygwin/X"))
+        return TRUE;
 
-	return FALSE;
+    return FALSE;
 }
 
 static gboolean check_for_xquartz(GdkDisplay *dpy)
 {
-	int nextensions;
-	int i;
-	gboolean match = FALSE;
-	char **extensions = XListExtensions(gdk_x11_display_get_xdisplay(dpy),
-					    &nextensions);
-	for (i = 0 ; extensions != NULL && i < nextensions ; i++) {
-		if (strcmp(extensions[i], "Apple-WM") == 0 ||
-		    strcmp(extensions[i], "Apple-DRI") == 0)
-			match = TRUE;
-	}
-	if (extensions)
-		XFreeExtensionList(extensions);
-
-	return match;
+    int nextensions;
+    int i;
+    gboolean match = FALSE;
+    char **extensions = XListExtensions(gdk_x11_display_get_xdisplay(dpy),
+                                        &nextensions);
+    for (i = 0 ; extensions != NULL && i < nextensions ; i++) {
+        if (strcmp(extensions[i], "Apple-WM") == 0 ||
+            strcmp(extensions[i], "Apple-DRI") == 0)
+            match = TRUE;
+    }
+    if (extensions)
+        XFreeExtensionList(extensions);
+
+    return match;
 }
 #endif
 
 const guint16 const *vnc_display_keymap_gdk2rfb_table(size_t *maplen)
 {
-	GdkDisplay *dpy = gdk_display_get_default();
+    GdkDisplay *dpy = gdk_display_get_default();
 
 #ifdef GDK_WINDOWING_X11
-	if (GDK_IS_X11_DISPLAY(dpy)) {
-		XkbDescPtr desc;
-		const gchar *keycodes = NULL;
-
-		/* There is no easy way to determine what X11 server
-		 * and platform & keyboard driver is in use. Thus we
-		 * do best guess heuristics.
-		 *
-		 * This will need more work for people with other
-		 * X servers..... patches welcomed.
-		 */
-
-		desc = XkbGetKeyboard(gdk_x11_display_get_xdisplay(dpy),
-				      XkbGBN_AllComponentsMask,
-				      XkbUseCoreKbd);
-		if (desc) {
-			if (desc->names) {
-				keycodes = gdk_x11_get_xatom_name(desc->names->keycodes);
-				if (!keycodes)
-					g_warning("could not lookup keycode name");
-			}
-			XkbFreeClientMap(desc, XkbGBN_AllComponentsMask, True);
-		}
-
-		if (check_for_xwin(dpy)) {
-			VNC_DEBUG("Using xwin keycode mapping");
-			*maplen = G_N_ELEMENTS(keymap_xorgxwin2rfb);
-			return keymap_xorgxwin2rfb;
-		} else if (check_for_xquartz(dpy)) {
-			VNC_DEBUG("Using xquartz keycode mapping");
-			*maplen = G_N_ELEMENTS(keymap_xorgxquartz2rfb);
-			return keymap_xorgxquartz2rfb;
-		} else if (keycodes && STRPREFIX(keycodes, "evdev_")) {
-			VNC_DEBUG("Using evdev keycode mapping");
-			*maplen = G_N_ELEMENTS(keymap_xorgevdev2rfb);
-			return keymap_xorgevdev2rfb;
-		} else if (keycodes && STRPREFIX(keycodes, "xfree86_")) {
-			VNC_DEBUG("Using xfree86 keycode mapping");
-			*maplen = G_N_ELEMENTS(keymap_xorgkbd2rfb);
-			return keymap_xorgkbd2rfb;
-		} else {
-			g_warning("Unknown keycode mapping '%s'.\n"
-				  "Please report to gtk-vnc-list gnome org\n"
-				  "including the following information:\n"
-				  "\n"
-				  "  - Operating system\n"
-				  "  - GDK build\n"
-				  "  - X11 Server\n"
-				  "  - xprop -root\n"
-				  "  - xdpyinfo\n",
-				  keycodes);
-			return NULL;
-		}
-	}
+    if (GDK_IS_X11_DISPLAY(dpy)) {
+        XkbDescPtr desc;
+        const gchar *keycodes = NULL;
+
+        /* There is no easy way to determine what X11 server
+         * and platform & keyboard driver is in use. Thus we
+         * do best guess heuristics.
+         *
+         * This will need more work for people with other
+         * X servers..... patches welcomed.
+         */
+
+        desc = XkbGetKeyboard(gdk_x11_display_get_xdisplay(dpy),
+                              XkbGBN_AllComponentsMask,
+                              XkbUseCoreKbd);
+        if (desc) {
+            if (desc->names) {
+                keycodes = gdk_x11_get_xatom_name(desc->names->keycodes);
+                if (!keycodes)
+                    g_warning("could not lookup keycode name");
+            }
+            XkbFreeClientMap(desc, XkbGBN_AllComponentsMask, True);
+        }
+
+        if (check_for_xwin(dpy)) {
+            VNC_DEBUG("Using xwin keycode mapping");
+            *maplen = G_N_ELEMENTS(keymap_xorgxwin2rfb);
+            return keymap_xorgxwin2rfb;
+        } else if (check_for_xquartz(dpy)) {
+            VNC_DEBUG("Using xquartz keycode mapping");
+            *maplen = G_N_ELEMENTS(keymap_xorgxquartz2rfb);
+            return keymap_xorgxquartz2rfb;
+        } else if (keycodes && STRPREFIX(keycodes, "evdev_")) {
+            VNC_DEBUG("Using evdev keycode mapping");
+            *maplen = G_N_ELEMENTS(keymap_xorgevdev2rfb);
+            return keymap_xorgevdev2rfb;
+        } else if (keycodes && STRPREFIX(keycodes, "xfree86_")) {
+            VNC_DEBUG("Using xfree86 keycode mapping");
+            *maplen = G_N_ELEMENTS(keymap_xorgkbd2rfb);
+            return keymap_xorgkbd2rfb;
+        } else {
+            g_warning("Unknown keycode mapping '%s'.\n"
+                      "Please report to gtk-vnc-list gnome org\n"
+                      "including the following information:\n"
+                      "\n"
+                      "  - Operating system\n"
+                      "  - GDK build\n"
+                      "  - X11 Server\n"
+                      "  - xprop -root\n"
+                      "  - xdpyinfo\n",
+                      keycodes);
+            return NULL;
+        }
+    }
 #endif
 
 #ifdef GDK_WINDOWING_WIN32
-	if (GDK_IS_WIN32_DISPLAY(dpy)) {
-		VNC_DEBUG("Using Win32 virtual keycode mapping");
-		*maplen = sizeof(keymap_win322rfb);
-		return keymap_win322rfb;
-	}
+    if (GDK_IS_WIN32_DISPLAY(dpy)) {
+        VNC_DEBUG("Using Win32 virtual keycode mapping");
+        *maplen = sizeof(keymap_win322rfb);
+        return keymap_win322rfb;
+    }
 #endif
 
 #ifdef GDK_WINDOWING_QUARTZ
-	if (GDK_IS_QUARTZ_DISPLAY(dpy)) {
-		VNC_DEBUG("Using OS-X virtual keycode mapping");
-		*maplen = sizeof(keymap_osx2rfb);
-		return keymap_osx2rfb;
-	}
+    if (GDK_IS_QUARTZ_DISPLAY(dpy)) {
+        VNC_DEBUG("Using OS-X virtual keycode mapping");
+        *maplen = sizeof(keymap_osx2rfb);
+        return keymap_osx2rfb;
+    }
 #endif
 
-	g_warning("Unsupported GDK Windowing platform.\n"
-		  "Disabling extended keycode tables.\n"
-		  "Please report to gtk-vnc-list gnome org\n"
-		  "including the following information:\n"
-		  "\n"
-		  "  - Operating system\n"
-		  "  - GDK Windowing system build\n");
-	return NULL;
+    g_warning("Unsupported GDK Windowing platform.\n"
+              "Disabling extended keycode tables.\n"
+              "Please report to gtk-vnc-list gnome org\n"
+              "including the following information:\n"
+              "\n"
+              "  - Operating system\n"
+              "  - GDK Windowing system build\n");
+    return NULL;
 }
 
 guint16 vnc_display_keymap_gdk2rfb(const guint16 const *keycode_map,
-				   size_t keycode_maplen,
-				   guint16 keycode)
+                                   size_t keycode_maplen,
+                                   guint16 keycode)
 {
-	if (!keycode_map)
-		return 0;
-	if (keycode >= keycode_maplen)
-		return 0;
-	return keycode_map[keycode];
+    if (!keycode_map)
+        return 0;
+    if (keycode >= keycode_maplen)
+        return 0;
+    return keycode_map[keycode];
 }
 
 /* Set the keymap entries */
 void vnc_display_keyval_set_entries(void)
 {
-	size_t i;
-	if (ref_count_for_untranslated_keys == 0)
-		for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++)
-			gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
-							  untranslated_keys[i].keyval,
-							  &untranslated_keys[i].keys,
-							  &untranslated_keys[i].n_keys);
-	ref_count_for_untranslated_keys++;
+    size_t i;
+    if (ref_count_for_untranslated_keys == 0)
+        for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++)
+            gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
+                                              untranslated_keys[i].keyval,
+                                              &untranslated_keys[i].keys,
+                                              &untranslated_keys[i].n_keys);
+    ref_count_for_untranslated_keys++;
 }
 
 /* Free the keymap entries */
 void vnc_display_keyval_free_entries(void)
 {
-	size_t i;
+    size_t i;
 
-	if (ref_count_for_untranslated_keys == 0)
-		return;
+    if (ref_count_for_untranslated_keys == 0)
+        return;
 
-	ref_count_for_untranslated_keys--;
-	if (ref_count_for_untranslated_keys == 0)
-		for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++)
-			g_free(untranslated_keys[i].keys);
+    ref_count_for_untranslated_keys--;
+    if (ref_count_for_untranslated_keys == 0)
+        for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++)
+            g_free(untranslated_keys[i].keys);
 
 }
 
 /* Get the keyval from the keycode without the level. */
 guint vnc_display_keyval_from_keycode(guint keycode, guint keyval)
 {
-	size_t i;
-	for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++) {
-		if (keycode == untranslated_keys[i].keys[0].keycode) {
-			return untranslated_keys[i].keyval;
-		}
-	}
-
-	return keyval;
+    size_t i;
+    for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++) {
+        if (keycode == untranslated_keys[i].keys[0].keycode) {
+            return untranslated_keys[i].keyval;
+        }
+    }
+
+    return keyval;
 }
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncdisplaykeymap.h b/src/vncdisplaykeymap.h
index 7cb9946..053e387 100644
--- a/src/vncdisplaykeymap.h
+++ b/src/vncdisplaykeymap.h
@@ -26,10 +26,17 @@
 
 const guint16 const *vnc_display_keymap_gdk2rfb_table(size_t *maplen);
 guint16 vnc_display_keymap_gdk2rfb(const guint16 *keycode_map,
-				   size_t keycode_maplen,
-				   guint16 keycode);
+                                   size_t keycode_maplen,
+                                   guint16 keycode);
 void vnc_display_keyval_set_entries(void);
 void vnc_display_keyval_free_entries(void);
 guint vnc_display_keyval_from_keycode(guint keycode, guint keyval);
 
 #endif /* VNC_DISPLAY_KEYMAP_H */
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/vncframebuffer.c b/src/vncframebuffer.c
index 617f45a..9f021b2 100644
--- a/src/vncframebuffer.c
+++ b/src/vncframebuffer.c
@@ -26,110 +26,110 @@
 
 guint16 vnc_framebuffer_get_width(VncFramebuffer *fb)
 {
-	return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_width(fb);
+    return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_width(fb);
 }
 
 guint16 vnc_framebuffer_get_height(VncFramebuffer *fb)
 {
-	return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_height(fb);
+    return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_height(fb);
 }
 
 int vnc_framebuffer_get_rowstride(VncFramebuffer *fb)
 {
-	return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_rowstride(fb);
+    return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_rowstride(fb);
 }
 
 guint8 *vnc_framebuffer_get_buffer(VncFramebuffer *fb)
 {
-	return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_buffer(fb);
+    return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_buffer(fb);
 }
 
 const VncPixelFormat *vnc_framebuffer_get_local_format(VncFramebuffer *fb)
 {
-	return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_local_format(fb);
+    return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_local_format(fb);
 }
 
 const VncPixelFormat *vnc_framebuffer_get_remote_format(VncFramebuffer *fb)
 {
-	return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_remote_format(fb);
+    return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_remote_format(fb);
 }
 
 gboolean vnc_framebuffer_perfect_format_match(VncFramebuffer *fb)
 {
-	return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->perfect_format_match(fb);
+    return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->perfect_format_match(fb);
 }
 
 void vnc_framebuffer_set_pixel_at(VncFramebuffer *fb,
-				  guint8 *src,
-				  guint16 x, guint16 y)
+                                  guint8 *src,
+                                  guint16 x, guint16 y)
 {
-	VNC_FRAMEBUFFER_GET_INTERFACE(fb)->set_pixel_at(fb, src, x, y);
+    VNC_FRAMEBUFFER_GET_INTERFACE(fb)->set_pixel_at(fb, src, x, y);
 }
 
 void vnc_framebuffer_fill(VncFramebuffer *fb,
-			  guint8 *src,
-			  guint16 x, guint16 y,
-			  guint16 width, guint16 height)
+                          guint8 *src,
+                          guint16 x, guint16 y,
+                          guint16 width, guint16 height)
 {
-	VNC_FRAMEBUFFER_GET_INTERFACE(fb)->fill(fb, src, x, y, width, height);
+    VNC_FRAMEBUFFER_GET_INTERFACE(fb)->fill(fb, src, x, y, width, height);
 }
 
 void vnc_framebuffer_copyrect(VncFramebuffer *fb,
-			      guint16 srcx, guint16 srcy,
-			      guint16 dstx, guint16 dsty,
-			      guint16 width, guint16 height)
+                              guint16 srcx, guint16 srcy,
+                              guint16 dstx, guint16 dsty,
+                              guint16 width, guint16 height)
 {
-	VNC_FRAMEBUFFER_GET_INTERFACE(fb)->copyrect(fb, srcx, srcy, dstx, dsty, width, height);
+    VNC_FRAMEBUFFER_GET_INTERFACE(fb)->copyrect(fb, srcx, srcy, dstx, dsty, width, height);
 }
 
 void vnc_framebuffer_blt(VncFramebuffer *fb,
-			 guint8 *src,
-			 int rowstride,
-			 guint16 x, guint16 y,
-			 guint16 width, guint16 height)
+                         guint8 *src,
+                         int rowstride,
+                         guint16 x, guint16 y,
+                         guint16 width, guint16 height)
 {
-	VNC_FRAMEBUFFER_GET_INTERFACE(fb)->blt(fb, src, rowstride, x, y, width, height);
+    VNC_FRAMEBUFFER_GET_INTERFACE(fb)->blt(fb, src, rowstride, x, y, width, height);
 }
 
 void vnc_framebuffer_rgb24_blt(VncFramebuffer *fb,
-			       guint8 *src,
-			       int rowstride,
-			       guint16 x, guint16 y,
-			       guint16 width, guint16 height)
+                               guint8 *src,
+                               int rowstride,
+                               guint16 x, guint16 y,
+                               guint16 width, guint16 height)
 {
-	VNC_FRAMEBUFFER_GET_INTERFACE(fb)->rgb24_blt(fb, src, rowstride, x, y, width, height);
+    VNC_FRAMEBUFFER_GET_INTERFACE(fb)->rgb24_blt(fb, src, rowstride, x, y, width, height);
 }
 
 
 void vnc_framebuffer_set_color_map(VncFramebuffer *fb,
-				   VncColorMap *map)
+                                   VncColorMap *map)
 {
-	VNC_FRAMEBUFFER_GET_INTERFACE(fb)->set_color_map(fb, map);
+    VNC_FRAMEBUFFER_GET_INTERFACE(fb)->set_color_map(fb, map);
 }
 
 
 GType
 vnc_framebuffer_get_type (void)
 {
-	static GType framebuffer_type = 0;
+    static GType framebuffer_type = 0;
 
-	if (!framebuffer_type) {
-		framebuffer_type =
-			g_type_register_static_simple (G_TYPE_INTERFACE, "VncFramebuffer",
-						       sizeof (VncFramebufferInterface),
-						       NULL, 0, NULL, 0);
+    if (!framebuffer_type) {
+        framebuffer_type =
+            g_type_register_static_simple (G_TYPE_INTERFACE, "VncFramebuffer",
+                                           sizeof (VncFramebufferInterface),
+                                           NULL, 0, NULL, 0);
 
-		g_type_interface_add_prerequisite (framebuffer_type, G_TYPE_OBJECT);
-	}
+        g_type_interface_add_prerequisite (framebuffer_type, G_TYPE_OBJECT);
+    }
 
-	return framebuffer_type;
+    return framebuffer_type;
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncframebuffer.h b/src/vncframebuffer.h
index 638441f..edec7f8 100644
--- a/src/vncframebuffer.h
+++ b/src/vncframebuffer.h
@@ -39,41 +39,41 @@ typedef struct _VncFramebuffer VncFramebuffer; /* Dummy object */
 typedef struct _VncFramebufferInterface VncFramebufferInterface;
 
 struct _VncFramebufferInterface {
-	GTypeInterface parent;
-
-	guint16 (*get_width)(VncFramebuffer *fb);
-	guint16 (*get_height)(VncFramebuffer *fb);
-	int (*get_rowstride)(VncFramebuffer *fb);
-	guint8 *(*get_buffer)(VncFramebuffer *fb);
-	const VncPixelFormat *(*get_local_format)(VncFramebuffer *fb);
-	const VncPixelFormat *(*get_remote_format)(VncFramebuffer *fb);
-	gboolean (*perfect_format_match)(VncFramebuffer *fb);
-
-	void (*set_pixel_at)(VncFramebuffer *fb,
-			     guint8 *src, /* One remote pixel */
-			     guint16 x, guint16 y);
-	void (*fill)(VncFramebuffer *fb,
-		     guint8 *src, /* One remote pixel */
-		     guint16 x, guint16 y,
-		     guint16 width, guint16 height);
-	void (*copyrect)(VncFramebuffer *fb,
-			 guint16 srcx, guint16 srcy,
-			 guint16 dstx, guint16 dsty,
-			 guint16 width, guint16 height);
-	void (*blt)(VncFramebuffer *fb,
-		    guint8 *src, /* Remote pixel array */
-		    int rowstride,
-		    guint16 x, guint16 y,
-		    guint16 width, guint16 height);
-	void (*rgb24_blt)(VncFramebuffer *fb,
-			  guint8 *src, /* rgb24 pixel array */
-			  int rowstride,
-			  guint16 x, guint16 y,
-			  guint16 width, guint16 height);
-	void (*set_color_map)(VncFramebuffer *fb,
-			      VncColorMap *map);
-
-	/* Do not add fields to this struct */
+    GTypeInterface parent;
+
+    guint16 (*get_width)(VncFramebuffer *fb);
+    guint16 (*get_height)(VncFramebuffer *fb);
+    int (*get_rowstride)(VncFramebuffer *fb);
+    guint8 *(*get_buffer)(VncFramebuffer *fb);
+    const VncPixelFormat *(*get_local_format)(VncFramebuffer *fb);
+    const VncPixelFormat *(*get_remote_format)(VncFramebuffer *fb);
+    gboolean (*perfect_format_match)(VncFramebuffer *fb);
+
+    void (*set_pixel_at)(VncFramebuffer *fb,
+                         guint8 *src, /* One remote pixel */
+                         guint16 x, guint16 y);
+    void (*fill)(VncFramebuffer *fb,
+                 guint8 *src, /* One remote pixel */
+                 guint16 x, guint16 y,
+                 guint16 width, guint16 height);
+    void (*copyrect)(VncFramebuffer *fb,
+                     guint16 srcx, guint16 srcy,
+                     guint16 dstx, guint16 dsty,
+                     guint16 width, guint16 height);
+    void (*blt)(VncFramebuffer *fb,
+                guint8 *src, /* Remote pixel array */
+                int rowstride,
+                guint16 x, guint16 y,
+                guint16 width, guint16 height);
+    void (*rgb24_blt)(VncFramebuffer *fb,
+                      guint8 *src, /* rgb24 pixel array */
+                      int rowstride,
+                      guint16 x, guint16 y,
+                      guint16 width, guint16 height);
+    void (*set_color_map)(VncFramebuffer *fb,
+                          VncColorMap *map);
+
+    /* Do not add fields to this struct */
 };
 
 GType vnc_framebuffer_get_type(void) G_GNUC_CONST;
@@ -90,33 +90,33 @@ const VncPixelFormat *vnc_framebuffer_get_remote_format(VncFramebuffer *fb);
 gboolean vnc_framebuffer_perfect_format_match(VncFramebuffer *fb);
 
 void vnc_framebuffer_set_pixel_at(VncFramebuffer *fb,
-				  guint8 *src, /* One remote pixel */
-				  guint16 x, guint16 y);
+                                  guint8 *src, /* One remote pixel */
+                                  guint16 x, guint16 y);
 
 void vnc_framebuffer_fill(VncFramebuffer *fb,
-			  guint8 *src, /* One remote pixel */
-			  guint16 x, guint16 y,
-			  guint16 width, guint16 height);
+                          guint8 *src, /* One remote pixel */
+                          guint16 x, guint16 y,
+                          guint16 width, guint16 height);
 
 void vnc_framebuffer_copyrect(VncFramebuffer *fb,
-			      guint16 srcx, guint16 srcy,
-			      guint16 dstx, guint16 dsty,
-			      guint16 width, guint16 height);
+                              guint16 srcx, guint16 srcy,
+                              guint16 dstx, guint16 dsty,
+                              guint16 width, guint16 height);
 
 void vnc_framebuffer_blt(VncFramebuffer *fb,
-			 guint8 *src, /* Remote pixel array */
-			 int rowstride,
-			 guint16 x, guint16 y,
-			 guint16 width, guint16 height);
+                         guint8 *src, /* Remote pixel array */
+                         int rowstride,
+                         guint16 x, guint16 y,
+                         guint16 width, guint16 height);
 
 void vnc_framebuffer_rgb24_blt(VncFramebuffer *fb,
-			       guint8 *src, /* rgb24 pixel array */
-			       int rowstride,
-			       guint16 x, guint16 y,
-			       guint16 width, guint16 height);
+                               guint8 *src, /* rgb24 pixel array */
+                               int rowstride,
+                               guint16 x, guint16 y,
+                               guint16 width, guint16 height);
 
 void vnc_framebuffer_set_color_map(VncFramebuffer *fb,
-				   VncColorMap *map);
+                                   VncColorMap *map);
 
 
 G_END_DECLS
@@ -125,8 +125,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncgrabsequence.c b/src/vncgrabsequence.c
index 015cf86..c2d7549 100644
--- a/src/vncgrabsequence.c
+++ b/src/vncgrabsequence.c
@@ -27,97 +27,97 @@
 
 GType vnc_grab_sequence_get_type(void)
 {
-	static GType grab_sequence_type = 0;
+    static GType grab_sequence_type = 0;
 
-	if (G_UNLIKELY(grab_sequence_type == 0)) {
-		grab_sequence_type = g_boxed_type_register_static
-			("VncGrabSequence",
-			 (GBoxedCopyFunc)vnc_grab_sequence_copy,
-			 (GBoxedFreeFunc)vnc_grab_sequence_free);
-	}
+    if (G_UNLIKELY(grab_sequence_type == 0)) {
+        grab_sequence_type = g_boxed_type_register_static
+            ("VncGrabSequence",
+             (GBoxedCopyFunc)vnc_grab_sequence_copy,
+             (GBoxedFreeFunc)vnc_grab_sequence_free);
+    }
 
-	return grab_sequence_type;
+    return grab_sequence_type;
 }
 
 
 VncGrabSequence *vnc_grab_sequence_new(guint nkeysyms, guint *keysyms)
 {
-	VncGrabSequence *sequence;
+    VncGrabSequence *sequence;
 
-	sequence = g_slice_new0(VncGrabSequence);
-	sequence->nkeysyms = nkeysyms;
-	sequence->keysyms = g_new0(guint, nkeysyms);
-	memcpy(sequence->keysyms, keysyms, sizeof(guint)*nkeysyms);
+    sequence = g_slice_new0(VncGrabSequence);
+    sequence->nkeysyms = nkeysyms;
+    sequence->keysyms = g_new0(guint, nkeysyms);
+    memcpy(sequence->keysyms, keysyms, sizeof(guint)*nkeysyms);
 
-	return sequence;
+    return sequence;
 }
 
 
 VncGrabSequence *vnc_grab_sequence_new_from_string(const gchar *str)
 {
-	gchar **keysymstr;
-	int i;
-	VncGrabSequence *sequence;
+    gchar **keysymstr;
+    int i;
+    VncGrabSequence *sequence;
 
-	sequence = g_slice_new0(VncGrabSequence);
+    sequence = g_slice_new0(VncGrabSequence);
 
-	keysymstr = g_strsplit(str, "+", 5);
+    keysymstr = g_strsplit(str, "+", 5);
 
-	sequence->nkeysyms = 0;
-	while (keysymstr[sequence->nkeysyms])
-		sequence->nkeysyms++;
+    sequence->nkeysyms = 0;
+    while (keysymstr[sequence->nkeysyms])
+        sequence->nkeysyms++;
 
-	sequence->keysyms = g_new0(guint, sequence->nkeysyms);
-	for (i = 0 ; i < sequence->nkeysyms ; i++)
-		sequence->keysyms[i] =
-			(guint)gdk_keyval_from_name(keysymstr[i]);
+    sequence->keysyms = g_new0(guint, sequence->nkeysyms);
+    for (i = 0 ; i < sequence->nkeysyms ; i++)
+        sequence->keysyms[i] =
+            (guint)gdk_keyval_from_name(keysymstr[i]);
 
-	g_strfreev(keysymstr);
+    g_strfreev(keysymstr);
 
-	return sequence;
+    return sequence;
 
 }
 
 
 VncGrabSequence *vnc_grab_sequence_copy(VncGrabSequence *srcSequence)
 {
-	VncGrabSequence *sequence;
+    VncGrabSequence *sequence;
 
-	sequence = g_slice_dup(VncGrabSequence, srcSequence);
-	sequence->keysyms = g_new0(guint, srcSequence->nkeysyms);
-	memcpy(sequence->keysyms, srcSequence->keysyms,
-	       sizeof(guint) * sequence->nkeysyms);
+    sequence = g_slice_dup(VncGrabSequence, srcSequence);
+    sequence->keysyms = g_new0(guint, srcSequence->nkeysyms);
+    memcpy(sequence->keysyms, srcSequence->keysyms,
+           sizeof(guint) * sequence->nkeysyms);
 
-	return sequence;
+    return sequence;
 }
 
 
 void vnc_grab_sequence_free(VncGrabSequence *sequence)
 {
-	g_slice_free(VncGrabSequence, sequence);
+    g_slice_free(VncGrabSequence, sequence);
 }
 
 
 gchar *vnc_grab_sequence_as_string(VncGrabSequence *sequence)
 {
-	GString *str = g_string_new("");
-	int i;
+    GString *str = g_string_new("");
+    int i;
 
-	for (i = 0 ; i < sequence->nkeysyms ; i++) {
-		if (i > 0)
-			g_string_append_c(str, '+');
-		g_string_append(str, gdk_keyval_name(sequence->keysyms[i]));
-	}
+    for (i = 0 ; i < sequence->nkeysyms ; i++) {
+        if (i > 0)
+            g_string_append_c(str, '+');
+        g_string_append(str, gdk_keyval_name(sequence->keysyms[i]));
+    }
 
-	return g_string_free(str, FALSE);
+    return g_string_free(str, FALSE);
 
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncgrabsequence.h b/src/vncgrabsequence.h
index c0b9bd1..0bfc8cc 100644
--- a/src/vncgrabsequence.h
+++ b/src/vncgrabsequence.h
@@ -32,10 +32,10 @@ G_BEGIN_DECLS
 typedef struct _VncGrabSequence VncGrabSequence;
 
 struct _VncGrabSequence {
-	guint nkeysyms;
-	guint *keysyms;
+    guint nkeysyms;
+    guint *keysyms;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 GType vnc_grab_sequence_get_type(void);
@@ -53,8 +53,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncimageframebuffer.c b/src/vncimageframebuffer.c
index 9f06843..a012409 100644
--- a/src/vncimageframebuffer.c
+++ b/src/vncimageframebuffer.c
@@ -27,11 +27,11 @@
 #include "vncimageframebuffer.h"
 #include "vncutil.h"
 
-#define VNC_IMAGE_FRAMEBUFFER_GET_PRIVATE(obj)				\
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_IMAGE_FRAMEBUFFER, VncImageFramebufferPrivate))
+#define VNC_IMAGE_FRAMEBUFFER_GET_PRIVATE(obj)                          \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_IMAGE_FRAMEBUFFER, VncImageFramebufferPrivate))
 
 struct _VncImageFramebufferPrivate {
-	GdkImage *image;
+    GdkImage *image;
 };
 
 
@@ -39,178 +39,178 @@ G_DEFINE_TYPE(VncImageFramebuffer, vnc_image_framebuffer, VNC_TYPE_BASE_FRAMEBUF
 
 
 enum {
-	PROP_0,
-	PROP_IMAGE,
+    PROP_0,
+    PROP_IMAGE,
 };
 
 
 static void vnc_image_framebuffer_get_property(GObject *object,
-					       guint prop_id,
-					       GValue *value,
-					       GParamSpec *pspec)
+                                               guint prop_id,
+                                               GValue *value,
+                                               GParamSpec *pspec)
 {
-	VncImageFramebuffer *framebuffer = VNC_IMAGE_FRAMEBUFFER(object);
-	VncImageFramebufferPrivate *priv = framebuffer->priv;
+    VncImageFramebuffer *framebuffer = VNC_IMAGE_FRAMEBUFFER(object);
+    VncImageFramebufferPrivate *priv = framebuffer->priv;
 
-	switch (prop_id) {
-	case PROP_IMAGE:
-		g_value_set_object(value, priv->image);
-		break;
+    switch (prop_id) {
+    case PROP_IMAGE:
+        g_value_set_object(value, priv->image);
+        break;
 
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-	}
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 static void vnc_image_framebuffer_set_property(GObject *object,
-					       guint prop_id,
-					       const GValue *value,
-					       GParamSpec *pspec)
+                                               guint prop_id,
+                                               const GValue *value,
+                                               GParamSpec *pspec)
 {
-	VncImageFramebuffer *framebuffer = VNC_IMAGE_FRAMEBUFFER(object);
-	VncImageFramebufferPrivate *priv = framebuffer->priv;
-
-	switch (prop_id) {
-	case PROP_IMAGE:
-		if (priv->image)
-			g_object_unref(G_OBJECT(priv->image));
-		priv->image = g_value_get_object(value);
-		g_object_ref(G_OBJECT(priv->image));
-		break;
-
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-        }
+    VncImageFramebuffer *framebuffer = VNC_IMAGE_FRAMEBUFFER(object);
+    VncImageFramebufferPrivate *priv = framebuffer->priv;
+
+    switch (prop_id) {
+    case PROP_IMAGE:
+        if (priv->image)
+            g_object_unref(G_OBJECT(priv->image));
+        priv->image = g_value_get_object(value);
+        g_object_ref(G_OBJECT(priv->image));
+        break;
+
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
 }
 
 static void vnc_image_framebuffer_finalize (GObject *object)
 {
-	VncImageFramebuffer *fb = VNC_IMAGE_FRAMEBUFFER(object);
-	VncImageFramebufferPrivate *priv = fb->priv;
+    VncImageFramebuffer *fb = VNC_IMAGE_FRAMEBUFFER(object);
+    VncImageFramebufferPrivate *priv = fb->priv;
 
-	if (priv->image)
-		g_object_unref(priv->image);
+    if (priv->image)
+        g_object_unref(priv->image);
 
-	G_OBJECT_CLASS(vnc_image_framebuffer_parent_class)->finalize (object);
+    G_OBJECT_CLASS(vnc_image_framebuffer_parent_class)->finalize (object);
 }
 
 static void vnc_image_framebuffer_class_init(VncImageFramebufferClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = vnc_image_framebuffer_finalize;
-	object_class->get_property = vnc_image_framebuffer_get_property;
-	object_class->set_property = vnc_image_framebuffer_set_property;
-
-	g_object_class_install_property(object_class,
-					PROP_IMAGE,
-					g_param_spec_object("image",
-							    "The client image",
-							    "The client image for the framebuffer",
-							    GDK_TYPE_IMAGE,
-							    G_PARAM_READABLE |
-							    G_PARAM_WRITABLE |
-							    G_PARAM_CONSTRUCT_ONLY |
-							    G_PARAM_STATIC_NAME |
-							    G_PARAM_STATIC_NICK |
-							    G_PARAM_STATIC_BLURB));
-
-	g_type_class_add_private(klass, sizeof(VncImageFramebufferPrivate));
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = vnc_image_framebuffer_finalize;
+    object_class->get_property = vnc_image_framebuffer_get_property;
+    object_class->set_property = vnc_image_framebuffer_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_IMAGE,
+                                    g_param_spec_object("image",
+                                                        "The client image",
+                                                        "The client image for the framebuffer",
+                                                        GDK_TYPE_IMAGE,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_WRITABLE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+    g_type_class_add_private(klass, sizeof(VncImageFramebufferPrivate));
 }
 
 
 void vnc_image_framebuffer_init(VncImageFramebuffer *fb)
 {
-	VncImageFramebufferPrivate *priv;
+    VncImageFramebufferPrivate *priv;
 
-	priv = fb->priv = VNC_IMAGE_FRAMEBUFFER_GET_PRIVATE(fb);
+    priv = fb->priv = VNC_IMAGE_FRAMEBUFFER_GET_PRIVATE(fb);
 
-	memset(priv, 0, sizeof(*priv));
+    memset(priv, 0, sizeof(*priv));
 }
 
 
 VncImageFramebuffer *vnc_image_framebuffer_new(GdkImage *image,
-					       const VncPixelFormat *remoteFormat)
+                                               const VncPixelFormat *remoteFormat)
 {
-        VncPixelFormat localFormat;
-        guint32 red_mask, green_mask, blue_mask;
-        gint red_shift, green_shift, blue_shift, w, h;
-        guint16 bpp, bpl, depth;
-        gpointer pixels;
-        GdkByteOrder byte_order;
-
-	#if GTK_CHECK_VERSION (2, 21, 1)
-	GdkVisual *visual = gdk_image_get_visual (image);
-	gdk_visual_get_red_pixel_details (visual, &red_mask, &red_shift, NULL);
-	gdk_visual_get_green_pixel_details (visual, &green_mask, &green_shift, NULL);
-	gdk_visual_get_blue_pixel_details (visual, &blue_mask, &blue_shift, NULL);
-	bpp = gdk_image_get_bytes_per_pixel (image);
-	depth = gdk_image_get_depth (image);
-	byte_order = gdk_image_get_byte_order (image);
-	bpl = gdk_image_get_bytes_per_line (image);
-	w = gdk_image_get_width (image);
-	h = gdk_image_get_height (image);
-	pixels = gdk_image_get_pixels (image);
-	#else
-	red_mask = image->visual->red_mask;
-	red_shift = image->visual->red_shift;
-	green_mask = image->visual->green_mask;
-	green_shift = image->visual->green_shift;
-	blue_mask = image->visual->blue_mask;
-	blue_shift = image->visual->blue_shift;
-	bpp = image->bpp;
-	depth = image->depth;
-	byte_order = image->byte_order;
-	bpl = image->bpl;
-	w = image->width;
-	h = image->height;
-	pixels = image->mem;
-	#endif
-
-	VNC_DEBUG("Visual mask: %3d %3d %3d\n      shift: %3d %3d %3d",
-		   red_mask,
-		   green_mask,
-		   blue_mask,
-		   red_shift,
-		   green_shift,
-		   blue_shift);
-
-	localFormat.red_max = red_mask >> red_shift;
-	localFormat.green_max = green_mask >> green_shift;
-	localFormat.blue_max = blue_mask >> blue_shift;
-	localFormat.red_shift = red_shift;
-	localFormat.green_shift = green_shift;
-	localFormat.blue_shift = blue_shift;
-	localFormat.depth = depth;
-	localFormat.bits_per_pixel = bpp * 8;
-	localFormat.byte_order = byte_order == GDK_LSB_FIRST ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
-
-	memset(pixels, 0, bpl * h);
-
-	return VNC_IMAGE_FRAMEBUFFER(g_object_new(VNC_TYPE_IMAGE_FRAMEBUFFER,
-						  "image", image,
-						  "buffer", (guint8 *)pixels,
-						  "width", w,
-						  "height", h,
-						  "rowstride", bpl,
-						  "local-format", &localFormat,
-						  "remote-format", remoteFormat,
-						  NULL));
+    VncPixelFormat localFormat;
+    guint32 red_mask, green_mask, blue_mask;
+    gint red_shift, green_shift, blue_shift, w, h;
+    guint16 bpp, bpl, depth;
+    gpointer pixels;
+    GdkByteOrder byte_order;
+
+#if GTK_CHECK_VERSION (2, 21, 1)
+    GdkVisual *visual = gdk_image_get_visual (image);
+    gdk_visual_get_red_pixel_details (visual, &red_mask, &red_shift, NULL);
+    gdk_visual_get_green_pixel_details (visual, &green_mask, &green_shift, NULL);
+    gdk_visual_get_blue_pixel_details (visual, &blue_mask, &blue_shift, NULL);
+    bpp = gdk_image_get_bytes_per_pixel (image);
+    depth = gdk_image_get_depth (image);
+    byte_order = gdk_image_get_byte_order (image);
+    bpl = gdk_image_get_bytes_per_line (image);
+    w = gdk_image_get_width (image);
+    h = gdk_image_get_height (image);
+    pixels = gdk_image_get_pixels (image);
+#else
+    red_mask = image->visual->red_mask;
+    red_shift = image->visual->red_shift;
+    green_mask = image->visual->green_mask;
+    green_shift = image->visual->green_shift;
+    blue_mask = image->visual->blue_mask;
+    blue_shift = image->visual->blue_shift;
+    bpp = image->bpp;
+    depth = image->depth;
+    byte_order = image->byte_order;
+    bpl = image->bpl;
+    w = image->width;
+    h = image->height;
+    pixels = image->mem;
+#endif
+
+    VNC_DEBUG("Visual mask: %3d %3d %3d\n      shift: %3d %3d %3d",
+              red_mask,
+              green_mask,
+              blue_mask,
+              red_shift,
+              green_shift,
+              blue_shift);
+
+    localFormat.red_max = red_mask >> red_shift;
+    localFormat.green_max = green_mask >> green_shift;
+    localFormat.blue_max = blue_mask >> blue_shift;
+    localFormat.red_shift = red_shift;
+    localFormat.green_shift = green_shift;
+    localFormat.blue_shift = blue_shift;
+    localFormat.depth = depth;
+    localFormat.bits_per_pixel = bpp * 8;
+    localFormat.byte_order = byte_order == GDK_LSB_FIRST ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
+
+    memset(pixels, 0, bpl * h);
+
+    return VNC_IMAGE_FRAMEBUFFER(g_object_new(VNC_TYPE_IMAGE_FRAMEBUFFER,
+                                              "image", image,
+                                              "buffer", (guint8 *)pixels,
+                                              "width", w,
+                                              "height", h,
+                                              "rowstride", bpl,
+                                              "local-format", &localFormat,
+                                              "remote-format", remoteFormat,
+                                              NULL));
 }
 
 
 GdkImage *vnc_image_framebuffer_get_image(VncImageFramebuffer *fb)
 {
-	VncImageFramebufferPrivate *priv = fb->priv;
+    VncImageFramebufferPrivate *priv = fb->priv;
 
-	return priv->image;
+    return priv->image;
 }
 
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncimageframebuffer.h b/src/vncimageframebuffer.h
index faef161..a1152d4 100644
--- a/src/vncimageframebuffer.h
+++ b/src/vncimageframebuffer.h
@@ -43,29 +43,29 @@ typedef struct _VncImageFramebufferClass VncImageFramebufferClass;
 
 struct _VncImageFramebuffer
 {
-	VncBaseFramebuffer parent;
+    VncBaseFramebuffer parent;
 
-	VncImageFramebufferPrivate *priv;
+    VncImageFramebufferPrivate *priv;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 struct _VncImageFramebufferClass
 {
-	VncBaseFramebufferClass parent_class;
+    VncBaseFramebufferClass parent_class;
 
-	/*
-	 * If adding fields to this struct, remove corresponding
-	 * amount of padding to avoid changing overall struct size
-	 */
-	gpointer _vnc_reserved[VNC_PADDING];
+    /*
+     * If adding fields to this struct, remove corresponding
+     * amount of padding to avoid changing overall struct size
+     */
+    gpointer _vnc_reserved[VNC_PADDING];
 };
 
 
 GType vnc_image_framebuffer_get_type(void) G_GNUC_CONST;
 
 VncImageFramebuffer *vnc_image_framebuffer_new(GdkImage *image,
-					       const VncPixelFormat *remoteFormat);
+                                               const VncPixelFormat *remoteFormat);
 
 GdkImage *vnc_image_framebuffer_get_image(VncImageFramebuffer *fb);
 
@@ -76,8 +76,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncmodule.c b/src/vncmodule.c
index f7f778a..3655b02 100644
--- a/src/vncmodule.c
+++ b/src/vncmodule.c
@@ -34,11 +34,11 @@ DL_EXPORT(void) initgtkvnc(void)
 
     m = Py_InitModule ("gtkvnc", gtkvnc_functions);
     if (PyErr_Occurred())
-	Py_FatalError("can't init module");
+        Py_FatalError("can't init module");
 
     d = PyModule_GetDict (m);
     if (PyErr_Occurred())
-	Py_FatalError("can't get dict");
+        Py_FatalError("can't get dict");
 
     gtkvnc_add_constants(m, "VNC_DISPLAY_");
     gtkvnc_register_classes (d);
@@ -47,3 +47,10 @@ DL_EXPORT(void) initgtkvnc(void)
         Py_FatalError ("can't initialise module vnc");
     }
 }
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
diff --git a/src/vncpixelformat.c b/src/vncpixelformat.c
index f8b307e..06c825c 100644
--- a/src/vncpixelformat.c
+++ b/src/vncpixelformat.c
@@ -24,48 +24,48 @@
 
 GType vnc_pixel_format_get_type(void)
 {
-	static GType pixel_format_type = 0;
+    static GType pixel_format_type = 0;
 
-	if (G_UNLIKELY(pixel_format_type == 0)) {
-		pixel_format_type = g_boxed_type_register_static
-			("VncPixelFormat",
-			 (GBoxedCopyFunc)vnc_pixel_format_copy,
-			 (GBoxedFreeFunc)vnc_pixel_format_free);
-	}
+    if (G_UNLIKELY(pixel_format_type == 0)) {
+        pixel_format_type = g_boxed_type_register_static
+            ("VncPixelFormat",
+             (GBoxedCopyFunc)vnc_pixel_format_copy,
+             (GBoxedFreeFunc)vnc_pixel_format_free);
+    }
 
-	return pixel_format_type;
+    return pixel_format_type;
 }
 
 
 VncPixelFormat *vnc_pixel_format_new(void)
 {
-	VncPixelFormat *format;
+    VncPixelFormat *format;
 
-	format = g_slice_new0(VncPixelFormat);
+    format = g_slice_new0(VncPixelFormat);
 
-	return format;
+    return format;
 }
 
 
 VncPixelFormat *vnc_pixel_format_copy(VncPixelFormat *srcFormat)
 {
-	VncPixelFormat *format;
+    VncPixelFormat *format;
 
-	format = g_slice_dup(VncPixelFormat, srcFormat);
+    format = g_slice_dup(VncPixelFormat, srcFormat);
 
-	return format;
+    return format;
 }
 
 
 void vnc_pixel_format_free(VncPixelFormat *format)
 {
-	g_slice_free(VncPixelFormat, format);
+    g_slice_free(VncPixelFormat, format);
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncpixelformat.h b/src/vncpixelformat.h
index 2382e5d..62e308a 100644
--- a/src/vncpixelformat.h
+++ b/src/vncpixelformat.h
@@ -32,18 +32,18 @@ G_BEGIN_DECLS
 typedef struct _VncPixelFormat VncPixelFormat;
 
 struct _VncPixelFormat {
-	guint8 bits_per_pixel;
-	guint8 depth;
-	guint16 byte_order;
-	guint8 true_color_flag;
-	guint16 red_max;
-	guint16 green_max;
-	guint16 blue_max;
-	guint8 red_shift;
-	guint8 green_shift;
-	guint8 blue_shift;
+    guint8 bits_per_pixel;
+    guint8 depth;
+    guint16 byte_order;
+    guint8 true_color_flag;
+    guint16 red_max;
+    guint16 green_max;
+    guint16 blue_max;
+    guint8 red_shift;
+    guint8 green_shift;
+    guint8 blue_shift;
 
-	/* Do not add fields to this struct */
+    /* Do not add fields to this struct */
 };
 
 GType vnc_pixel_format_get_type(void);
@@ -58,8 +58,8 @@ G_END_DECLS
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncutil.c b/src/vncutil.c
index bff8f7f..52f9979 100644
--- a/src/vncutil.c
+++ b/src/vncutil.c
@@ -27,38 +27,38 @@ static gboolean debugFlag = FALSE;
 
 void vnc_util_set_debug(gboolean enabled)
 {
-	debugFlag = enabled;
+    debugFlag = enabled;
 }
 
 gboolean vnc_util_get_debug(void)
 {
-	return debugFlag;
+    return debugFlag;
 }
 
 gint vnc_util_get_version(void)
 {
-	return (VERSION_MAJOR << 16) |
-		(VERSION_MINOR << 8) |
-		VERSION_MICRO;
+    return (VERSION_MAJOR << 16) |
+        (VERSION_MINOR << 8) |
+        VERSION_MICRO;
 }
 
 gboolean vnc_util_check_version(gint major, gint minor, gint micro)
 {
-	return ((VERSION_MAJOR > major) || \
-		((VERSION_MAJOR == major) && (VERSION_MINOR > minor)) || \
-		((VERSION_MAJOR == major) && (VERSION_MINOR == minor) && \
-		(VERSION_MICRO >= micro)));
+    return ((VERSION_MAJOR > major) || \
+            ((VERSION_MAJOR == major) && (VERSION_MINOR > minor)) || \
+            ((VERSION_MAJOR == major) && (VERSION_MINOR == minor) && \
+             (VERSION_MICRO >= micro)));
 }
 
 const gchar *vnc_util_get_version_string(void)
 {
-	return VERSION;
+    return VERSION;
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/src/vncutil.h b/src/vncutil.h
index db10d99..d67f9aa 100644
--- a/src/vncutil.h
+++ b/src/vncutil.h
@@ -31,11 +31,11 @@ gint vnc_util_get_version(void);
 const gchar *vnc_util_get_version_string(void);
 gboolean vnc_util_check_version(gint major, gint minor, gint micro);
 
-#define VNC_DEBUG(fmt, ...)						\
-	do {								\
-		if (G_UNLIKELY(vnc_util_get_debug()))			\
-			g_debug(__FILE__ " " fmt, ## __VA_ARGS__);	\
-	} while (0)
+#define VNC_DEBUG(fmt, ...)                             \
+    do {                                                \
+        if (G_UNLIKELY(vnc_util_get_debug()))           \
+            g_debug(__FILE__ " " fmt, ## __VA_ARGS__);  \
+    } while (0)
 
 /* For normal VncXXXClass structs */
 #define VNC_PADDING 4
@@ -48,8 +48,8 @@ G_END_DECLS
 #endif /* VNC_UTIL_H */
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */
diff --git a/tools/gvnccapture.c b/tools/gvnccapture.c
index baa6613..90febe3 100644
--- a/tools/gvnccapture.c
+++ b/tools/gvnccapture.c
@@ -19,69 +19,69 @@
  */
 
 /*
-=head1 NAME
+  =head1 NAME
 
-gvnccapture - VNC screenshot capture
+  gvnccapture - VNC screenshot capture
 
-=head1 SYNOPSIS
+  =head1 SYNOPSIS
 
-gvnccapture [OPTION]... [HOST][:DISPLAY] FILENAME
+  gvnccapture [OPTION]... [HOST][:DISPLAY] FILENAME
 
-=head1 DESCRIPTION
+  =head1 DESCRIPTION
 
-Capture a screenshot of the VNC desktop at HOST:DISPLAY saving to the
-image file FILENAME. If HOST is omitted it defaults to "localhost",
-if :DISPLAY is omitted, it defaults to ":1". FILENAME must end in a
-known image format extension (eg ".png", ".jpeg"). Supported options
-are
+  Capture a screenshot of the VNC desktop at HOST:DISPLAY saving to the
+  image file FILENAME. If HOST is omitted it defaults to "localhost",
+  if :DISPLAY is omitted, it defaults to ":1". FILENAME must end in a
+  known image format extension (eg ".png", ".jpeg"). Supported options
+  are
 
-=over 4
+  =over 4
 
-=item --help, -?
+  =item --help, -?
 
-Display command line help information
+  Display command line help information
 
-=item --quiet, -q
+  =item --quiet, -q
 
-Do not display information on the console when capturing the screenshot,
-with the exception of any password prompt.
+  Do not display information on the console when capturing the screenshot,
+  with the exception of any password prompt.
 
-=item --debug, -d
+  =item --debug, -d
 
-Display verbose debugging information on the console
+  Display verbose debugging information on the console
 
-=back
+  =back
 
-=head1 EXIT STATUS
+  =head1 EXIT STATUS
 
-The exit status is 0 upon successful screen capture, otherwise
-it is a non-zero integer
+  The exit status is 0 upon successful screen capture, otherwise
+  it is a non-zero integer
 
-=head1 EXAMPLES
+  =head1 EXAMPLES
 
- # gvnccapture localhost:1 desktop.png
- Password: 
- Connected to localhost:1
- Saved display to desktop.png
+  # gvnccapture localhost:1 desktop.png
+  Password: 
+  Connected to localhost:1
+  Saved display to desktop.png
 
-=head1 AUTHORS
+  =head1 AUTHORS
 
-Daniel P. Berrange <dan berrange com>
+  Daniel P. Berrange <dan berrange com>
 
-=head1 COPYRIGHT
+  =head1 COPYRIGHT
 
-Copyright (C) 2010 Daniel P. Berrange <dan berrange com>.
+  Copyright (C) 2010 Daniel P. Berrange <dan berrange com>.
 
-License LGPLv2+: GNU Lesser GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
+  License LGPLv2+: GNU Lesser GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
 
-This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
+  This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
 
-=head1 SEE ALSO
+  =head1 SEE ALSO
 
-vinagre(1)
+  vinagre(1)
 
-=cut
- */
+  =cut
+*/
 
 #include "config.h"
 
@@ -98,40 +98,40 @@ vinagre(1)
 #include <vncbaseframebuffer.h>
 
 struct GVncCapture {
-	gchar *host;
-	int port;
+    gchar *host;
+    int port;
 
-	gboolean quiet;
-	gboolean saved;
+    gboolean quiet;
+    gboolean saved;
 
-	VncConnection *conn;
-        GMainLoop *loop;
-	gboolean connected;
-	gchar *output;
+    VncConnection *conn;
+    GMainLoop *loop;
+    gboolean connected;
+    gchar *output;
 
-	GdkPixbuf *pixbuf;
+    GdkPixbuf *pixbuf;
 };
 
 static const guint preferable_auths[] = {
-	/*
-	 * Both these two provide TLS based auth, and can layer
-	 * all the other auth types on top. So these two must
-	 * be the first listed
-	 */
-	VNC_CONNECTION_AUTH_VENCRYPT,
-	VNC_CONNECTION_AUTH_TLS,
-
-	/*
-	 * Then stackable auth types in order of preference
-	 */
-	VNC_CONNECTION_AUTH_SASL,
-	VNC_CONNECTION_AUTH_MSLOGON,
-	VNC_CONNECTION_AUTH_VNC,
-
-	/*
-	 * Or nothing at all
-	 */
-	VNC_CONNECTION_AUTH_NONE
+    /*
+     * Both these two provide TLS based auth, and can layer
+     * all the other auth types on top. So these two must
+     * be the first listed
+     */
+    VNC_CONNECTION_AUTH_VENCRYPT,
+    VNC_CONNECTION_AUTH_TLS,
+
+    /*
+     * Then stackable auth types in order of preference
+     */
+    VNC_CONNECTION_AUTH_SASL,
+    VNC_CONNECTION_AUTH_MSLOGON,
+    VNC_CONNECTION_AUTH_VNC,
+
+    /*
+     * Or nothing at all
+     */
+    VNC_CONNECTION_AUTH_NONE
 };
 
 
@@ -139,409 +139,409 @@ static const guint preferable_auths[] = {
 static gchar *
 do_vnc_get_credential(const gchar *prompt, gboolean doecho)
 {
-	struct termios old, new;
-	gchar buf[100];
-	gchar *res;
-	int n = sizeof(buf);
-	ssize_t len;
-
-	printf("%s", prompt);
-	fflush(stdout);
-
-	/* Turn echoing off and fail if we can't. */
-	if (!doecho && tcgetattr (fileno (stdin), &old) != 0)
-		return NULL;
-	new = old;
-	new.c_lflag &= ~ECHO;
-	if (!doecho && tcsetattr(fileno(stdin), TCSAFLUSH, &new) != 0)
-		return NULL;
-
-	/* Read the password. */
-	if ((res = fgets(buf, n, stdin)) != NULL) {
-		len = strlen(res);
-		if (res[len-1] == '\n')
-			res[len-1] = '\0';
-	}
-
-	/* Restore terminal. */
-	if (!doecho) {
-		printf("\n");
-		(void) tcsetattr(fileno (stdin), TCSAFLUSH, &old);
-	}
-
-	return res ? g_strdup(res) : NULL;
+    struct termios old, new;
+    gchar buf[100];
+    gchar *res;
+    int n = sizeof(buf);
+    ssize_t len;
+
+    printf("%s", prompt);
+    fflush(stdout);
+
+    /* Turn echoing off and fail if we can't. */
+    if (!doecho && tcgetattr (fileno (stdin), &old) != 0)
+        return NULL;
+    new = old;
+    new.c_lflag &= ~ECHO;
+    if (!doecho && tcsetattr(fileno(stdin), TCSAFLUSH, &new) != 0)
+        return NULL;
+
+    /* Read the password. */
+    if ((res = fgets(buf, n, stdin)) != NULL) {
+        len = strlen(res);
+        if (res[len-1] == '\n')
+            res[len-1] = '\0';
+    }
+
+    /* Restore terminal. */
+    if (!doecho) {
+        printf("\n");
+        (void) tcsetattr(fileno (stdin), TCSAFLUSH, &old);
+    }
+
+    return res ? g_strdup(res) : NULL;
 }
 #else
 static gchar *
 do_vnc_get_credential(const gchar *prompt, gboolean doecho G_GNUC_UNUSED)
 {
-	gchar buf[100];
-	gchar *res;
-	int n = sizeof(buf);
-	ssize_t len;
-
-	printf("%s", prompt);
-	fflush(stdout);
-
-	/* Read the password. */
-	if ((res = fgets(buf, n, stdin)) != NULL) {
-		len = strlen(res);
-		if (res[len-1] == '\n')
-			res[len-1] = '\0';
-	}
-
-	return res ? g_strdup(res) : NULL;
+    gchar buf[100];
+    gchar *res;
+    int n = sizeof(buf);
+    ssize_t len;
+
+    printf("%s", prompt);
+    fflush(stdout);
+
+    /* Read the password. */
+    if ((res = fgets(buf, n, stdin)) != NULL) {
+        len = strlen(res);
+        if (res[len-1] == '\n')
+            res[len-1] = '\0';
+    }
+
+    return res ? g_strdup(res) : NULL;
 }
 #endif
 
 static void do_vnc_framebuffer_update(VncConnection *conn,
-				      guint16 x, guint16 y,
-				      guint16 width, guint16 height,
-				      gpointer opaque)
+                                      guint16 x, guint16 y,
+                                      guint16 width, guint16 height,
+                                      gpointer opaque)
 {
-	struct GVncCapture *capture = opaque;
-
-	if (!capture->pixbuf)
-		return;
-
-	/* Crude attempt to see if we've got a complete frame by
-	 * checking if we've hit the bottom-right corner. Will
-	 * probably break
-	 */
-	if ((x + width) == vnc_connection_get_width(conn) &&
-	    (y + height) == vnc_connection_get_height(conn)) {
-		VNC_DEBUG("All done, saving to %s", capture->output);
-		gchar *ext = strrchr(capture->output, '.');
-		GError *err = NULL;
-		if (ext)
-			ext++;
-
-		if (!gdk_pixbuf_save(capture->pixbuf,
-				     capture->output,
-				     ext ? ext : "png",
-				     &err,
-				     "tEXt::Generator App", "gvnccapture", NULL)) {
-			if (!capture->quiet)
-				g_print("Unable to save display to %s: %s",
-					capture->output, err->message);
-		} else {
-			capture->saved = TRUE;
-			if (!capture->quiet)
-				g_print("Saved display to %s\n",
-					capture->output);
-		}
-		vnc_connection_shutdown(conn);
-		g_main_quit(capture->loop);
-	}
+    struct GVncCapture *capture = opaque;
+
+    if (!capture->pixbuf)
+        return;
+
+    /* Crude attempt to see if we've got a complete frame by
+     * checking if we've hit the bottom-right corner. Will
+     * probably break
+     */
+    if ((x + width) == vnc_connection_get_width(conn) &&
+        (y + height) == vnc_connection_get_height(conn)) {
+        VNC_DEBUG("All done, saving to %s", capture->output);
+        gchar *ext = strrchr(capture->output, '.');
+        GError *err = NULL;
+        if (ext)
+            ext++;
+
+        if (!gdk_pixbuf_save(capture->pixbuf,
+                             capture->output,
+                             ext ? ext : "png",
+                             &err,
+                             "tEXt::Generator App", "gvnccapture", NULL)) {
+            if (!capture->quiet)
+                g_print("Unable to save display to %s: %s",
+                        capture->output, err->message);
+        } else {
+            capture->saved = TRUE;
+            if (!capture->quiet)
+                g_print("Saved display to %s\n",
+                        capture->output);
+        }
+        vnc_connection_shutdown(conn);
+        g_main_quit(capture->loop);
+    }
 }
 
 static void do_vnc_desktop_resize(VncConnection *conn,
-				  int width, int height,
-				  gpointer opaque)
+                                  int width, int height,
+                                  gpointer opaque)
 {
-	struct GVncCapture *capture = opaque;
-	const VncPixelFormat *remoteFormat;
-	VncPixelFormat localFormat = {
-		.bits_per_pixel = 32,
-		.depth = 32,
-		.byte_order = G_BYTE_ORDER,
-		.true_color_flag = TRUE,
-		.red_max = 255,
-		.green_max = 255,
-		.blue_max = 255,
-		.red_shift = 0,
-		.green_shift = 8,
-		.blue_shift = 16,
-	};
-	VncBaseFramebuffer *fb;
-
-	if (capture->pixbuf) {
-		gdk_pixbuf_unref(capture->pixbuf);
-		capture->pixbuf = NULL;
-	}
-
-	VNC_DEBUG("Resize %dx%d", width, height);
-	remoteFormat = vnc_connection_get_pixel_format(conn);
-
-	/* We'll fix our local copy as rgb888 */
-	capture->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
-					 TRUE, 
-					 8,
-					 width,
-					 height);
-	gdk_pixbuf_fill(capture->pixbuf, 0);
-
-	fb = vnc_base_framebuffer_new(gdk_pixbuf_get_pixels(capture->pixbuf),
-				      gdk_pixbuf_get_width(capture->pixbuf),
-				      gdk_pixbuf_get_height(capture->pixbuf),
-				      gdk_pixbuf_get_rowstride(capture->pixbuf),
-				      remoteFormat,
-				      &localFormat);
-
-	vnc_connection_set_framebuffer(conn, VNC_FRAMEBUFFER(fb));
-
-	g_object_unref(fb);
+    struct GVncCapture *capture = opaque;
+    const VncPixelFormat *remoteFormat;
+    VncPixelFormat localFormat = {
+        .bits_per_pixel = 32,
+        .depth = 32,
+        .byte_order = G_BYTE_ORDER,
+        .true_color_flag = TRUE,
+        .red_max = 255,
+        .green_max = 255,
+        .blue_max = 255,
+        .red_shift = 0,
+        .green_shift = 8,
+        .blue_shift = 16,
+    };
+    VncBaseFramebuffer *fb;
+
+    if (capture->pixbuf) {
+        gdk_pixbuf_unref(capture->pixbuf);
+        capture->pixbuf = NULL;
+    }
+
+    VNC_DEBUG("Resize %dx%d", width, height);
+    remoteFormat = vnc_connection_get_pixel_format(conn);
+
+    /* We'll fix our local copy as rgb888 */
+    capture->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+                                     TRUE, 
+                                     8,
+                                     width,
+                                     height);
+    gdk_pixbuf_fill(capture->pixbuf, 0);
+
+    fb = vnc_base_framebuffer_new(gdk_pixbuf_get_pixels(capture->pixbuf),
+                                  gdk_pixbuf_get_width(capture->pixbuf),
+                                  gdk_pixbuf_get_height(capture->pixbuf),
+                                  gdk_pixbuf_get_rowstride(capture->pixbuf),
+                                  remoteFormat,
+                                  &localFormat);
+
+    vnc_connection_set_framebuffer(conn, VNC_FRAMEBUFFER(fb));
+
+    g_object_unref(fb);
 }
 
 
 static void do_vnc_initialized(VncConnection *conn,
-			       gpointer opaque)
+                               gpointer opaque)
 {
-	struct GVncCapture *capture = opaque;
-	gint32 encodings[] = {  VNC_CONNECTION_ENCODING_DESKTOP_RESIZE,
-                                VNC_CONNECTION_ENCODING_ZRLE,
-				VNC_CONNECTION_ENCODING_HEXTILE,
-				VNC_CONNECTION_ENCODING_RRE,
-				VNC_CONNECTION_ENCODING_COPY_RECT,
-				VNC_CONNECTION_ENCODING_RAW };
-	gint32 *encodingsp;
-	int n_encodings;
-
-	do_vnc_desktop_resize(conn,
-			      vnc_connection_get_width(conn),
-			      vnc_connection_get_height(conn),
-			      capture);
-
-	encodingsp = encodings;
-	n_encodings = G_N_ELEMENTS(encodings);
-
-	VNC_DEBUG("Sending %d encodings", n_encodings);
-	if (!vnc_connection_set_encodings(conn, n_encodings, encodingsp))
-		goto error;
-
-	VNC_DEBUG("Requesting first framebuffer update");
-	if (!vnc_connection_framebuffer_update_request(capture->conn,
-						       0, 0, 0,
-						       vnc_connection_get_width(capture->conn),
-						       vnc_connection_get_height(capture->conn)))
-		vnc_connection_shutdown(capture->conn);
-
-	if (!capture->quiet)
-		g_print("Connected to %s:%d\n", capture->host, capture->port - 5900);
-	capture->connected = TRUE;
-	return;
+    struct GVncCapture *capture = opaque;
+    gint32 encodings[] = {  VNC_CONNECTION_ENCODING_DESKTOP_RESIZE,
+                            VNC_CONNECTION_ENCODING_ZRLE,
+                            VNC_CONNECTION_ENCODING_HEXTILE,
+                            VNC_CONNECTION_ENCODING_RRE,
+                            VNC_CONNECTION_ENCODING_COPY_RECT,
+                            VNC_CONNECTION_ENCODING_RAW };
+    gint32 *encodingsp;
+    int n_encodings;
+
+    do_vnc_desktop_resize(conn,
+                          vnc_connection_get_width(conn),
+                          vnc_connection_get_height(conn),
+                          capture);
+
+    encodingsp = encodings;
+    n_encodings = G_N_ELEMENTS(encodings);
+
+    VNC_DEBUG("Sending %d encodings", n_encodings);
+    if (!vnc_connection_set_encodings(conn, n_encodings, encodingsp))
+        goto error;
+
+    VNC_DEBUG("Requesting first framebuffer update");
+    if (!vnc_connection_framebuffer_update_request(capture->conn,
+                                                   0, 0, 0,
+                                                   vnc_connection_get_width(capture->conn),
+                                                   vnc_connection_get_height(capture->conn)))
+        vnc_connection_shutdown(capture->conn);
+
+    if (!capture->quiet)
+        g_print("Connected to %s:%d\n", capture->host, capture->port - 5900);
+    capture->connected = TRUE;
+    return;
 
  error:
-	vnc_connection_shutdown(conn);
+    vnc_connection_shutdown(conn);
 }
 
 static void do_vnc_disconnected(VncConnection *conn G_GNUC_UNUSED,
-				gpointer opaque)
+                                gpointer opaque)
 {
-	struct GVncCapture *capture = opaque;
-	if (!capture->quiet) {
-		if (capture->connected)
-			g_print("Disconnected from %s:%d\n", capture->host, capture->port - 5900);
-		else
-			g_print("Unable to connect to %s:%d\n", capture->host, capture->port - 5900);
-	}
-	g_main_quit(capture->loop);
+    struct GVncCapture *capture = opaque;
+    if (!capture->quiet) {
+        if (capture->connected)
+            g_print("Disconnected from %s:%d\n", capture->host, capture->port - 5900);
+        else
+            g_print("Unable to connect to %s:%d\n", capture->host, capture->port - 5900);
+    }
+    g_main_quit(capture->loop);
 }
 
 static void do_vnc_auth_credential(VncConnection *conn, GValueArray *credList, gpointer opaque)
 {
-	struct GVncCapture *capture = opaque;
-	guint i;
-	char **data;
-
-	data = g_new0(char *, credList->n_values);
-
-	for (i = 0 ; i < credList->n_values ; i++) {
-		GValue *cred = g_value_array_get_nth(credList, i);
-		switch (g_value_get_enum(cred)) {
-		case VNC_CONNECTION_CREDENTIAL_PASSWORD:
-			data[i] = do_vnc_get_credential("Password: ", FALSE);
-			if (!data[i]) {
-				if (!capture->quiet)
-					g_print("Failed to read password\n");
-				vnc_connection_shutdown(conn);
-				goto cleanup;
-			}
-			break;
-		case VNC_CONNECTION_CREDENTIAL_USERNAME:
-			data[i] = do_vnc_get_credential("Username: ", TRUE);
-			if (!data[i]) {
-				if (!capture->quiet)
-					g_print("Failed to read username\n");
-				vnc_connection_shutdown(conn);
-				goto cleanup;
-			}
-			break;
-		case VNC_CONNECTION_CREDENTIAL_CLIENTNAME:
-			data[i] = g_strdup("gvnccapture");
-			break;
-		default:
-			break;
-		}
-	}
-	for (i = 0 ; i < credList->n_values ; i++) {
-		GValue *cred = g_value_array_get_nth(credList, i);
-		if (data[i]) {
-			if (!vnc_connection_set_credential(conn,
-							   g_value_get_enum(cred),
-							   data[i])) {
-				g_print("Failed to set credential type %d %s\n", g_value_get_enum(cred), data[i]);
-				vnc_connection_shutdown(conn);
-			}
-		} else {
-			if (!capture->quiet)
-				g_print("Unsupported credential type %d\n", g_value_get_enum(cred));
-			vnc_connection_shutdown(conn);
-		}
-	}
+    struct GVncCapture *capture = opaque;
+    guint i;
+    char **data;
+
+    data = g_new0(char *, credList->n_values);
+
+    for (i = 0 ; i < credList->n_values ; i++) {
+        GValue *cred = g_value_array_get_nth(credList, i);
+        switch (g_value_get_enum(cred)) {
+        case VNC_CONNECTION_CREDENTIAL_PASSWORD:
+            data[i] = do_vnc_get_credential("Password: ", FALSE);
+            if (!data[i]) {
+                if (!capture->quiet)
+                    g_print("Failed to read password\n");
+                vnc_connection_shutdown(conn);
+                goto cleanup;
+            }
+            break;
+        case VNC_CONNECTION_CREDENTIAL_USERNAME:
+            data[i] = do_vnc_get_credential("Username: ", TRUE);
+            if (!data[i]) {
+                if (!capture->quiet)
+                    g_print("Failed to read username\n");
+                vnc_connection_shutdown(conn);
+                goto cleanup;
+            }
+            break;
+        case VNC_CONNECTION_CREDENTIAL_CLIENTNAME:
+            data[i] = g_strdup("gvnccapture");
+            break;
+        default:
+            break;
+        }
+    }
+    for (i = 0 ; i < credList->n_values ; i++) {
+        GValue *cred = g_value_array_get_nth(credList, i);
+        if (data[i]) {
+            if (!vnc_connection_set_credential(conn,
+                                               g_value_get_enum(cred),
+                                               data[i])) {
+                g_print("Failed to set credential type %d %s\n", g_value_get_enum(cred), data[i]);
+                vnc_connection_shutdown(conn);
+            }
+        } else {
+            if (!capture->quiet)
+                g_print("Unsupported credential type %d\n", g_value_get_enum(cred));
+            vnc_connection_shutdown(conn);
+        }
+    }
 
  cleanup:
-	for (i = 0 ; i < credList->n_values ; i++)
-		g_free(data[i]);
-	g_free(data);
+    for (i = 0 ; i < credList->n_values ; i++)
+        g_free(data[i]);
+    g_free(data);
 }
 
 static void do_vnc_auth_choose_type(VncConnection *conn,
-				    GValueArray *types,
-				    gpointer opaque G_GNUC_UNUSED)
+                                    GValueArray *types,
+                                    gpointer opaque G_GNUC_UNUSED)
 {
-	guint i, j;
-
-	if (!types->n_values) {
-		VNC_DEBUG("No auth types to choose from");
-		return;
-	}
-
-	for (i = 0 ; i < G_N_ELEMENTS(preferable_auths) ; i++) {
-		int pref = preferable_auths[i];
-
-		for (j = 0 ; j < types->n_values ; j++) {
-			GValue *type = g_value_array_get_nth(types, j);
-			VNC_DEBUG("Compare %d vs %d", pref, g_value_get_enum(type));
-			if (pref == g_value_get_enum(type)) {
-				VNC_DEBUG("Chosen auth %d", pref);
-				vnc_connection_set_auth_type(conn, pref);
-				return;
-			}
-		}
-	}
-
-	GValue *type = g_value_array_get_nth(types, 0);
-	VNC_DEBUG("Chosen default auth %d", g_value_get_enum(type));
-	vnc_connection_set_auth_type(conn, g_value_get_enum(type));
+    guint i, j;
+
+    if (!types->n_values) {
+        VNC_DEBUG("No auth types to choose from");
+        return;
+    }
+
+    for (i = 0 ; i < G_N_ELEMENTS(preferable_auths) ; i++) {
+        int pref = preferable_auths[i];
+
+        for (j = 0 ; j < types->n_values ; j++) {
+            GValue *type = g_value_array_get_nth(types, j);
+            VNC_DEBUG("Compare %d vs %d", pref, g_value_get_enum(type));
+            if (pref == g_value_get_enum(type)) {
+                VNC_DEBUG("Chosen auth %d", pref);
+                vnc_connection_set_auth_type(conn, pref);
+                return;
+            }
+        }
+    }
+
+    GValue *type = g_value_array_get_nth(types, 0);
+    VNC_DEBUG("Chosen default auth %d", g_value_get_enum(type));
+    vnc_connection_set_auth_type(conn, g_value_get_enum(type));
 }
 
 
 static void show_help(const char *binary, const char *error)
 {
-	if (error)
-		g_print("%s\n\n", error);
-	g_print("Usage: %s [HOSTNAME][:DISPLAY] FILENAME\n\n", binary);
-	g_print("Run '%s --help' to see a full list of available command line options\n",
-		binary);
+    if (error)
+        g_print("%s\n\n", error);
+    g_print("Usage: %s [HOSTNAME][:DISPLAY] FILENAME\n\n", binary);
+    g_print("Run '%s --help' to see a full list of available command line options\n",
+            binary);
 }
 
 static gboolean vnc_debug_option_arg(const gchar *option_name G_GNUC_UNUSED,
-				     const gchar *value G_GNUC_UNUSED,
-				     gpointer data G_GNUC_UNUSED,
-				     GError **error G_GNUC_UNUSED)
+                                     const gchar *value G_GNUC_UNUSED,
+                                     gpointer data G_GNUC_UNUSED,
+                                     GError **error G_GNUC_UNUSED)
 {
-	vnc_util_set_debug(TRUE);
-	return TRUE;
+    vnc_util_set_debug(TRUE);
+    return TRUE;
 }
 
 
 int main(int argc, char **argv)
 {
-	GOptionContext *context;
-	GError *error = NULL;
-	gchar *display;
-	gchar *port;
-	gchar **args = NULL;
-	int ret;
-	gboolean quiet = FALSE;
-	const GOptionEntry options [] = {
-		{ "debug", 'd', G_OPTION_FLAG_NO_ARG,  G_OPTION_ARG_CALLBACK,
-		  vnc_debug_option_arg, "Enables debug output", NULL },
-		{ "quiet", 'q', 0, G_OPTION_ARG_NONE,
-		  &quiet, "Don't print any status to console", NULL },
-		{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
-		  NULL, "HOSTNAME[:DISPLAY] FILENAME" },
-		{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
-	};
-	struct GVncCapture *capture;
-
-	g_type_init();
-
-	/* Setup command line options */
-	context = g_option_context_new("- Vnc Image Capture");
-	g_option_context_add_main_entries(context, options, NULL);
-	g_option_context_parse(context, &argc, &argv, &error);
-	if (error) {
-		show_help(argv[0], error->message);
-		g_error_free(error);
-		return 1;
-	}
-	if (!args || (g_strv_length(args) != 2)) {
-		show_help(argv[0], NULL);
-		return 1;
-	}
-
-	capture = g_new0(struct GVncCapture, 1);
-	capture->quiet = quiet;
-
-	if (args[0][0] == ':') {
-		capture->host = g_strdup("localhost");
-		display = args[0];
-	} else {
-		capture->host = g_strdup(args[0]);
-		display = strchr(capture->host, ':');
-	}
-	if (display) {
-		*display = 0;
-		display++;
-		capture->port = 5900 + atoi(display);
-	} else {
-		capture->port = 5900;
-	}
-	port = g_strdup_printf("%d", capture->port);
-
-	capture->conn = vnc_connection_new();
-	capture->output = g_strdup(args[1]);
-
-	g_signal_connect(capture->conn, "vnc-initialized",
-			 G_CALLBACK(do_vnc_initialized), capture);
-	g_signal_connect(capture->conn, "vnc-disconnected",
-			 G_CALLBACK(do_vnc_disconnected), capture);
-	g_signal_connect(capture->conn, "vnc-auth-choose-type",
-			 G_CALLBACK(do_vnc_auth_choose_type), capture);
-	g_signal_connect(capture->conn, "vnc-auth-choose-subtype",
-			 G_CALLBACK(do_vnc_auth_choose_type), capture);
-	g_signal_connect(capture->conn, "vnc-auth-credential",
-			 G_CALLBACK(do_vnc_auth_credential), capture);
-	g_signal_connect(capture->conn, "vnc-desktop-resize",
-			 G_CALLBACK(do_vnc_desktop_resize), capture);
-	g_signal_connect(capture->conn, "vnc-framebuffer-update",
-			 G_CALLBACK(do_vnc_framebuffer_update), capture);
-
-	vnc_connection_open_host(capture->conn, capture->host, port);
-
-	capture->loop = g_main_loop_new(g_main_context_default(), FALSE);
-
-	g_main_loop_run(capture->loop);
-
-	vnc_connection_shutdown(capture->conn);
-	g_object_unref(capture->conn);
-	if (capture->pixbuf)
-		gdk_pixbuf_unref(capture->pixbuf);
-
-	ret = capture->saved ? 0 : 1;
-
-	g_free(capture->host);
-	g_free(capture);
-
-	return ret;
+    GOptionContext *context;
+    GError *error = NULL;
+    gchar *display;
+    gchar *port;
+    gchar **args = NULL;
+    int ret;
+    gboolean quiet = FALSE;
+    const GOptionEntry options [] = {
+        { "debug", 'd', G_OPTION_FLAG_NO_ARG,  G_OPTION_ARG_CALLBACK,
+          vnc_debug_option_arg, "Enables debug output", NULL },
+        { "quiet", 'q', 0, G_OPTION_ARG_NONE,
+          &quiet, "Don't print any status to console", NULL },
+        { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
+          NULL, "HOSTNAME[:DISPLAY] FILENAME" },
+        { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
+    };
+    struct GVncCapture *capture;
+
+    g_type_init();
+
+    /* Setup command line options */
+    context = g_option_context_new("- Vnc Image Capture");
+    g_option_context_add_main_entries(context, options, NULL);
+    g_option_context_parse(context, &argc, &argv, &error);
+    if (error) {
+        show_help(argv[0], error->message);
+        g_error_free(error);
+        return 1;
+    }
+    if (!args || (g_strv_length(args) != 2)) {
+        show_help(argv[0], NULL);
+        return 1;
+    }
+
+    capture = g_new0(struct GVncCapture, 1);
+    capture->quiet = quiet;
+
+    if (args[0][0] == ':') {
+        capture->host = g_strdup("localhost");
+        display = args[0];
+    } else {
+        capture->host = g_strdup(args[0]);
+        display = strchr(capture->host, ':');
+    }
+    if (display) {
+        *display = 0;
+        display++;
+        capture->port = 5900 + atoi(display);
+    } else {
+        capture->port = 5900;
+    }
+    port = g_strdup_printf("%d", capture->port);
+
+    capture->conn = vnc_connection_new();
+    capture->output = g_strdup(args[1]);
+
+    g_signal_connect(capture->conn, "vnc-initialized",
+                     G_CALLBACK(do_vnc_initialized), capture);
+    g_signal_connect(capture->conn, "vnc-disconnected",
+                     G_CALLBACK(do_vnc_disconnected), capture);
+    g_signal_connect(capture->conn, "vnc-auth-choose-type",
+                     G_CALLBACK(do_vnc_auth_choose_type), capture);
+    g_signal_connect(capture->conn, "vnc-auth-choose-subtype",
+                     G_CALLBACK(do_vnc_auth_choose_type), capture);
+    g_signal_connect(capture->conn, "vnc-auth-credential",
+                     G_CALLBACK(do_vnc_auth_credential), capture);
+    g_signal_connect(capture->conn, "vnc-desktop-resize",
+                     G_CALLBACK(do_vnc_desktop_resize), capture);
+    g_signal_connect(capture->conn, "vnc-framebuffer-update",
+                     G_CALLBACK(do_vnc_framebuffer_update), capture);
+
+    vnc_connection_open_host(capture->conn, capture->host, port);
+
+    capture->loop = g_main_loop_new(g_main_context_default(), FALSE);
+
+    g_main_loop_run(capture->loop);
+
+    vnc_connection_shutdown(capture->conn);
+    g_object_unref(capture->conn);
+    if (capture->pixbuf)
+        gdk_pixbuf_unref(capture->pixbuf);
+
+    ret = capture->saved ? 0 : 1;
+
+    g_free(capture->host);
+    g_free(capture);
+
+    return ret;
 }
 
 /*
  * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
  * End:
  */



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