VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/clipboard.h@ 23794

Last change on this file since 23794 was 8155, checked in by vboxsync, 17 years ago

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1/** @file
2 *
3 * Shared Clipboard:
4 * Linux guest.
5 */
6
7/*
8 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __Additions_linux_clipboard_h
24# define __Additions_linux_clipboard_h
25
26#include <VBox/log.h>
27#include "thread.h" /* for VBoxGuestThread */
28
29extern void vboxClipboardDisconnect (void);
30extern int vboxClipboardConnect (void);
31extern int vboxClipboardMain (void);
32
33/**
34 * Display change request monitor thread function
35 */
36class VBoxGuestClipboardThread : public VBoxGuestThreadFunction
37{
38private:
39 // Copying or assigning a thread object is not sensible
40 VBoxGuestClipboardThread(const VBoxGuestClipboardThread&);
41 VBoxGuestClipboardThread& operator=(const VBoxGuestClipboardThread&);
42
43 // Private member variables
44 /** Have we been initialised yet? */
45 bool mInit;
46 /** The thread object running us. */
47 VBoxGuestThread *mThread;
48public:
49 VBoxGuestClipboardThread() { mInit = false; }
50 /**
51 * Initialise the class and check that the guest supports dynamic resizing.
52 * @returns iprt status value
53 */
54 int init(void)
55 {
56 if (mInit)
57 return true;
58 return vboxClipboardConnect();
59 }
60 /**
61 * The actual thread function.
62 *
63 * @returns iprt status code as thread return value
64 * @param pParent the VBoxGuestThread running this thread function
65 */
66 virtual int threadFunction(VBoxGuestThread *pThread)
67 {
68 vboxClipboardMain();
69 return VINF_SUCCESS;
70 }
71 /**
72 * Send a signal to the thread function that it should exit
73 */
74 virtual void stop(void) { vboxClipboardDisconnect(); }
75};
76
77class VBoxGuestClipboard
78{
79private:
80 /** No copying or assignment. */
81 VBoxGuestClipboard(const VBoxGuestClipboard &);
82 VBoxGuestClipboard& operator=(const VBoxGuestClipboard &);
83
84 /** Our monitor thread function */
85 VBoxGuestClipboardThread mThreadFunction;
86 /** And the thread for the thread function */
87 VBoxGuestThread mThread;
88 /** Are we initialised? */
89 bool mInit;
90public:
91 /**
92 * Initialise the class.
93 * @returns iprt status value
94 */
95 int init(void)
96 {
97 LogFlowThisFunc(("\n"));
98 int rc = mThreadFunction.init();
99 if (RT_SUCCESS(rc))
100 rc = mThread.start();
101 if (RT_SUCCESS(rc))
102 mInit = true;
103 LogFlowThisFunc(("returning %Rrc\n", rc));
104 return rc;
105 }
106 /**
107 * Uninitialise the class.
108 * @param cMillies how long to wait for the thread to stop
109 */
110 void uninit(unsigned cMillies = RT_INDEFINITE_WAIT)
111 {
112 LogFlowThisFunc(("\n"));
113 if (mInit)
114 mThread.stop(cMillies, NULL);
115 LogFlowThisFunc(("returning\n"));
116 }
117
118 VBoxGuestClipboard() : mThread(&mThreadFunction, 0, RTTHREADTYPE_MSG_PUMP,
119 RTTHREADFLAGS_WAITABLE, "SHCLIP MAIN")
120 { mInit = false; }
121 ~VBoxGuestClipboard()
122 {
123 LogFlowThisFunc(("\n"));
124 if (mInit)
125 try {
126 uninit(2000);
127 } catch (...) { }
128 LogFlowThisFunc(("returning\n"));
129 }
130};
131
132#endif /* __Additions_linux_clipboard_h not defined */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette