1
/*********************************************************
2
* Copyright (C) 2009 VMware, Inc. All rights reserved.
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.
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.
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.
17
*********************************************************/
20
* unityPluginEntry.cpp --
22
* Implements the unity plugin for the tools services. Registers for the Unity
23
* RPC's and sets the Unity capabilities.
25
* XXX Rewrite all of this to match CUI models and be, like, readable.
28
#define G_LOG_DOMAIN "unity"
30
#include "unityPlugin.h"
33
# include "unityPluginPosix.h"
38
// guestrpc.h defines the RPCIn_Callback which is needed in rpcin.h which is in turn
39
// included by unity.h - so guestrpc.h must precede unity.h
40
#include "vmware/tools/guestrpc.h"
42
#include "vmware/tools/plugin.h"
43
#include "vmware/tools/utils.h"
45
TOOLS_MODULE_EXPORT ToolsPluginData *ToolsOnLoad(ToolsAppCtx *ctx);
48
using namespace vmware::tools;
52
*-----------------------------------------------------------------------------
56
* Plugin entry point. Returns the registration data.
64
*-----------------------------------------------------------------------------
67
TOOLS_MODULE_EXPORT ToolsPluginData *
68
ToolsOnLoad(ToolsAppCtx *ctx) // IN: The app context.
70
static ToolsPluginData regData = {
76
if (ctx->rpc != NULL) {
77
ToolsPlugin *pluginInstance = NULL;
80
pluginInstance = new UnityPluginWin32(ctx);
82
pluginInstance = new UnityPluginPosix(ctx);
85
if (!pluginInstance) {
86
// There's nothing we can do if we can't construct the plugin instance
90
if (!pluginInstance->Initialize()) {
91
g_warning("%s: Unity Plugin failed to initialize.\n", __FUNCTION__);
92
delete pluginInstance;
95
regData._private = pluginInstance;
97
std::vector<RpcChannelCallback> rpcs = pluginInstance->GetRpcCallbackList();
98
std::vector<ToolsPluginSignalCb> sigs =
99
pluginInstance->GetSignalRegistrations(®Data);
101
ToolsAppReg regs[] = {
102
{ TOOLS_APP_GUESTRPC, VMTools_WrapArray(&rpcs[0], sizeof rpcs[0], rpcs.size()) },
103
{ TOOLS_APP_SIGNALS, VMTools_WrapArray(&sigs[0], sizeof sigs[0], sigs.size()) },
106
regData.regs = VMTools_WrapArray(regs, sizeof *regs, ARRAYSIZE(regs));