1 | /* $Id: ClipboardProvider.cpp 78897 2019-05-31 15:23:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard - Provider implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
|
---|
23 | #include <VBox/GuestHost/SharedClipboard-uri.h>
|
---|
24 |
|
---|
25 | #include <iprt/asm.h>
|
---|
26 | #include <iprt/assert.h>
|
---|
27 | #include <iprt/dir.h>
|
---|
28 | #include <iprt/errcore.h>
|
---|
29 | #include <iprt/file.h>
|
---|
30 | #include <iprt/path.h>
|
---|
31 | #include <iprt/string.h>
|
---|
32 |
|
---|
33 |
|
---|
34 | #include <VBox/log.h>
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 | SharedClipboardProvider::SharedClipboardProvider(void)
|
---|
39 | : m_cRefs(0)
|
---|
40 | {
|
---|
41 | LogFlowFuncEnter();
|
---|
42 | }
|
---|
43 |
|
---|
44 | SharedClipboardProvider::~SharedClipboardProvider(void)
|
---|
45 | {
|
---|
46 | LogFlowFuncEnter();
|
---|
47 | Assert(m_cRefs == 0);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Creates a Shared Clipboard provider.
|
---|
52 | *
|
---|
53 | * @returns New Shared Clipboard provider instance.
|
---|
54 | * @param pCtx Pointer to creation context.
|
---|
55 | */
|
---|
56 | /* static */
|
---|
57 | SharedClipboardProvider *SharedClipboardProvider::Create(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx)
|
---|
58 | {
|
---|
59 | AssertPtrReturn(pCtx, NULL);
|
---|
60 |
|
---|
61 | SharedClipboardProvider *pProvider = NULL;
|
---|
62 |
|
---|
63 | switch (pCtx->enmSource)
|
---|
64 | {
|
---|
65 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_GUEST
|
---|
66 | case SHAREDCLIPBOARDPROVIDERSOURCE_VBGLR3:
|
---|
67 | pProvider = new SharedClipboardProviderVbglR3(pCtx->u.VBGLR3.uClientID);
|
---|
68 | break;
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST
|
---|
72 | case SHAREDCLIPBOARDPROVIDERSOURCE_HOSTSERVICE:
|
---|
73 | pProvider = new SharedClipboardProviderHostService();
|
---|
74 | break;
|
---|
75 | #endif
|
---|
76 | default:
|
---|
77 | AssertFailed();
|
---|
78 | break;
|
---|
79 | }
|
---|
80 |
|
---|
81 | return pProvider;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Adds a reference to a Shared Clipboard provider.
|
---|
86 | *
|
---|
87 | * @returns New reference count.
|
---|
88 | */
|
---|
89 | uint32_t SharedClipboardProvider::AddRef(void)
|
---|
90 | {
|
---|
91 | LogFlowFuncEnter();
|
---|
92 | return ASMAtomicIncU32(&m_cRefs);
|
---|
93 | }
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Removes a reference from a Shared Clipboard cache.
|
---|
97 | *
|
---|
98 | * @returns New reference count.
|
---|
99 | */
|
---|
100 | uint32_t SharedClipboardProvider::Release(void)
|
---|
101 | {
|
---|
102 | LogFlowFuncEnter();
|
---|
103 | Assert(m_cRefs);
|
---|
104 | return ASMAtomicDecU32(&m_cRefs);
|
---|
105 | }
|
---|
106 |
|
---|