00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _VMWARE_TOOLS_PLUGIN_H_
00020 #define _VMWARE_TOOLS_PLUGIN_H_
00021
00032 #include <glib.h>
00033 #if defined(G_PLATFORM_WIN32)
00034 # include <windows.h>
00035 # include <objbase.h>
00036 #endif
00037 #include "vmware/guestrpc/capabilities.h"
00038 #include "vmware/tools/guestrpc.h"
00039 #include "vmware/tools/utils.h"
00040
00049 #define VMTOOLSAPP_ERROR(ctx, err) do { \
00050 ASSERT((err) != 0); \
00051 (ctx)->errorCode = (err); \
00052 g_main_loop_quit((ctx)->mainLoop); \
00053 } while (0)
00054
00055
00065 #define VMTOOLSAPP_ATTACH_SOURCE(ctx, src, cb, data, destroy) do { \
00066 GSource *__src = (src); \
00067 g_source_set_callback(__src, (GSourceFunc) (cb), (data), (destroy)); \
00068 g_source_attach(__src, g_main_loop_get_context((ctx)->mainLoop)); \
00069 } while (0)
00070
00071
00083 #define TOOLS_CORE_SIG_CAPABILITIES "tcs_capabilities"
00084
00092 #define TOOLS_CORE_SIG_CONF_RELOAD "tcs_conf_reload"
00093
00103 #define TOOLS_CORE_SIG_DUMP_STATE "tcs_dump_state"
00104
00112 #define TOOLS_CORE_SIG_RESET "tcs_reset"
00113
00126 #define TOOLS_CORE_SIG_SET_OPTION "tcs_set_option"
00127
00135 #define TOOLS_CORE_SIG_SHUTDOWN "tcs_shutdown"
00136
00137 #if defined(G_PLATFORM_WIN32)
00138
00165 #define TOOLS_CORE_SIG_SERVICE_CONTROL "tcs_service_control"
00166
00167 #endif
00168
00169
00179 typedef enum {
00180 TOOLS_CORE_API_V1 = 0x1,
00181 } ToolsCoreAPI;
00182
00183
00188 typedef struct ToolsAppCtx {
00190 ToolsCoreAPI version;
00192 const gchar *name;
00194 gboolean isVMware;
00196 int errorCode;
00198 GMainLoop *mainLoop;
00200 RpcChannel *rpc;
00202 GKeyFile *config;
00203 #if defined(G_PLATFORM_WIN32)
00204
00205 gboolean comInitialized;
00206 #else
00207
00208 int blockFD;
00210 const char **envp;
00211 #endif
00212
00218 gpointer serviceObj;
00219 } ToolsAppCtx;
00220
00221 #if defined(G_PLATFORM_WIN32)
00222
00229 G_INLINE_FUNC gboolean
00230 ToolsCore_InitializeCOM(ToolsAppCtx *ctx)
00231 {
00232 if (!ctx->comInitialized) {
00233 HRESULT ret = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
00234 ctx->comInitialized = SUCCEEDED(ret);
00235 if (!ctx->comInitialized) {
00236 g_log(ctx->name, G_LOG_LEVEL_WARNING,
00237 "COM initialization failed(0x%x)\n", ret);
00238 }
00239 }
00240 return ctx->comInitialized;
00241 }
00242 #endif
00243
00244
00245
00246
00248 typedef enum {
00249 TOOLS_CAP_OLD = 0,
00250 TOOLS_CAP_OLD_NOVAL = 1,
00251 TOOLS_CAP_NEW = 2
00252 } ToolsCapabilityType;
00253
00263 typedef struct ToolsAppCapability {
00265 ToolsCapabilityType type;
00270 const gchar *name;
00275 GuestCapabilities index;
00277 guint value;
00278 } ToolsAppCapability;
00279
00280
00281
00282
00284 typedef enum {
00288 TOOLS_APP_GUESTRPC = 1,
00293 TOOLS_APP_SIGNALS = 2,
00299 TOOLS_APP_PROVIDER = 3,
00300 } ToolsAppType;
00301
00302
00311 typedef struct ToolsAppProvider {
00313 const gchar *name;
00320 ToolsAppType regType;
00322 size_t regSize;
00332 void (*activate)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, GError **err);
00343 gboolean (*registerApp)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, gpointer reg);
00352 void (*shutdown)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov);
00365 void (*dumpState)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, gpointer reg);
00366 } ToolsAppProvider;
00367
00368
00379 typedef struct ToolsAppReg {
00380 ToolsAppType type;
00381 GArray *data;
00382 } ToolsAppReg;
00383
00384
00394 typedef struct ToolsPluginSignalCb {
00395 const gchar *signame;
00396 gpointer callback;
00397 gpointer clientData;
00398 } ToolsPluginSignalCb;
00399
00400
00415 typedef struct ToolsPluginData {
00417 char *name;
00422 GArray *regs;
00453 gboolean (*errorCb)(ToolsAppCtx *ctx,
00454 ToolsAppType type,
00455 gpointer data,
00456 struct ToolsPluginData *plugin);
00458 gpointer _private;
00459 } ToolsPluginData;
00460
00466 #if defined(G_PLATFORM_WIN32)
00467 # define TOOLS_MODULE_EXPORT VMTOOLS_EXTERN_C __declspec(dllexport)
00468 #elif defined(GCC_EXPLICIT_EXPORT)
00469 # define TOOLS_MODULE_EXPORT VMTOOLS_EXTERN_C __attribute__((visibility("default")))
00470 #else
00471 # define TOOLS_MODULE_EXPORT VMTOOLS_EXTERN_C
00472 #endif
00473
00485 typedef ToolsPluginData *(*ToolsPluginOnLoad)(ToolsAppCtx *ctx);
00486
00489 #endif
00490