[haiku-development] session manager

  • From: Clemens <clemens.zeidler@xxxxxxxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Sat, 25 Jun 2011 18:15:18 +1200


here is short proposal for a session manager api. Had a session manager already working some time ago but there have been some feature requests:

1) be able to report progress
2) additional storage for large data (for example to save unsaved images in an image editor)

Here is a short overview of the current system. Two new virtual function are added to the BApplication class. One to store and one to restore the application state:

        // Session Manager
                        bool                            HasBeenRestored();
        virtual status_t                        RestoreState(const BMessage* 
BSessionAppReadStorage* storage);
        virtual status_t                        SaveState(BMessage* state,
BSessionAppStorage* storage) const;

The BMessage can be used to store general data, for most cases this should be enough to save the app state.

Each application has a private storage pool assigned where data can be saved by name identifier in a BDataIO object (BFile). The BSessionAppReadStorage and BSessionAppStorage *) can be used to open existing files and acquire new files. They also can be used to report progress to the session manager. Acquired files are automatically released when leaving the SaveState method. HasBeenAborted indicates if the user cancelled the shutdown process.

Storing and saving S&T groups is working :-)

Any suggestions?



class BSessionAppReadStorage {

                        status_t                        OpenStorage(const char* 
name, BDataIO** data);

                        void                            SetProgress(float 
        friend class BApplication;
BSessionAppReadStorage(BMessage* data);

                        BMessenger                      fSessionMessenger;
                        BPath                           fSessionPath;
                        team_id                         fTeam;

                        BList                           fStorageList;

class BSessionAppStorage : public BSessionAppReadStorage {

                        status_t                        AcquireStorage(const 
char* name,
BDataIO** data);
                        status_t                        ReleaseStorage(BDataIO* 
                        status_t                        RemoveStorage(const 
char* name);

                        bool                            HasBeenAborted();
        friend class BApplication;

BSessionAppStorage(BMessage* data);

Other related posts: