xref: /aoo41x/main/vcl/inc/salsession.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _VCL_SALSESSION_HXX
29 #define _VCL_SALSESSION_HXX
30 
31 #include "vcl/dllapi.h"
32 
33 enum SalSessionEventType
34 {
35     Interaction,
36     SaveRequest,
37     ShutdownCancel,
38     Quit
39 };
40 
41 struct SalSessionEvent
42 {
43     SalSessionEventType			m_eType;
44 
45     SalSessionEvent( SalSessionEventType eType )
46             : m_eType( eType )
47     {}
48 };
49 
50 struct SalSessionInteractionEvent : public SalSessionEvent
51 {
52     bool						m_bInteractionGranted;
53 
54     SalSessionInteractionEvent( bool bGranted )
55             : SalSessionEvent( Interaction ),
56               m_bInteractionGranted( bGranted )
57     {}
58 };
59 
60 struct SalSessionSaveRequestEvent : public SalSessionEvent
61 {
62     bool						m_bShutdown;
63     bool						m_bCancelable;
64 
65     SalSessionSaveRequestEvent( bool bShutdown, bool bCancelable )
66             : SalSessionEvent( SaveRequest ),
67               m_bShutdown( bShutdown ),
68               m_bCancelable( bCancelable )
69     {}
70 };
71 
72 struct SalSessionShutdownCancelEvent : public SalSessionEvent
73 {
74     SalSessionShutdownCancelEvent()
75             : SalSessionEvent( ShutdownCancel )
76     {}
77 };
78 
79 struct SalSessionQuitEvent : public SalSessionEvent
80 {
81     SalSessionQuitEvent()
82             : SalSessionEvent( Quit )
83     {}
84 };
85 
86 typedef void(*SessionProc)( SalSessionEvent *pEvent);
87 
88 class VCL_PLUGIN_PUBLIC SalSession
89 {
90     SessionProc			m_aProc;
91 public:
92     SalSession()
93             : m_aProc( 0 )
94     {}
95     virtual ~SalSession();
96 
97     void SetCallback( SessionProc aCallback )
98     {
99         m_aProc = aCallback;
100     }
101     void CallCallback( SalSessionEvent* pEvent )
102     {
103         if( m_aProc )
104             m_aProc( pEvent );
105     }
106 
107     // query the session manager for a user interaction slot
108     virtual void queryInteraction() = 0;
109     // signal the session manager that we're done with user interaction
110     virtual void interactionDone() = 0;
111     // signal that we're done saving
112     virtual void saveDone() = 0;
113     // try to cancel the sutdown in progress
114     virtual bool cancelShutdown() = 0;
115 };
116 
117 #endif
118