[haiku-development] session manager

Hi,

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:


protected:
        // Session Manager
                        bool                            HasBeenRestored();
        virtual status_t                        RestoreState(const BMessage* 
state,
                                                                        
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?

Regards,
        Clemens


*)

class BSessionAppReadStorage {
public:
                                                                
~BSessionAppReadStorage();

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

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

                        BMessenger                      fSessionMessenger;
                        BPath                           fSessionPath;
                        team_id                         fTeam;

                        BList                           fStorageList;
};


class BSessionAppStorage : public BSessionAppReadStorage {
public:
                                                                
~BSessionAppStorage();

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

                        bool                            HasBeenAborted();
private:
        friend class BApplication;

                                                                
BSessionAppStorage(BMessage* data);
};

Other related posts: