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

« back to all changes in this revision

Viewing changes to services/plugins/unity/unityPlugin.cpp

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

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
 
 * unityPlugin.cpp --
21
 
 *
22
 
 *      Implements an object that provides the entry points for tools unity
23
 
 *      plugin.
24
 
 */
25
 
 
26
 
#include "vmware/tools/plugin.h"
27
 
 
28
 
extern "C" {
29
 
   #include "vmware.h"
30
 
   #include "conf.h"
31
 
   #include "debug.h"
32
 
   #include "dynxdr.h"
33
 
   #include "guestrpc/unity.h"
34
 
   #include "guestrpc/unityActive.h"
35
 
   #include "rpcin.h"
36
 
   #include "strutil.h"
37
 
   #if defined(OPEN_VM_TOOLS)
38
 
      #include "unitylib/unity.h"
39
 
   #else
40
 
      #include "unity.h"
41
 
   #endif // OPEN_VM_TOOLS
42
 
   #include "xdrutil.h"
43
 
};
44
 
 
45
 
#include "ghIntegration.h"
46
 
#include "ghiTclo.h"
47
 
#include "unityPlugin.h"
48
 
#include "unityTclo.h"
49
 
#if defined(G_PLATFORM_WIN32)
50
 
#include "NotifyIconRpcCallback.h"
51
 
#endif // G_PLATFORM_WIN32
52
 
 
53
 
#define UNITY_CAP_NAME "unity"
54
 
 
55
 
namespace vmware { namespace tools {
56
 
 
57
 
/*
58
 
 * The static instance of the notification icon RPC callback object. This object
59
 
 * sends an RPC to the VMX in response to any change to the set of notification
60
 
 * icons.
61
 
 */
62
 
#if defined(G_PLATFORM_WIN32)
63
 
static NotifyIconRpcCallback gNotifyIconCallback;
64
 
#endif // G_PLATFORM_WIN32
65
 
 
66
 
 
67
 
/*
68
 
 *-----------------------------------------------------------------------------
69
 
 *
70
 
 * UnityPlugin::UnityPlugin --
71
 
 *
72
 
 *      Constructor for the Unity plugin, initialized Unity, and common options
73
 
 *      values.
74
 
 *
75
 
 * Results:
76
 
 *      None.
77
 
 *
78
 
 * Side effects:
79
 
 *      None.
80
 
 *
81
 
 *-----------------------------------------------------------------------------
82
 
 */
83
 
 
84
 
UnityPlugin::UnityPlugin(const ToolsAppCtx* ctx)        // IN: The app context.
85
 
   : ToolsPlugin(ctx),
86
 
     mUnityUpdateChannel(NULL)
87
 
{
88
 
}
89
 
 
90
 
 
91
 
/*
92
 
 *-----------------------------------------------------------------------------
93
 
 *
94
 
 * UnityPlugin::Initialize --
95
 
 *
96
 
 *      Initializer for the Unity plugin, initialized Unity, and common options
97
 
 *      values
98
 
 *
99
 
 * Results:
100
 
 *      True if initializatino was successful.
101
 
 *
102
 
 * Side effects:
103
 
 *      None.
104
 
 *
105
 
 *-----------------------------------------------------------------------------
106
 
 */
107
 
 
108
 
gboolean
109
 
UnityPlugin::Initialize()
110
 
{
111
 
   UnityHostCallbacks unityHostCallbacks;
112
 
   memset(&unityHostCallbacks, 0, sizeof unityHostCallbacks);
113
 
   unityHostCallbacks.buildUpdateCB = &UnityBuildUpdates;
114
 
   unityHostCallbacks.updateCB = &UnityUpdateCallbackFn;
115
 
   unityHostCallbacks.sendWindowContents = &UnitySendWindowContents;
116
 
   unityHostCallbacks.sendRequestMinimizeOperation = &UnitySendRequestMinimizeOperation;
117
 
   unityHostCallbacks.shouldShowTaskbar = &UnityShouldShowTaskbar;
118
 
   UnityTcloInit();
119
 
 
120
 
   /*
121
 
    * Initialize the update channel.
122
 
    */
123
 
   mUnityUpdateChannel = UnityUpdateChannelInit();
124
 
   if (NULL == mUnityUpdateChannel) {
125
 
      Warning("%s: Unable to initialize Unity update channel.\n", __FUNCTION__);
126
 
      return false;
127
 
   }
128
 
   unityHostCallbacks.updateCbCtx = mUnityUpdateChannel;
129
 
 
130
 
   Unity_Init(unityHostCallbacks, mCtx->serviceObj);
131
 
 
132
 
   GHITcloInit();
133
 
   GHIHostCallbacks ghiHostCallbacks;
134
 
   memset(&ghiHostCallbacks, 0, sizeof ghiHostCallbacks);
135
 
   ghiHostCallbacks.launchMenuChange = &GHILaunchMenuChangeRPC;
136
 
 
137
 
#if defined(G_PLATFORM_WIN32)
138
 
   GHI_Init(mCtx->mainLoop, NULL, ghiHostCallbacks);
139
 
   GHI_RegisterNotifyIconCallback(&gNotifyIconCallback);
140
 
#else
141
 
   GHI_Init(mCtx->mainLoop, mCtx->envp, ghiHostCallbacks);
142
 
#endif // G_PLATFORM_WIN32
143
 
 
144
 
   if (g_key_file_get_boolean(mCtx->config, CONFGROUPNAME_UNITY,
145
 
                              CONFNAME_UNITY_ENABLEDEBUG, NULL)) {
146
 
      Unity_InitializeDebugger();
147
 
   }
148
 
   Unity_SetForceEnable(g_key_file_get_boolean(mCtx->config, CONFGROUPNAME_UNITY,
149
 
                                               CONFNAME_UNITY_FORCEENABLE, NULL));
150
 
 
151
 
   /*
152
 
    * If no preferred color is in the config file then use a light gray tone,
153
 
    * the value is stored as xBGR.
154
 
    */
155
 
   int desktopColor = 0;
156
 
   GError *e = NULL;
157
 
   desktopColor = g_key_file_get_integer(mCtx->config, CONFGROUPNAME_UNITY,
158
 
                                         CONFNAME_UNITY_BACKGROUNDCOLOR, &e);
159
 
   if (e != NULL) {
160
 
      desktopColor = /* red */ 0xdc |
161
 
                     /* green */ 0xdc << 8 |
162
 
                     /* blue */ 0xdc << 16;
163
 
   }
164
 
   Unity_SetConfigDesktopColor(desktopColor);
165
 
   return true;
166
 
}
167
 
 
168
 
 
169
 
/*
170
 
 *-----------------------------------------------------------------------------
171
 
 *
172
 
 * UnityPlugin::~UnityPlugin --
173
 
 *
174
 
 *      Destructor for the Unity plugin, cleanup Unity.
175
 
 *
176
 
 * Results:
177
 
 *      None.
178
 
 *
179
 
 * Side effects:
180
 
 *      Whole lotta stuff.
181
 
 *
182
 
 *-----------------------------------------------------------------------------
183
 
 */
184
 
 
185
 
UnityPlugin::~UnityPlugin()
186
 
{
187
 
   Unity_Cleanup();
188
 
   UnityUpdateChannelCleanup(mUnityUpdateChannel);
189
 
   UnityTcloCleanup();
190
 
#if defined(G_PLATFORM_WIN32)
191
 
   GHI_UnregisterNotifyIconCallback(&gNotifyIconCallback);
192
 
#endif // G_PLATFORM_WIN32
193
 
   GHI_Cleanup();
194
 
   GHITcloCleanup();
195
 
}
196
 
 
197
 
 
198
 
/*
199
 
 *-----------------------------------------------------------------------------
200
 
 *
201
 
 * UnityPlugin::GetCapabilities --
202
 
 *
203
 
 *      Called by the service core when the host requests the capabilities
204
 
 *      supported by the guest tools.
205
 
 *
206
 
 * Results:
207
 
 *      A list of capabilities to be sent to the host.
208
 
 *
209
 
 * Side effects:
210
 
 *      None.
211
 
 *
212
 
 *-----------------------------------------------------------------------------
213
 
 */
214
 
 
215
 
std::vector<ToolsAppCapability>
216
 
UnityPlugin::GetCapabilities(gboolean set) // IN
217
 
{
218
 
   /*
219
 
    * Note that we can't use UNITY_RPC_UNITY_CAP here because it includes the
220
 
    * "tools.capability" prefix which vmtoolsd will automatically prepend to the
221
 
    * supplied capability name.
222
 
    */
223
 
   Bool b = set ? Unity_IsSupported() : FALSE;
224
 
   std::vector<ToolsAppCapability> caps;
225
 
   caps.push_back(ToolsAppCapabilityOldEntry(UNITY_CAP_NAME, b));
226
 
   caps.push_back(ToolsAppCapabilityOldEntry("unity.taskbar", b));
227
 
   caps.push_back(ToolsAppCapabilityNewEntry(UNITY_CAP_STATUS_UNITY_ACTIVE, b));
228
 
   return caps;
229
 
}
230
 
 
231
 
 
232
 
/*
233
 
 *-----------------------------------------------------------------------------
234
 
 *
235
 
 * UnityPlugin::GetRpcCallbackList --
236
 
 *
237
 
 *      Called by the service core when the host requests the RPCs supported
238
 
 *      by the guest tools.
239
 
 *
240
 
 * Results:
241
 
 *      A list of RPC Callbacks to be sent to the host.
242
 
 *
243
 
 * Side effects:
244
 
 *      None.
245
 
 *
246
 
 *-----------------------------------------------------------------------------
247
 
 */
248
 
 
249
 
std::vector<RpcChannelCallback>
250
 
UnityPlugin::GetRpcCallbackList()
251
 
{
252
 
   std::vector<RpcChannelCallback> rpcList;
253
 
 
254
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_ENTER, UnityTcloEnter));
255
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_UPDATE_FULL, UnityTcloGetUpdate));
256
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_UPDATE_INCREMENTAL, UnityTcloGetUpdate));
257
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_WINDOW_PATH, UnityTcloGetWindowPath));
258
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_WINDOW_SETTOP, UnityTcloSetTopWindowGroup));
259
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_WINDOW_CONTENTS, UnityTcloGetWindowContents));
260
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_ICON_DATA, UnityTcloGetIconData));
261
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_DESKTOP_WORK_AREA_SET, UnityTcloSetDesktopWorkArea));
262
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_SHOW_TASKBAR, UnityTcloShowTaskbar));
263
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_EXIT, UnityTcloExit));
264
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_WINDOW_MOVE_RESIZE, UnityTcloMoveResizeWindow));
265
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_DESKTOP_CONFIG_SET, UnityTcloSetDesktopConfig));
266
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_DESKTOP_ACTIVE_SET, UnityTcloSetDesktopActive));
267
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_WINDOW_DESKTOP_SET, UnityTcloSetWindowDesktop));
268
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_CONFIRM_OPERATION, UnityTcloConfirmOperation));
269
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_SET_OPTIONS, UnityTcloSetUnityOptions));
270
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_WINDOW_CONTENTS_REQUEST, UnityTcloRequestWindowContents));
271
 
   rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_SEND_MOUSE_WHEEL, UnityTcloSendMouseWheel));
272
 
 
273
 
   char **commandList = NULL;
274
 
   Unity_GetWindowCommandList(&commandList);
275
 
   for (int i = 0; commandList && (NULL != commandList[i]); i++) {
276
 
      rpcList.push_back(RpcChannelCallbackEntry(commandList[i], UnityTcloWindowCommand));
277
 
   }
278
 
 
279
 
   if (GHI_IsSupported()) {
280
 
      rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_BINARY_INFO, GHITcloGetBinaryInfo));
281
 
      rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_OPEN_LAUNCHMENU, GHITcloOpenStartMenu));
282
 
      rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_LAUNCHMENU_ITEM, GHITcloGetStartMenuItem));
283
 
      rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_CLOSE_LAUNCHMENU, GHITcloCloseStartMenu));
284
 
      rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_SHELL_OPEN, GHITcloShellOpen));
285
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_GUEST_SHELL_ACTION, GHITcloShellAction));
286
 
      rpcList.push_back(RpcChannelCallbackEntry(UNITY_RPC_GET_BINARY_HANDLERS, GHITcloGetBinaryHandlers));
287
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_SET_GUEST_HANDLER, GHITcloSetGuestHandler));
288
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_RESTORE_DEFAULT_GUEST_HANDLER, GHITcloRestoreDefaultGuestHandler));
289
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_OUTLOOK_SET_TEMP_FOLDER, GHITcloSetOutlookTempFolder));
290
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_OUTLOOK_RESTORE_TEMP_FOLDER, GHITcloRestoreOutlookTempFolder));
291
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_TRAY_ICON_SEND_EVENT, GHITcloTrayIconSendEvent));
292
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_TRAY_ICON_START_UPDATES, GHITcloTrayIconStartUpdates));
293
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_TRAY_ICON_STOP_UPDATES, GHITcloTrayIconStopUpdates));
294
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_SET_FOCUSED_WINDOW, GHITcloSetFocusedWindow));
295
 
      rpcList.push_back(RpcChannelCallbackEntry(GHI_RPC_GET_EXEC_INFO_HASH, GHITcloGetExecInfoHash));
296
 
   }
297
 
 
298
 
   return rpcList;
299
 
}
300
 
 
301
 
} /* namespace tools */ } /* namespace vmware */