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
00147 #define TOOLS_CORE_SIG_SESSION_CHANGE "tcs_session_change"
00148
00157 #define TOOLS_CORE_SIG_PRESHUTDOWN "tcs_preshutdown"
00158
00159 #endif
00160
00161
00171 typedef enum {
00172 TOOLS_CORE_API_V1 = 0x1,
00173 } ToolsCoreAPI;
00174
00175
00180 typedef struct ToolsAppCtx {
00182 ToolsCoreAPI version;
00184 const gchar *name;
00186 gboolean isVMware;
00188 int errorCode;
00190 GMainLoop *mainLoop;
00192 RpcChannel *rpc;
00194 GKeyFile *config;
00195 #if defined(G_PLATFORM_WIN32)
00196
00197 gboolean comInitialized;
00198 #else
00199
00200 int blockFD;
00202 const char **envp;
00203 #endif
00204
00210 gpointer serviceObj;
00211 } ToolsAppCtx;
00212
00213 #if defined(G_PLATFORM_WIN32)
00214
00221 G_INLINE_FUNC gboolean
00222 ToolsCore_InitializeCOM(ToolsAppCtx *ctx)
00223 {
00224 if (!ctx->comInitialized) {
00225 HRESULT ret = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
00226 ctx->comInitialized = SUCCEEDED(ret);
00227 if (!ctx->comInitialized) {
00228 g_log(ctx->name, G_LOG_LEVEL_WARNING,
00229 "COM initialization failed(0x%x)\n", ret);
00230 }
00231 }
00232 return ctx->comInitialized;
00233 }
00234 #endif
00235
00236
00237
00238
00240 typedef enum {
00241 TOOLS_CAP_OLD = 0,
00242 TOOLS_CAP_OLD_NOVAL = 1,
00243 TOOLS_CAP_NEW = 2
00244 } ToolsCapabilityType;
00245
00255 typedef struct ToolsAppCapability {
00257 ToolsCapabilityType type;
00262 const gchar *name;
00267 GuestCapabilities index;
00269 guint value;
00270 } ToolsAppCapability;
00271
00272
00273
00274
00276 typedef enum {
00280 TOOLS_APP_GUESTRPC = 1,
00285 TOOLS_APP_SIGNALS = 2,
00291 TOOLS_APP_PROVIDER = 3,
00292 } ToolsAppType;
00293
00294
00303 typedef struct ToolsAppProvider {
00305 const gchar *name;
00312 ToolsAppType regType;
00314 size_t regSize;
00324 void (*activate)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, GError **err);
00333 void (*registerApp)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, gpointer reg);
00342 void (*shutdown)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov);
00355 void (*dumpState)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, gpointer reg);
00356 } ToolsAppProvider;
00357
00358
00369 typedef struct ToolsAppReg {
00370 ToolsAppType type;
00371 GArray *data;
00372 } ToolsAppReg;
00373
00374
00384 typedef struct ToolsPluginSignalCb {
00385 const gchar *signame;
00386 gpointer callback;
00387 gpointer clientData;
00388 } ToolsPluginSignalCb;
00389
00390
00399 typedef struct ToolsPluginData {
00401 char *name;
00403 GArray *regs;
00405 gpointer _private;
00406 } ToolsPluginData;
00407
00413 #if defined(G_PLATFORM_WIN32)
00414 # define TOOLS_MODULE_EXPORT VMTOOLS_EXTERN_C __declspec(dllexport)
00415 #elif defined(GCC_EXPLICIT_EXPORT)
00416 # define TOOLS_MODULE_EXPORT VMTOOLS_EXTERN_C __attribute__((visibility("default")))
00417 #else
00418 # define TOOLS_MODULE_EXPORT VMTOOLS_EXTERN_C
00419 #endif
00420
00432 typedef ToolsPluginData *(*ToolsPluginOnLoad)(ToolsAppCtx *ctx);
00433
00436 #endif
00437