1
/*********************************************************
2
* Copyright (C) 2010 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
*********************************************************/
22
* Defines the object that implements the tools core service plugin form of
26
#ifndef _UNITY_PLUGIN_H_
27
#define _UNITY_PLUGIN_H_
33
#include "boost/shared_ptr.hpp"
36
#include "vmware/tools/plugin.h"
38
namespace vmware { namespace tools {
40
class UnityPBRPCServer;
42
typedef struct _UnityUpdateChannel UnityUpdateChannel;
46
*-----------------------------------------------------------------------------
48
* vmware::tools::RpcChannelCallbackEntry --
50
* Helper struct to build an RPCChannelCallback structure from a command
51
* string and RpcIn_Callback.
53
*-----------------------------------------------------------------------------
56
struct RpcChannelCallbackEntry
57
: public RpcChannelCallback
59
RpcChannelCallbackEntry(const char *RpcName, RpcIn_Callback func)
72
*-----------------------------------------------------------------------------
74
* vmware::tools::ToolsAppCapabilityOldEntry --
76
* Helper struct to build an ToolsAppCapability structure from an old
77
* style capability name and flag to indicate whether the capability is
80
*-----------------------------------------------------------------------------
83
struct ToolsAppCapabilityOldEntry
84
: public ToolsAppCapability
86
ToolsAppCapabilityOldEntry(const char *capName, gboolean enabled)
89
/* The capability name field is not-const (though it seems to be treated that way)
90
* so we'll need to cast away the const here 8-(
92
name = const_cast<gchar*>(capName);
99
*-----------------------------------------------------------------------------
101
* vmware::tools::ToolsAppCapabilityNewEntry --
103
* Helper struct to build an ToolsAppCapability structure from a new style
104
* capability index and flag to indicate whether the capability is enabled.
106
*-----------------------------------------------------------------------------
109
struct ToolsAppCapabilityNewEntry
110
: public ToolsAppCapability
112
ToolsAppCapabilityNewEntry(GuestCapabilities cap, gboolean enabled)
114
type = TOOLS_CAP_NEW;
123
*-----------------------------------------------------------------------------
125
* vmware::tools::ToolsPlugin --
127
* Defines a pure virtual interface for plugins to implement. These
128
* methods are called by per-plugin static C functions in the the plugin
131
*-----------------------------------------------------------------------------
137
: public ToolsPluginSignalCb
139
SignalCtx(const char* signame_, void* callback_, void* clientData_)
142
callback = callback_;
143
clientData = clientData_;
147
virtual ~ToolsPlugin() {};
149
virtual gboolean Initialize() = 0;
150
virtual gboolean Reset(gpointer src) = 0;
151
virtual void Shutdown(gpointer src) = 0;
152
virtual gboolean SetOption(gpointer src,
153
const std::string &option,
154
const std::string &value) = 0;
156
virtual std::vector<ToolsAppCapability> GetCapabilities(gboolean set) = 0;
157
virtual std::vector<RpcChannelCallback> GetRpcCallbackList() = 0;
158
virtual std::vector<ToolsPluginSignalCb> GetSignalRegistrations(ToolsPluginData*) const;
161
ToolsPlugin(const ToolsAppCtx* ctx) : mCtx(ctx) {}
164
static gboolean OnCReset(gpointer src, ToolsAppCtx* ctx, ToolsPluginData* pdata);
165
static void OnCShutdown(gpointer src, ToolsAppCtx* ctx, ToolsPluginData* pdata);
166
static GArray* OnCCapabilities(gpointer src, ToolsAppCtx* ctx, gboolean set,
167
ToolsPluginData* plugin);
168
static gboolean OnCSetOption(gpointer src, ToolsAppCtx* ctx, const gchar* option,
169
const gchar* value, ToolsPluginData* plugin);
171
const ToolsAppCtx* mCtx;
179
virtual gboolean Initialize();
181
virtual gboolean Reset(gpointer src) { return TRUE; }
182
virtual void Shutdown(gpointer src) {};
183
virtual gboolean SetOption(gpointer src,
184
const std::string &option,
185
const std::string &value)
190
virtual std::vector<ToolsAppCapability> GetCapabilities(gboolean set);
191
virtual std::vector<RpcChannelCallback> GetRpcCallbackList();
194
UnityPlugin(const ToolsAppCtx* ctx);
195
virtual ~UnityPlugin();
197
UnityUpdateChannel *mUnityUpdateChannel;
201
class UnityPluginWin32
205
UnityPluginWin32(const ToolsAppCtx* ctx);
206
virtual ~UnityPluginWin32();
208
virtual gboolean Initialize();
210
virtual std::vector<ToolsAppCapability> GetCapabilities(gboolean set);
211
virtual std::vector<ToolsPluginSignalCb> GetSignalRegistrations(ToolsPluginData*) const;
213
virtual DWORD OnServiceControl(gpointer src,
215
SERVICE_STATUS_HANDLE handle,
220
virtual void OnDesktopSwitch();
223
boost::shared_ptr<UnityPBRPCServer> mUnityPBRPCServer;
226
static DWORD OnCServiceControl(gpointer src, ToolsAppCtx* ctx,
227
SERVICE_STATUS_HANDLE handle, guint control,
228
guint evtType, gpointer evtData,
229
ToolsPluginData* data);
230
static void OnCDesktopSwitch(gpointer src, ToolsAppCtx* ctx, ToolsPluginData* plugin);
234
} /* namespace tools */ } /* namespace vmware */
236
#endif // _UNITY_PLUGIN_H_