Konqueror session management + crash handler

So as it was promised, konqueror session management is already done. I’ve just sent an email to kfm-devel with the patch attached and hopefully the patch will enter into trunk before the hard feature freeze (next monday) so that we get it in Konqueror 4.1.

The session management support is pretty similar to the one that Opera has. Let’s say it’s inspired in Opera =). And as everyone likes screenshots, here there is one that shows the new menus for session management:

So you can easily save current session, open one of the saved sessions, or manage current sessions. And only one more item was added to the File Menu, which is the same menu where session management resides in Opera.

The Manage sessions dialog lets you save current session in a new session or in an existing session (overwriting it). It also can rename an existing session, or delete it. Or even open one of those sessions. Quite straightforward if you look at it, actually:

And I have reserved the best part for the end. Proper crash session recovery! Because Konqueror shouldn’t, but it can crash sometimes. And it crashes even more when you use KDE trunk. Until now, the only option you had to recover from a crash was using the crash plugin which is sub-optimal.

What I’ve done is something similar to what Opera, Firefox and many others browsers do: Save session every X seconds (it’s configurable via konquerorrc, 10 seconds by default as in firefox). This is done for all konqueror processes, and it’s saved in ~/.kde/share/apps/konqueror/autosaved/. Each process saves its session timely there in a file with a name similar to “:1.114” which identifies it. When a konqueror instance is closed cleanly, its file is removed.

Thus, every time a new window or konqueror process is launched, Konqueror reads that directory and asks to DBus if there’s any service registered with the name “:1.114”, for example, or whatever name have the autosaved files. This is done very fast, because no text parsing or waiting is needed, so the user doesn’t feel any delay.

If for some reason there’s a file with a name that is not related to a registered dbus service, that means that something wrong happened i.e. a konqueror process crashed or froze. And in that case, you get this nice dialog:

Which allows you to restore session if you want, or not, or even not restoring it now but restoring it later (opening a new konqueror process / window). As David Faure suggested me, it also allows you to check “do not ask again” and always do whatever you choose automatically without asking everytime. Nice isn’t it?

There’ still some related fixes I want to add to SVN before hard feature freeze, like adding a KAction menu to “Hibernate konqueror”, i.e. Save current session and close konqueror, so that next time you open konqueror it can be restored. Also listing the crashed and still not restored sessions (i.e. you clicked in “ask me later”) in the sessions menu.

Oh and adding an option to undo closed tab to right click menu of the konqueror tabbar is a must too, I use that option a lot now in firefox and we need it too ;-).