~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to services/plugins/dndcp/dndGuest/guestDnDCPMgr.cc

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2010 VMware, Inc. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License as published
 
6
 * by the Free Software Foundation version 2.1 and no later version.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
10
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
 
11
 * License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 
15
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
 
16
 *
 
17
 *********************************************************/
 
18
 
 
19
/**
 
20
 * @GuestDnDCPMgr.cc --
 
21
 *
 
22
 * Implementation of common layer GuestDnDCPMgr object.
 
23
 */
 
24
 
 
25
#include "guestDnDCPMgr.hh"
 
26
#ifdef DND_USING_VMCF
 
27
#   include "dndCPTransportVMCF.hh"
 
28
#else
 
29
#   include "dndCPTransportGuestRpc.hpp"
 
30
#endif
 
31
 
 
32
extern "C" {
 
33
   #include "debug.h"
 
34
   #include "guestApp.h"
 
35
}
 
36
 
 
37
GuestDnDCPMgr *GuestDnDCPMgr::m_instance = NULL;
 
38
 
 
39
 
 
40
/**
 
41
 *
 
42
 * Constructor.
 
43
 */
 
44
 
 
45
GuestDnDCPMgr::GuestDnDCPMgr()
 
46
   : mDnDMgr(NULL),
 
47
     mCPMgr(NULL),
 
48
     mFileTransfer(NULL),
 
49
     mTransport(NULL),
 
50
     mToolsAppCtx(NULL),
 
51
     mLocalCaps(0xffffffff)
 
52
{
 
53
}
 
54
 
 
55
 
 
56
/**
 
57
 * Destructor.
 
58
 */
 
59
 
 
60
GuestDnDCPMgr::~GuestDnDCPMgr(void)
 
61
{
 
62
   g_debug("%s: enter\n", __FUNCTION__);
 
63
   delete mDnDMgr;
 
64
   mDnDMgr = NULL;
 
65
   delete mFileTransfer;
 
66
   mFileTransfer = NULL;
 
67
   delete mTransport;
 
68
   mTransport = NULL;
 
69
}
 
70
 
 
71
 
 
72
/**
 
73
 * Get an instance of GuestDnDCPMgr, which is an application singleton.
 
74
 *
 
75
 * @return a pointer to the singleton GuestDnDCPMgr object, or NULL if
 
76
 * for some reason it could not be allocated.
 
77
 */
 
78
 
 
79
GuestDnDCPMgr *
 
80
GuestDnDCPMgr::GetInstance(void)
 
81
{
 
82
   if (!m_instance) {
 
83
      m_instance = new GuestDnDCPMgr;
 
84
   }
 
85
   return m_instance;
 
86
}
 
87
 
 
88
 
 
89
/**
 
90
 * Destroy the GuestDnDCPMgr singleton.
 
91
 */
 
92
 
 
93
void
 
94
GuestDnDCPMgr::Destroy(void)
 
95
{
 
96
   if (m_instance) {
 
97
      delete m_instance;
 
98
      m_instance = NULL;
 
99
   }
 
100
}
 
101
 
 
102
 
 
103
/**
 
104
 * Initialize the GuestDnDCPMgr object. All owner should call this first before
 
105
 * calling any other function.
 
106
 *
 
107
 * @param[in] ctx ToolsAppCtx
 
108
 */
 
109
 
 
110
void
 
111
GuestDnDCPMgr::Init(ToolsAppCtx *ctx)
 
112
{
 
113
   mToolsAppCtx = ctx;
 
114
 
 
115
#if !defined(DND_USING_VMCF)
 
116
   ASSERT(mToolsAppCtx);
 
117
#endif
 
118
 
 
119
   if (mFileTransfer) {
 
120
      delete mFileTransfer;
 
121
   }
 
122
   mFileTransfer = new GuestFileTransfer(GetTransport());
 
123
}
 
124
 
 
125
 
 
126
/**
 
127
 * Get the GuestDnDCPMgr object.
 
128
 *
 
129
 * @return a pointer to the GuestDnDCPMgr instance.
 
130
 */
 
131
 
 
132
GuestDnDMgr *
 
133
GuestDnDCPMgr::GetDnDMgr(void)
 
134
{
 
135
   if (!mDnDMgr) {
 
136
      /* mEventQueue must be set before this call. */
 
137
      mDnDMgr = new GuestDnDMgr(GetTransport(), mToolsAppCtx);
 
138
   }
 
139
   return mDnDMgr;
 
140
}
 
141
 
 
142
 
 
143
/**
 
144
 * Get the GuestCopyPasteMgr object.
 
145
 *
 
146
 * @return a pointer to the GuestCopyPasteMgr instance.
 
147
 */
 
148
 
 
149
GuestCopyPasteMgr *
 
150
GuestDnDCPMgr::GetCopyPasteMgr(void)
 
151
{
 
152
   if (!mCPMgr) {
 
153
      mCPMgr = new GuestCopyPasteMgr(GetTransport());
 
154
   }
 
155
   return mCPMgr;
 
156
}
 
157
 
 
158
 
 
159
/**
 
160
 * Get the DnDCPTransport object.
 
161
 *
 
162
 * XXX Implementation here is temporary and should be replaced with rpcChannel.
 
163
 *
 
164
 * @return a pointer to the manager's DnDCPTransport instance.
 
165
 */
 
166
 
 
167
DnDCPTransport *
 
168
GuestDnDCPMgr::GetTransport(void)
 
169
{
 
170
   if (!mTransport) {
 
171
      ASSERT(mToolsAppCtx);
 
172
#ifdef DND_USING_VMCF
 
173
      GKeyFile *confDictRef = NULL;
 
174
      const char *brokerAddr = NULL;
 
175
 
 
176
      confDictRef = mToolsAppCtx->config;
 
177
      if (confDictRef) {
 
178
         brokerAddr = g_key_file_get_string(confDictRef,
 
179
                                            "vmcf.broker",
 
180
                                            "addr",
 
181
                                            NULL);
 
182
      }
 
183
      if (!brokerAddr) {
 
184
 
 
185
         /* We are executing in the simulator, so hardcode the brokerAddr. */
 
186
         brokerAddr = "tcp:host=127.0.0.1,port=8672,family=ipv4";
 
187
      }
 
188
      mTransport = new DnDCPTransportVMCF(brokerAddr, NULL, false);
 
189
#else
 
190
      mTransport = new DnDCPTransportGuestRpc(mToolsAppCtx->rpc);
 
191
#endif
 
192
   }
 
193
   return mTransport;
 
194
}
 
195
 
 
196
 
 
197
/**
 
198
 * API for starting the transport main loop from python.
 
199
 */
 
200
 
 
201
void
 
202
GuestDnDCPMgr::StartLoop()
 
203
{
 
204
   (void) GetTransport();
 
205
   if (mTransport) {
 
206
      mTransport->StartLoop();
 
207
   }
 
208
}
 
209
 
 
210
 
 
211
/**
 
212
 * API for iterating the transport main loop from python.
 
213
 */
 
214
 
 
215
void
 
216
GuestDnDCPMgr::IterateLoop()
 
217
{
 
218
   (void) GetTransport();
 
219
   if (mTransport) {
 
220
      mTransport->IterateLoop();
 
221
   }
 
222
}
 
223
 
 
224
 
 
225
/**
 
226
 * API for ending the transport main loop from python.
 
227
 */
 
228
 
 
229
void
 
230
GuestDnDCPMgr::EndLoop()
 
231
{
 
232
   (void) GetTransport();
 
233
   if (mTransport) {
 
234
      mTransport->EndLoop();
 
235
   }
 
236
}