/src/libreoffice/vcl/inc/salsession.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <vcl/dllapi.h> |
23 | | |
24 | | enum SalSessionEventType |
25 | | { |
26 | | Interaction, |
27 | | SaveRequest, |
28 | | ShutdownCancel, |
29 | | Quit |
30 | | }; |
31 | | |
32 | | struct SalSessionEvent |
33 | | { |
34 | | SalSessionEventType m_eType; |
35 | | |
36 | | SalSessionEvent( SalSessionEventType eType ) |
37 | | : m_eType( eType ) |
38 | 0 | {} |
39 | | }; |
40 | | |
41 | | struct SalSessionInteractionEvent : public SalSessionEvent |
42 | | { |
43 | | bool m_bInteractionGranted; |
44 | | |
45 | | SalSessionInteractionEvent( bool bGranted ) |
46 | | : SalSessionEvent( Interaction ), |
47 | | m_bInteractionGranted( bGranted ) |
48 | 0 | {} |
49 | | }; |
50 | | |
51 | | struct SalSessionSaveRequestEvent : public SalSessionEvent |
52 | | { |
53 | | bool m_bShutdown; |
54 | | |
55 | | SalSessionSaveRequestEvent( bool bShutdown ) |
56 | | : SalSessionEvent( SaveRequest ), |
57 | | m_bShutdown( bShutdown ) |
58 | 0 | {} |
59 | | }; |
60 | | |
61 | | struct SalSessionShutdownCancelEvent : public SalSessionEvent |
62 | | { |
63 | | SalSessionShutdownCancelEvent() |
64 | | : SalSessionEvent( ShutdownCancel ) |
65 | 0 | {} |
66 | | }; |
67 | | |
68 | | struct SalSessionQuitEvent : public SalSessionEvent |
69 | | { |
70 | | SalSessionQuitEvent() |
71 | | : SalSessionEvent( Quit ) |
72 | 0 | {} |
73 | | }; |
74 | | |
75 | | typedef void(*SessionProc)(void *pData, SalSessionEvent *pEvent); |
76 | | |
77 | | class VCL_PLUGIN_PUBLIC SalSession |
78 | | { |
79 | | SessionProc m_aProc; |
80 | | void * m_pProcData; |
81 | | public: |
82 | | SalSession() |
83 | | : m_aProc(nullptr) |
84 | | , m_pProcData(nullptr) |
85 | 0 | { |
86 | 0 | } |
87 | | virtual ~SalSession(); |
88 | | |
89 | | void SetCallback( SessionProc aCallback, void * pCallbackData ) |
90 | 0 | { |
91 | 0 | m_aProc = aCallback; |
92 | 0 | m_pProcData = pCallbackData; |
93 | 0 | } |
94 | | void CallCallback( SalSessionEvent* pEvent ) |
95 | 0 | { |
96 | 0 | if( m_aProc ) |
97 | 0 | m_aProc( m_pProcData, pEvent ); |
98 | 0 | } |
99 | | |
100 | | // query the session manager for a user interaction slot |
101 | | virtual void queryInteraction() = 0; |
102 | | // signal the session manager that we're done with user interaction |
103 | | virtual void interactionDone() = 0; |
104 | | // signal that we're done saving |
105 | | virtual void saveDone() = 0; |
106 | | // try to cancel the shutdown in progress |
107 | | virtual bool cancelShutdown() = 0; |
108 | | }; |
109 | | |
110 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |