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

« back to all changes in this revision

Viewing changes to services/plugins/dndcp/dndcp.cpp

  • 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
 * @file dndcp.cpp --
 
21
 *
 
22
 * Entry points for DnD and CP plugin.
 
23
 *
 
24
 * No platform-specific code belongs here. See copyPasteDnDWrapper.[h|cpp]
 
25
 * for abstraction API to platform implementations, and copyPasteDnDImpl.h
 
26
 * for implementation class inteface. To add a new platform, derive from
 
27
 * CopyPasteDnDImpl.
 
28
 */
 
29
 
 
30
extern "C" {
 
31
#include "vmware.h"
 
32
#include "vmware/guestrpc/tclodefs.h"
 
33
#include "vmware/tools/plugin.h"
 
34
#include "vmware/tools/utils.h"
 
35
}
 
36
 
 
37
#include <string.h>
 
38
#include "copyPasteDnDWrapper.h"
 
39
 
 
40
extern "C" {
 
41
 
 
42
/**
 
43
 * Cleanup internal data on shutdown.
 
44
 *
 
45
 * @param[in]  src      Unused.
 
46
 * @param[in]  ctx      Unused.
 
47
 * @param[in]  data     Unused.
 
48
 */
 
49
 
 
50
static void
 
51
DnDCPShutdown(gpointer src,
 
52
              ToolsAppCtx *ctx,
 
53
              gpointer data)
 
54
{
 
55
   g_debug("%s: enter\n", __FUNCTION__);
 
56
   CopyPasteDnDWrapper *p = CopyPasteDnDWrapper::GetInstance();
 
57
   if (p) {
 
58
      p->UnregisterCP();
 
59
      p->UnregisterDnD();
 
60
   }
 
61
   CopyPasteDnDWrapper::Destroy();
 
62
}
 
63
 
 
64
 
 
65
/**
 
66
 * Handle a reset signal.
 
67
 *
 
68
 * @param[in]  src      Unused.
 
69
 * @param[in]  ctx      Unused.
 
70
 * @param[in]  data     Unused.
 
71
 */
 
72
 
 
73
static void
 
74
DnDCPReset(gpointer src,
 
75
           ToolsAppCtx *ctx,
 
76
           gpointer data)
 
77
{
 
78
   g_debug("%s: enter\n", __FUNCTION__);
 
79
   CopyPasteDnDWrapper *p = CopyPasteDnDWrapper::GetInstance();
 
80
   if (p) {
 
81
      p->OnReset();
 
82
   }
 
83
}
 
84
 
 
85
 
 
86
/**
 
87
 * Returns the list of the plugin's capabilities.
 
88
 *
 
89
 *
 
90
 * @param[in]  src      Unused.
 
91
 * @param[in]  ctx      Unused.
 
92
 * @param[in]  set      Whether setting or unsetting the capability.
 
93
 * @param[in]  data     Unused.
 
94
 *
 
95
 * @return A list of capabilities.
 
96
 */
 
97
 
 
98
static GArray *
 
99
DnDCPCapabilities(gpointer src,
 
100
                  ToolsAppCtx *ctx,
 
101
                  gboolean set,
 
102
                  gpointer data)
 
103
{
 
104
   g_debug("%s: enter\n", __FUNCTION__);
 
105
   CopyPasteDnDWrapper *p = CopyPasteDnDWrapper::GetInstance();
 
106
   if (p) {
 
107
      p->OnCapReg(set);
 
108
   }
 
109
   return NULL;
 
110
}
 
111
 
 
112
 
 
113
/**
 
114
 * Handles SetOption callback.
 
115
 *
 
116
 *
 
117
 * @param[in]  src       Unused.
 
118
 * @param[in]  ctx       Unused.
 
119
 * @param[in]  data      Unused.
 
120
 * @param[in]  option    The option being set.
 
121
 * @param[in]  value     The value the option is being set to.
 
122
 *
 
123
 * @return TRUE on success, FALSE otherwise.
 
124
 */
 
125
 
 
126
static gboolean
 
127
DnDCPSetOption(gpointer src,
 
128
               ToolsAppCtx *ctx,
 
129
               const gchar *option,
 
130
               const gchar *value,
 
131
               gpointer data)
 
132
{
 
133
   gboolean ret = FALSE;
 
134
 
 
135
   ASSERT(option);
 
136
   ASSERT(value);
 
137
   g_debug("%s: enter option %s value %s\n", __FUNCTION__, option, value);
 
138
   CopyPasteDnDWrapper *p = CopyPasteDnDWrapper::GetInstance();
 
139
 
 
140
   if (option == NULL || (strcmp(option, TOOLSOPTION_ENABLEDND) != 0 &&
 
141
                         strcmp(option, TOOLSOPTION_COPYPASTE) != 0)) {
 
142
      goto out;
 
143
   }
 
144
 
 
145
   if (value == NULL || (strcmp(value, "2") != 0 &&
 
146
                         strcmp(value, "1") != 0 &&
 
147
                         strcmp(value, "0") != 0)) {
 
148
      goto out;
 
149
   }
 
150
 
 
151
   if (p) {
 
152
      p->Init(ctx);
 
153
      ret = p->OnSetOption(option, value);
 
154
   }
 
155
out:
 
156
   return ret;
 
157
}
 
158
 
 
159
 
 
160
/**
 
161
 * Plugin entry point. Initializes internal plugin state.
 
162
 *
 
163
 * @param[in]  ctx   The app context.
 
164
 *
 
165
 * @return The registration data.
 
166
 */
 
167
 
 
168
TOOLS_MODULE_EXPORT ToolsPluginData *
 
169
ToolsOnLoad(ToolsAppCtx *ctx)
 
170
{
 
171
   static ToolsPluginData regData = {
 
172
      "dndCP",
 
173
      NULL,
 
174
      NULL
 
175
   };
 
176
 
 
177
   if (ctx->rpc != NULL) {
 
178
      ToolsPluginSignalCb sigs[] = {
 
179
         { TOOLS_CORE_SIG_CAPABILITIES, (void *) DnDCPCapabilities, NULL },
 
180
         { TOOLS_CORE_SIG_RESET, (void *) DnDCPReset, NULL },
 
181
         { TOOLS_CORE_SIG_SET_OPTION, (void *) DnDCPSetOption, NULL },
 
182
         { TOOLS_CORE_SIG_SHUTDOWN, (void *) DnDCPShutdown, NULL }
 
183
      };
 
184
 
 
185
      ToolsAppReg regs[] = {
 
186
         { TOOLS_APP_SIGNALS, VMTools_WrapArray(sigs, sizeof *sigs, ARRAYSIZE(sigs)) }
 
187
      };
 
188
 
 
189
      /*
 
190
       * DnD/CP Initialization here.
 
191
       */
 
192
 
 
193
      CopyPasteDnDWrapper *p = CopyPasteDnDWrapper::GetInstance();
 
194
      if (p) {
 
195
         p->Init(ctx);
 
196
         p->PointerInit();
 
197
      }
 
198
 
 
199
      regData.regs = VMTools_WrapArray(regs, sizeof *regs, ARRAYSIZE(regs));
 
200
      return &regData;
 
201
   }
 
202
 
 
203
   return NULL;
 
204
}
 
205
 
 
206
}