1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _VCL_SALSESSION_HXX 25 #define _VCL_SALSESSION_HXX 26 27 #include "vcl/dllapi.h" 28 29 enum SalSessionEventType 30 { 31 Interaction, 32 SaveRequest, 33 ShutdownCancel, 34 Quit 35 }; 36 37 struct SalSessionEvent 38 { 39 SalSessionEventType m_eType; 40 SalSessionEventSalSessionEvent41 SalSessionEvent( SalSessionEventType eType ) 42 : m_eType( eType ) 43 {} 44 }; 45 46 struct SalSessionInteractionEvent : public SalSessionEvent 47 { 48 bool m_bInteractionGranted; 49 SalSessionInteractionEventSalSessionInteractionEvent50 SalSessionInteractionEvent( bool bGranted ) 51 : SalSessionEvent( Interaction ), 52 m_bInteractionGranted( bGranted ) 53 {} 54 }; 55 56 struct SalSessionSaveRequestEvent : public SalSessionEvent 57 { 58 bool m_bShutdown; 59 bool m_bCancelable; 60 SalSessionSaveRequestEventSalSessionSaveRequestEvent61 SalSessionSaveRequestEvent( bool bShutdown, bool bCancelable ) 62 : SalSessionEvent( SaveRequest ), 63 m_bShutdown( bShutdown ), 64 m_bCancelable( bCancelable ) 65 {} 66 }; 67 68 struct SalSessionShutdownCancelEvent : public SalSessionEvent 69 { SalSessionShutdownCancelEventSalSessionShutdownCancelEvent70 SalSessionShutdownCancelEvent() 71 : SalSessionEvent( ShutdownCancel ) 72 {} 73 }; 74 75 struct SalSessionQuitEvent : public SalSessionEvent 76 { SalSessionQuitEventSalSessionQuitEvent77 SalSessionQuitEvent() 78 : SalSessionEvent( Quit ) 79 {} 80 }; 81 82 typedef void(*SessionProc)( SalSessionEvent *pEvent); 83 84 class VCL_PLUGIN_PUBLIC SalSession 85 { 86 SessionProc m_aProc; 87 public: SalSession()88 SalSession() 89 : m_aProc( 0 ) 90 {} 91 virtual ~SalSession(); 92 SetCallback(SessionProc aCallback)93 void SetCallback( SessionProc aCallback ) 94 { 95 m_aProc = aCallback; 96 } CallCallback(SalSessionEvent * pEvent)97 void CallCallback( SalSessionEvent* pEvent ) 98 { 99 if( m_aProc ) 100 m_aProc( pEvent ); 101 } 102 103 // query the session manager for a user interaction slot 104 virtual void queryInteraction() = 0; 105 // signal the session manager that we're done with user interaction 106 virtual void interactionDone() = 0; 107 // signal that we're done saving 108 virtual void saveDone() = 0; 109 // try to cancel the sutdown in progress 110 virtual bool cancelShutdown() = 0; 111 }; 112 113 #endif 114