Index: gnumeric-1.6.2/src/workbook-control-gui.h
===================================================================
--- gnumeric-1.6.2.orig/src/workbook-control-gui.h
+++ gnumeric-1.6.2/src/workbook-control-gui.h
@@ -44,6 +44,11 @@ void       wbcg_set_end_mode      (Workb
 
 void	   wbcg_set_transient_for (WorkbookControlGUI *wbcg, GtkWindow *window);
 
+void       wbcg_save_set_sensitivity (WorkbookControlGUI *wbcg, gboolean state);
+
+void       wbcg_msg_dialog (WorkbookControl *wbc, const char *data, const char *msg);
+
+
 PangoFontDescription *wbcg_get_font_desc (WorkbookControlGUI *wbcg);
 
 #endif /* GNUMERIC_WORKBOOK_CONTROL_GUI_H */
Index: gnumeric-1.6.2/src/flock.h
===================================================================
--- /dev/null
+++ gnumeric-1.6.2/src/flock.h
@@ -0,0 +1,12 @@
+#ifndef FLOCK_H
+#define FLOCK_H
+
+#include "workbook.h"
+
+WbLockState flock_acquire (const char *, char **);
+
+char *flock_verify (const char *);
+
+gboolean flock_release (const char *);
+
+#endif /* FLOCK_H */
Index: gnumeric-1.6.2/src/workbook-view.c
===================================================================
--- gnumeric-1.6.2.orig/src/workbook-view.c
+++ gnumeric-1.6.2/src/workbook-view.c
@@ -1,4 +1,5 @@
-/* vim: set sw=8: */
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
 /*
  * workbook-view.c: View functions for the workbook
  *
@@ -24,6 +25,7 @@
 #include "workbook-view.h"
 
 #include "workbook-control-priv.h"
+#include "workbook-control-gui.h"
 #include "workbook.h"
 #include "application.h"
 #include "sheet.h"
@@ -62,6 +64,8 @@
 #include "mathfunc.h"
 #include <goffice/utils/go-file.h>
 
+#include "flock.h"
+
 /* WorkbookView signals */
 enum {
 	LAST_SIGNAL
@@ -581,6 +585,8 @@ workbook_view_new (Workbook *wb)
 	wbv->do_auto_completion = gnm_app_use_auto_complete ();
 	wbv->is_protected = FALSE;
 
+        workbook_set_lock_state (wb, WB_LOCK_SELF);
+
 	/* Set the default operation to be performed over selections */
 	wbv->auto_expr      = NULL;
 	wbv->auto_expr_desc = NULL;
@@ -647,6 +653,95 @@ wbv_save_to_uri (WorkbookView *wbv, GOFi
 	g_free (msg);
 }
 
+void
+wb_view_adapt_to_locking (WorkbookView *wbv,
+			  const char *lockdata,
+			  WbLockState state,
+			  WbvLockNotification ln)
+{
+	const char *uri;
+	char *msg;
+	const char *tmp_data;
+	const char *raw_msg;
+	char *header;
+
+	if ((ln != WBV_EXT_LOCK_SAVE) && (ln != WBV_EXT_LOCK_SAVEAS)) {
+		WORKBOOK_VIEW_FOREACH_CONTROL (wbv, control, wbcg_save_set_sensitivity (control, FALSE););
+	}
+
+	switch (ln) {
+	case WBV_EXT_LOCK_OPEN:
+		if (state == WB_LOCK_EXT) {
+			raw_msg = _("The workbook '%s' is locked, which should mean that "
+				    "someone else is currently using it.  The workbook "
+				    "will be opened, but saving changes will be disabled "
+				    "to prevent the possibility of conflicting changes by "
+				    "concurrent users.  Use the SAVE AS menu action to "
+				    "store any changes under a new name.  Otherwise try "
+				    "re-opening the workbook later.");
+		} else {
+			raw_msg = _("The workbook '%s' cannot be modified because insufficient "
+				    "file system access permissions are available.  The workbook "
+				    "will be opened, but saving changes will be disabled.  "
+				    "Use the SAVE AS menu action to store any changes elsewhere.");
+		}
+		break;
+	case WBV_EXT_LOCK_SAVE:
+		raw_msg = _("Saving of workbook '%s' has been disabled. Use the "
+			    "SAVE AS menu action to store any changes under a new name.");
+		break;
+	case WBV_EXT_LOCK_SAVEAS:
+		if (state == WB_LOCK_EXT) {
+			raw_msg = _("The workbook '%s' is locked.  This likely means that "
+				    "someone else is currently using it.  To prevent the possibility "
+				    "of conflicting changes by concurrent users, saving to this "
+				    "workbook has been disabled.");
+		} else {
+			raw_msg = _("The workbook '%s' cannot be modified because insufficient "
+				    "access permissions are available.  Consequently, saving to this "
+				    "workbook has been disabled.");
+		}
+		break;
+	case WBV_SELF_LOCK_FAULT:
+		raw_msg = _("The lock for workbook '%s' has been removed or damaged.  "
+			    "This is unexpected and is probably a sign that something "
+			    "has gone wrong.  To prevent the possibility of conflicting "
+			    "changes by concurrent users, saving to this workbook has "
+			    "been disabled.");
+		break;
+	default:
+		g_assert_not_reached();
+	}
+
+	uri = workbook_get_uri (wb_view_workbook (wbv));
+	if (lockdata == NULL) {
+		tmp_data = flock_verify (uri);
+	} else {
+		tmp_data = lockdata;
+	}
+	msg = g_strdup_printf (raw_msg, g_path_get_basename (uri));
+
+	switch (state) {
+	case WB_LOCK_EXT:
+		header = g_strdup_printf ("LOCKED by %s", tmp_data);
+		break;
+	case WB_LOCK_PRIVS:
+		header = g_strdup ("MODIFICATION NOT PERMITTED");
+		break;
+	default:
+		/* This should never happen */
+		header = g_strdup ("ABANDON ALL HOPE, YE WHO SEE THIS MESSAGE");
+	}
+
+	WORKBOOK_VIEW_FOREACH_CONTROL (wbv, control, 
+				       wbcg_msg_dialog(control, header, msg); break;);
+
+	if (lockdata == NULL) {
+		g_free (tmp_data);
+	}
+	g_free (msg);
+}
+
 /**
  * wb_view_save_as:
  * @wbv         : Workbook View
@@ -667,6 +762,9 @@ wb_view_save_as (WorkbookView *wbv, GOFi
 	IOContext *io_context;
 	Workbook  *wb;
 	gboolean has_error, has_warning;
+        char *lockdata;
+	WbLockState new_lock_state;
+	gboolean uri_changed = FALSE;
 
 	g_return_val_if_fail (IS_WORKBOOK_VIEW (wbv), FALSE);
 	g_return_val_if_fail (IS_GO_FILE_SAVER (fs), FALSE);
@@ -676,17 +774,36 @@ wb_view_save_as (WorkbookView *wbv, GOFi
 	wb = wb_view_workbook (wbv);
 	io_context = gnumeric_io_context_new (context);
 
+        if ((new_lock_state = flock_acquire(uri, &lockdata)) != WB_LOCK_SELF) {
+		wb_view_adapt_to_locking (wbv, lockdata, new_lock_state, WBV_EXT_LOCK_SAVEAS);
+		g_free (lockdata);
+		return FALSE;
+        }
+
 	go_cmd_context_set_sensitive (context, FALSE);
 	wbv_save_to_uri (wbv, fs, uri, io_context);
 	go_cmd_context_set_sensitive (context, TRUE);
 
 	has_error   = gnumeric_io_error_occurred (io_context);
 	has_warning = gnumeric_io_warning_occurred (io_context);
-	if (!has_error) {
-		if (workbook_set_saveinfo (wb,
-			go_file_saver_get_format_level (fs), fs) &&
-		    workbook_set_uri (wb, uri))
+	if ((! has_error) && 
+	    (workbook_set_saveinfo (wb, go_file_saver_get_format_level (fs), fs))) {
+		char *old_uri = g_strdup (workbook_get_uri(wb));
+		if (workbook_set_uri (wb, uri)) {
+			uri_changed = TRUE;
+			if (workbook_lock_state (wb) == WB_LOCK_SELF) {
+				flock_release (old_uri);
+			} else {
+				workbook_set_lock_state (wbv->wb, new_lock_state);
+				WORKBOOK_VIEW_FOREACH_CONTROL (
+					wbv, control, wbcg_save_set_sensitivity (control, TRUE););
+			}
 			workbook_set_dirty (wb, FALSE);
+		}
+		g_free (old_uri);
+	}
+	if (! uri_changed) {
+		flock_release (uri);
 	}
 	if (has_error || has_warning)
 		gnumeric_io_error_display (io_context);
@@ -713,11 +830,25 @@ wb_view_save (WorkbookView *wbv, GOCmdCo
 	Workbook	*wb;
 	GOFileSaver	*fs;
 	gboolean has_error, has_warning;
+	char *lockdata;
 
 	g_return_val_if_fail (IS_WORKBOOK_VIEW (wbv), FALSE);
 	g_return_val_if_fail (IS_GO_CMD_CONTEXT (context), FALSE);
 
 	wb = wb_view_workbook (wbv);
+
+	if ((lockdata = flock_verify (workbook_get_uri(wb))) != NULL) {
+		WbLockState state;
+		if ((state = workbook_lock_state (wb)) == WB_LOCK_EXT) {
+			wb_view_adapt_to_locking (wbv, lockdata, state, WBV_EXT_LOCK_SAVE);
+		} else {
+			workbook_set_lock_state (wbv->wb, state);
+			wb_view_adapt_to_locking (wbv, lockdata, state, WBV_SELF_LOCK_FAULT);
+		}
+		g_free (lockdata);
+		return FALSE;
+        }
+
 	fs = workbook_get_file_saver (wb);
 	if (fs == NULL)
 		fs = go_file_saver_get_default ();
@@ -1028,6 +1159,16 @@ wb_view_new_from_uri (char const *uri,
 					      optional_fmt, io_context,
 					      optional_enc);
 		g_object_unref (G_OBJECT (input));
+
+		if (res != NULL) {
+			WbLockState lock_state;
+
+			lock_state = flock_acquire(uri, NULL);
+			/* There is apparently no GUI existing yet (at least in most cases),
+			   so we cannot disable (grey out) SAVE here... Only make a note for later. */
+			workbook_set_lock_state (res->wb, lock_state);
+		}
+
 		return res;
 	}
 
Index: gnumeric-1.6.2/src/workbook.c
===================================================================
--- gnumeric-1.6.2.orig/src/workbook.c
+++ gnumeric-1.6.2/src/workbook.c
@@ -15,6 +15,7 @@
 #include <glib/gi18n.h>
 #include "gnumeric.h"
 #include "workbook-priv.h"
+#include "workbook.h"
 
 #include "workbook-view.h"
 #include "workbook-control.h"
@@ -40,6 +41,8 @@
 #include <goffice/utils/go-file.h>
 #include <goffice/utils/go-glib-extras.h>
 
+#include "flock.h"
+
 #ifdef WITH_GTK
 #ifdef WITH_GNOME
 #include <bonobo/bonobo-main.h>
@@ -72,6 +75,18 @@ cb_saver_finalize (Workbook *wb, GOFileS
 	g_return_if_fail (IS_WORKBOOK (wb));
 	g_return_if_fail (wb->file_saver == saver);
 	wb->file_saver = NULL;
+} 
+
+WbLockState
+workbook_lock_state (Workbook *wb)
+{
+	return wb->lock_state;
+}
+
+void
+workbook_set_lock_state (Workbook *wb, WbLockState state)
+{
+	wb->lock_state = state;
 }
 
 static void
@@ -80,6 +95,10 @@ workbook_dispose (GObject *wb_object)
 	Workbook *wb = WORKBOOK (wb_object);
 	GList *sheets, *ptr;
 
+	if (wb->lock_state == WB_LOCK_SELF) {
+		flock_release(wb->uri);	
+	}
+ 
 	wb->during_destruction = TRUE;
 
 	if (wb->file_saver)
Index: gnumeric-1.6.2/src/workbook-priv.h
===================================================================
--- gnumeric-1.6.2.orig/src/workbook-priv.h
+++ gnumeric-1.6.2/src/workbook-priv.h
@@ -20,6 +20,8 @@ struct _Workbook {
 	gboolean modified;
 	gboolean is_placeholder;
 
+        WbLockState lock_state;
+
 	gchar		*uri;
 	FileFormatLevel  file_format_level;
 	GOFileSaver	*file_saver;
Index: gnumeric-1.6.2/src/flock.c
===================================================================
--- /dev/null
+++ gnumeric-1.6.2/src/flock.c
@@ -0,0 +1,277 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <goffice/utils/go-file.h>
+#include <glib/gi18n.h>
+
+#include "gnumeric.h"
+#include "flock.h"
+
+#ifndef O_NOFOLLOW
+#define O_NOFOLLOW (0)
+#endif
+
+const unsigned max_lockdata_sz = 1024;
+
+static char * gen_lockname (const char *);
+static char * gen_lockdata (void);
+static char * read_lockdata (char *);
+
+static char *
+gen_lockname (const char *uri)
+{
+	char *dir, *base, *lockname;
+
+	if ((uri == NULL) || (strlen(uri) == 0) || (strncmp (uri, "file://", 7) != 0)) {
+		return NULL;
+	}
+
+	dir = go_dirname_from_uri (uri, TRUE);
+	base = go_basename_from_uri (uri);
+	lockname = g_strdup_printf ("%s/.%s.lock", dir, base);
+	g_free (base);
+	g_free (dir);
+
+	/* XXX debugging */
+	/* g_printerr ("lockname is '%s'\n", lockname); */
+
+	return lockname;
+}
+
+#if (! ((GLIB_MAJOR_VERSION > 2) || ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 8))))
+static const char *
+g_get_host_name (void)
+{
+	static char hostname [HOST_NAME_MAX + 1];
+	
+	if (gethostname (hostname, HOST_NAME_MAX) == -1) {
+		return _("localhost");
+	}
+	return hostname;
+}
+#endif
+
+static char *
+gen_lockdata ()
+{
+	const gchar *username;
+	const gchar *hostname;
+	uid_t uid;
+	pid_t pid;
+	char *data;
+
+	username = g_get_user_name();
+	hostname = g_get_host_name();
+	uid = getuid ();
+	pid = getpid ();
+	data = g_strdup_printf ("%s@%s (uid %lu, pid %lu)", username, hostname, 
+				(long unsigned) uid, (long unsigned) pid);
+
+	if (strlen (data) >= max_lockdata_sz) {
+		g_printerr (_("WARNING: lock data size exceeds allowance (%lu >= %lu)\n"), 
+			    strlen (data), max_lockdata_sz);
+	}
+
+	return data;
+}
+
+static char *
+read_lockdata (char *lockname)
+{
+	int fd, r_rc, c_rc;
+	char *data;
+
+	fd = g_open (lockname, O_RDONLY);
+	if (fd == -1) {
+		return NULL;
+	}
+
+	data = (char *) g_malloc0 (max_lockdata_sz);
+	
+	r_rc = read (fd, data, max_lockdata_sz - 1);
+	c_rc = close (fd);
+	
+	/* XXX debugging */
+	/* g_printerr ("lockdata is '%s'\n", data); */
+
+	if ((r_rc == -1) || (c_rc == -1) ||
+	    (! g_utf8_validate(data, -1, NULL))) {
+		g_free (data);
+		return NULL;
+	}
+	
+	/* XXX debugging */
+	/* g_printerr ("lockdata is utf8-kosher\n", data); */
+
+	return data;
+}
+
+WbLockState
+flock_acquire (const char* uri, char **lockdata_ref)
+{
+	char *lockname = NULL;
+	char *lockdata = NULL;
+	const char *err_msg = NULL;
+	mode_t mask;
+	int fd;
+	WbLockState state = WB_LOCK_EXT;
+
+	lockname = gen_lockname (uri);
+	if (lockname == NULL) {
+		err_msg = _("illegal lockname");
+		goto flock_lock_finish;
+	}
+
+	/* XXX debugging */
+	//XXX g_printerr ("locking '%s'\n", lockname);
+
+	mask = umask(0);
+	fd = g_open (lockname, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+	umask(mask);
+ 	if (fd != -1) {
+		int w_rc, c_rc;
+
+		lockdata = gen_lockdata ();
+		if (lockdata == NULL) {
+			err_msg = _("lock data generation error");
+			goto flock_lock_finish;
+		}
+
+		w_rc = write (fd, lockdata, MIN(strlen (lockdata), max_lockdata_sz));
+		g_free(lockdata);
+		lockdata = NULL;
+		c_rc = close (fd);
+
+		if (w_rc == -1) {
+			err_msg = _("lock write failure");
+			goto flock_lock_finish;
+		}
+		if (c_rc == -1) {
+			err_msg = _("lock close failure");
+			goto flock_lock_finish;
+		}
+		
+		state = WB_LOCK_SELF;
+	} else {
+		GFileError error = g_file_error_from_errno (errno);
+		if (error == G_FILE_ERROR_EXIST) {
+			if ((lockdata = read_lockdata (lockname)) == NULL) {
+				err_msg = _("lock exists, but reading it failed");
+				goto flock_lock_finish;
+			}
+			/* XXX debugging */
+			//XXX g_printerr ("lock already held by '%s'\n", lockdata);
+		} else if ((error == G_FILE_ERROR_PERM) || (error == G_FILE_ERROR_ACCES)) {
+			err_msg = _("permissions prevent lock access");
+			state = WB_LOCK_PRIVS;
+			goto flock_lock_finish;
+		} else {
+			err_msg = _("lock open failed");
+		}
+	}
+
+  flock_lock_finish: 
+	if (err_msg != NULL) {
+		/* XXX debugging */
+		//XXX g_printerr ("locking failed for '%s'\n", lockname);
+		
+		g_assert (lockdata == NULL);
+		lockdata = g_strdup_printf ("%s (%s)", _("unknown"), err_msg);
+	}
+
+	if (lockdata_ref != NULL) {
+		*lockdata_ref = lockdata;
+	}
+
+	if (lockname != NULL) {
+		g_free(lockname);
+	}
+
+	return state;
+}  
+
+char *
+flock_verify (const char* uri)
+{
+	char *lockname = NULL;
+	char *expected_lockdata = NULL;
+	char *actual_lockdata = NULL;
+	const char *err_msg = NULL;
+	
+	lockname = gen_lockname (uri);
+	if (lockname == NULL) {
+		err_msg = _("illegal lockname");
+		goto flock_verify_finish;
+	}
+
+	expected_lockdata = gen_lockdata ();
+	if (expected_lockdata == NULL) {
+		err_msg = _("lock data generation error");
+		goto flock_verify_finish;
+	}
+
+	/* XXX debugging */
+	//XXX g_printerr ("verifying '%s'\n", lockname);
+	
+	if ((actual_lockdata = read_lockdata (lockname)) == NULL) {
+		err_msg = _("reading lock failed");
+		goto flock_verify_finish;
+	}
+
+	if (strncmp (expected_lockdata, actual_lockdata, max_lockdata_sz) == 0) {
+		g_free(actual_lockdata);
+		actual_lockdata = NULL;
+	} else {
+		/* XXX debugging */
+		/* g_printerr ("expected '%s', actually '%s'\n", expected_lockdata, actual_lockdata); */
+	}
+
+  flock_verify_finish:
+	if (err_msg != NULL) {
+		/* XXX debugging */
+		//XXX g_printerr ("lock verify failed for '%s'\n", lockname);
+		
+		g_assert (actual_lockdata == NULL);
+		actual_lockdata = g_strdup_printf ("%s (%s)", _("unknown"), err_msg);
+	}
+
+	if (lockname != NULL) {
+		g_free(lockname);
+	}
+	if (expected_lockdata != NULL) {
+		g_free(expected_lockdata);
+	}
+	return actual_lockdata;
+}  
+
+gboolean
+flock_release (const char* uri)
+{
+	char *lockname;
+	gboolean success;
+
+	if (flock_verify (uri) != NULL) {
+		return FALSE;
+	}
+
+	lockname = gen_lockname (uri);
+
+	/* XXX debugging */
+	//XXX g_printerr ("releasing '%s'\n", lockname);
+
+	success = (g_remove (lockname) == 0);
+	g_free(lockname);
+
+	return success;
+}  
Index: gnumeric-1.6.2/src/workbook-control-gui.c
===================================================================
--- gnumeric-1.6.2.orig/src/workbook-control-gui.c
+++ gnumeric-1.6.2/src/workbook-control-gui.c
@@ -1177,6 +1177,29 @@ wbcg_menu_state_update (WorkbookControl 
 	}
 }
 
+void
+wbcg_save_set_sensitivity (WorkbookControlGUI *wbcg, gboolean state)
+{
+	g_return_if_fail (wbcg != NULL);
+	wbcg_set_action_sensitivity (wbcg, "FileSave", state);
+}
+
+void
+wbcg_msg_dialog (WorkbookControl *wbc, const char *header, const char *msg)
+{
+	GtkWidget *d;
+	WorkbookControlGUI *wbcg = (WorkbookControlGUI *)wbc;
+
+	g_return_if_fail (wbcg != NULL);
+
+	d = gnumeric_message_dialog_new (wbcg_toplevel (wbcg),
+					 GTK_DIALOG_DESTROY_WITH_PARENT,
+					 GTK_MESSAGE_WARNING,
+					 header, msg);
+	go_gtk_dialog_add_button (GTK_DIALOG(d), "OK", GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+	go_gtk_dialog_run (GTK_DIALOG (d), wbcg_toplevel (wbcg));
+}
+
 static void
 wbcg_undo_redo_labels (WorkbookControl *wbc, char const *undo, char const *redo)
 {
Index: gnumeric-1.6.2/src/Makefile.am
===================================================================
--- gnumeric-1.6.2.orig/src/Makefile.am
+++ gnumeric-1.6.2/src/Makefile.am
@@ -85,6 +85,8 @@ GNUMERIC_BASE =					\
 	expr-name.h				\
 	file-autoft.c				\
 	file-autoft.h				\
+	flock.c  				\
+	flock.h		         		\
 	format-template.c			\
 	format-template.h			\
 	func.c					\
Index: gnumeric-1.6.2/src/main-application.c
===================================================================
--- gnumeric-1.6.2.orig/src/main-application.c
+++ gnumeric-1.6.2/src/main-application.c
@@ -438,6 +438,7 @@ main (int argc, char const *argv [])
 			}
 			if (wbv != NULL) {
 				WorkbookControlGUI *wbcg;
+				WbLockState lock_state;
 
 				wbcg = WORKBOOK_CONTROL_GUI
 					(workbook_control_gui_new (wbv, NULL, NULL));
@@ -448,6 +449,10 @@ main (int argc, char const *argv [])
 				if (immediate_exit_flag)
 					wbcgs_to_kill = g_slist_prepend (wbcgs_to_kill,
 									   wbcg);
+
+				if ((lock_state = workbook_lock_state (wbv->wb)) != WB_LOCK_SELF) {
+					wb_view_adapt_to_locking (wbv, NULL, lock_state, WBV_EXT_LOCK_OPEN);
+				}
 			}
 			/* cheesy attempt to keep the ui from freezing during
 			   load */
Index: gnumeric-1.6.2/src/workbook-view.h
===================================================================
--- gnumeric-1.6.2.orig/src/workbook-view.h
+++ gnumeric-1.6.2/src/workbook-view.h
@@ -1,7 +1,10 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
 #ifndef GNUMERIC_WORKBOOK_VIEW_H
 #define GNUMERIC_WORKBOOK_VIEW_H
 
 #include "gnumeric.h"
+#include "workbook.h"
 #include <glib-object.h>
 #include <gsf/gsf.h>
 
@@ -47,6 +50,18 @@ typedef struct {
 #define WORKBOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), WORKBOOK_VIEW_TYPE, WorkbookViewClass))
 #define IS_WORKBOOK_VIEW(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), WORKBOOK_VIEW_TYPE))
 
+/* File Locking */
+typedef enum {
+	WBV_EXT_LOCK_OPEN,
+	WBV_EXT_LOCK_SAVE,
+	WBV_EXT_LOCK_SAVEAS,
+	WBV_SELF_LOCK_FAULT
+} WbvLockNotification;
+void            wb_view_adapt_to_locking (WorkbookView *wbv,
+					  const char *lockdata,
+					  WbLockState state,
+					  WbvLockNotification ln);
+
 /* Lifecycle */
 GType		 workbook_view_get_type	  (void);
 WorkbookView	*workbook_view_new	  (Workbook *optional_workbook);
Index: gnumeric-1.6.2/src/gui-file.c
===================================================================
--- gnumeric-1.6.2.orig/src/gui-file.c
+++ gnumeric-1.6.2/src/gui-file.c
@@ -104,6 +104,7 @@ gui_wb_view_show (WorkbookControlGUI *wb
 {
 	WorkbookControlGUI *new_wbcg = NULL;
 	Workbook *tmp_wb = wb_control_workbook (WORKBOOK_CONTROL (wbcg));
+        WbLockState lock_state;
 
 #ifdef USE_HILDON
 	if (workbook_is_dirty (tmp_wb)) {
@@ -145,6 +146,10 @@ gui_wb_view_show (WorkbookControlGUI *wb
 	}
 #endif
 
+        if ((lock_state = workbook_lock_state (wbv->wb)) != WB_LOCK_SELF) {
+            wb_view_adapt_to_locking (wbv, NULL, lock_state, WBV_EXT_LOCK_OPEN);
+        }
+
 	sheet_update (wb_view_cur_sheet	(wbv));
 }
 
Index: gnumeric-1.6.2/src/workbook.h
===================================================================
--- gnumeric-1.6.2.orig/src/workbook.h
+++ gnumeric-1.6.2/src/workbook.h
@@ -10,6 +10,13 @@
 #include <goffice/app/file.h>
 #include <glib-object.h>
 
+/* File Locking */
+typedef enum {
+	WB_LOCK_EXT,
+	WB_LOCK_PRIVS,
+	WB_LOCK_SELF
+} WbLockState;
+
 GType       workbook_get_type            (void);
 Workbook   *workbook_new                 (void);
 Workbook   *workbook_new_with_sheets     (int sheet_count);
@@ -38,6 +45,8 @@ gboolean    workbook_sheet_rename       
 unsigned    workbook_find_command	(Workbook *wb,
 					 gboolean is_undo, gpointer cmd);
 
+WbLockState workbook_lock_state     (Workbook *wb);
+void        workbook_set_lock_state (Workbook *wb, WbLockState state);
 
 /* IO Routines */
 gboolean       workbook_set_uri		(Workbook *wb, char const *uri);
