[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Opening the same file twice
From:       David Faure <faure () kde ! org>
Date:       2004-03-10 13:20:32
Message-ID: 200403101420.32193.faure () kde ! org
[Download RAW message or body]

On Wednesday 10 March 2004 15:10, Marc Heyvaert wrote:
> > 1. You open a file for which you have no writing permissions. The file
> > opens ok, there is no warning, nothing in the titlebar. I would like to see
> > there a warning dialog and a permanent reminder of the situation in the
> > title bar. Example : /home/march/Documents/abc.ksp - KSpread  <read-only>

Yep, to be done.
Should be easy since all apps support a readonly mode already (for e.g. embedding into konqueror).

> > 2. You open a file that has already been opened. This is a real life
> > situation and even more so in linux than in Windows because most of us work
> > on several desktops. When I do portfolio-updates I sometimes open 10 of
> > them. In MS-Excel there all on the same desktop, all different windows
> > inside the same application (I prefer it that way for this type of work).
> > With KSpread you have 10 windows, but if you shuffle your work around on
> > your desktops you can easily find yourself editing the same file twice!
> > Saving it twice and losing half of your work without being aware of it. So
> > this is a second reason why the read-only feature could be helpfull.
> >
> > As to the way to implement it...there are several ways of doing it. I think
> > that checking if you have write permission must be possible, so that covers
> > situation 1. For situation 2 a hack could be to write a semaphor file to
> > the same directory as the directory of the original file. This file could
> > have 0 bytes, same name, same extension + an agreed extra extension.
> > Writing this file will be possible because it comes after the check for (1)
> > and is only needed in case someone opens the other file for writing. On
> > File|Close and File|Quit the semaphor file should be removed.

This would lead to many problems if the application (or the X server, or the machine) crashes
and you end up with a stale "semaphor" file around.

I think this can be implemented in a more robust way by using DCOP to ask
"is anyone editing that file already"? All running e.g. KOffice apps would be awakened
and would answer yes if they do (this can be done nicely using DCOP's findObject()).

Of course the DCOP solution has one drawback: it won't detect if two users
(or the same user on two displays) are editing the same file.
[This is because there is one dcopserver per user and per display].
To fix this, the "lock file" solution is the only one (but including the PID of
the app having the lock, or even better, the DCOP app-id, to be able to
ping it and see if it's still alive and indeed editing that file).

Once that works we might want to extend the solution to all of KDE 
(kate/kwrite/etc. would need this too I suppose).
Cc'ing the Kate developers, I wonder if they thought about this already.

-- 
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic