1 | /* $Id: SharedClipboardPrivate.h 78683 2019-05-23 10:07:21Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Private Shared Clipboard code. */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2019 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef MAIN_INCLUDED_SharedClipboardPrivate_h
|
---|
18 | #define MAIN_INCLUDED_SharedClipboardPrivate_h
|
---|
19 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
20 | # pragma once
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #include <iprt/dir.h>
|
---|
24 | #include <iprt/file.h>
|
---|
25 | #include <iprt/path.h>
|
---|
26 |
|
---|
27 | #include <VBox/hgcmsvc.h> /* For PVBOXHGCMSVCPARM. */
|
---|
28 | #include <VBox/HostServices/VBoxClipboardSvc.h>
|
---|
29 |
|
---|
30 |
|
---|
31 | /* Prototypes. */
|
---|
32 | class Console;
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Private singleton class for the Shared Clipboard
|
---|
36 | * implementation. Can't be instanciated directly, only via
|
---|
37 | * the factory pattern.
|
---|
38 | */
|
---|
39 | class SharedClipboard
|
---|
40 | {
|
---|
41 | public:
|
---|
42 |
|
---|
43 | static SharedClipboard *createInstance(const ComObjPtr<Console>& pConsole)
|
---|
44 | {
|
---|
45 | Assert(NULL == SharedClipboard::s_pInstance);
|
---|
46 | SharedClipboard::s_pInstance = new SharedClipboard(pConsole);
|
---|
47 | return SharedClipboard::s_pInstance;
|
---|
48 | }
|
---|
49 |
|
---|
50 | static void destroyInstance(void)
|
---|
51 | {
|
---|
52 | if (SharedClipboard::s_pInstance)
|
---|
53 | {
|
---|
54 | delete SharedClipboard::s_pInstance;
|
---|
55 | SharedClipboard::s_pInstance = NULL;
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | static inline SharedClipboard *getInstance(void)
|
---|
60 | {
|
---|
61 | AssertPtr(SharedClipboard::s_pInstance);
|
---|
62 | return SharedClipboard::s_pInstance;
|
---|
63 | }
|
---|
64 |
|
---|
65 | protected:
|
---|
66 |
|
---|
67 | SharedClipboard(const ComObjPtr<Console>& pConsole);
|
---|
68 | virtual ~SharedClipboard(void);
|
---|
69 |
|
---|
70 | public:
|
---|
71 |
|
---|
72 | /** @name Public helper functions.
|
---|
73 | * @{ */
|
---|
74 | int hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const;
|
---|
75 | /** @} */
|
---|
76 |
|
---|
77 | public:
|
---|
78 |
|
---|
79 | /** @name Static low-level HGCM callback handler.
|
---|
80 | * @{ */
|
---|
81 | static DECLCALLBACK(int) hostServiceCallback(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
|
---|
82 | /** @} */
|
---|
83 |
|
---|
84 | protected:
|
---|
85 |
|
---|
86 | /** @name Singleton properties.
|
---|
87 | * @{ */
|
---|
88 | /** Pointer to console implementation. */
|
---|
89 | const ComObjPtr<Console> m_pConsole;
|
---|
90 | /** @} */
|
---|
91 |
|
---|
92 | private:
|
---|
93 |
|
---|
94 | /** Staic pointer to singleton instance. */
|
---|
95 | static SharedClipboard *s_pInstance;
|
---|
96 | };
|
---|
97 |
|
---|
98 | /** Access to the Shared Clipboard's singleton instance. */
|
---|
99 | #define SHAREDCLIPBOARDINST() SharedClipboard::getInstance()
|
---|
100 |
|
---|
101 | #endif /* !MAIN_INCLUDED_SharedClipboardPrivate_h */
|
---|
102 |
|
---|