00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _VMTOOLSAPP_H_
00020 #define _VMTOOLSAPP_H_
00021
00032 #include <glib.h>
00033 #if defined(G_PLATFORM_WIN32)
00034 # include <windows.h>
00035 # include <objbase.h>
00036 #endif
00037 #include "rpcChannel.h"
00038 #include "vmware/guestrpc/capabilities.h"
00039
00048 #define VMTOOLSAPP_ERROR(ctx, err) do { \
00049 ASSERT((err) != 0); \
00050 (ctx)->errorCode = (err); \
00051 g_main_loop_quit((ctx)->mainLoop); \
00052 } while (0)
00053
00054
00064 #define VMTOOLSAPP_ATTACH_SOURCE(ctx, src, cb, data, destroy) do { \
00065 GSource *__src = (src); \
00066 g_source_set_callback(__src, (GSourceFunc) (cb), (data), (destroy)); \
00067 g_source_attach(__src, g_main_loop_get_context((ctx)->mainLoop)); \
00068 } while (0)
00069
00070
00082 #define TOOLS_CORE_SIG_CAPABILITIES "tcs_capabilities"
00083
00091 #define TOOLS_CORE_SIG_CONF_RELOAD "tcs_conf_reload"
00092
00102 #define TOOLS_CORE_SIG_DUMP_STATE "tcs_dump_state"
00103
00111 #define TOOLS_CORE_SIG_RESET "tcs_reset"
00112
00125 #define TOOLS_CORE_SIG_SET_OPTION "tcs_set_option"
00126
00134 #define TOOLS_CORE_SIG_SHUTDOWN "tcs_shutdown"
00135
00136 #if defined(G_PLATFORM_WIN32)
00137
00146 #define TOOLS_CORE_SIG_SESSION_CHANGE "tcs_session_change"
00147 #endif
00148
00149
00159 typedef enum {
00160 TOOLS_CORE_API_V1 = 0x1,
00161 } ToolsCoreAPI;
00162
00163
00168 typedef struct ToolsAppCtx {
00170 ToolsCoreAPI version;
00172 const gchar *name;
00174 gboolean isVMware;
00176 int errorCode;
00178 GMainLoop *mainLoop;
00180 RpcChannel *rpc;
00182 GKeyFile *config;
00183 #if defined(G_PLATFORM_WIN32)
00184
00185 gboolean comInitialized;
00186 #else
00187
00188 int blockFD;
00190 const char **envp;
00191 #endif
00192
00198 gpointer serviceObj;
00199 } ToolsAppCtx;
00200
00201 #if defined(G_PLATFORM_WIN32)
00202
00209 static INLINE gboolean
00210 ToolsCore_InitializeCOM(ToolsAppCtx *ctx)
00211 {
00212 if (!ctx->comInitialized) {
00213 HRESULT ret = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
00214 ctx->comInitialized = SUCCEEDED(ret);
00215 if (!ctx->comInitialized) {
00216 g_log(ctx->name, G_LOG_LEVEL_WARNING,
00217 "COM initialization failed(0x%x)\n", ret);
00218 }
00219 }
00220 return ctx->comInitialized;
00221 }
00222 #endif
00223
00224
00225
00226
00228 typedef enum {
00229 TOOLS_CAP_OLD = 0,
00230 TOOLS_CAP_OLD_NOVAL = 1,
00231 TOOLS_CAP_NEW = 2
00232 } ToolsCapabilityType;
00233
00243 typedef struct ToolsAppCapability {
00245 ToolsCapabilityType type;
00250 gchar *name;
00255 GuestCapabilities index;
00257 guint value;
00258 } ToolsAppCapability;
00259
00260
00261
00262
00264 typedef enum {
00268 TOOLS_APP_GUESTRPC = 1,
00273 TOOLS_APP_SIGNALS = 2,
00279 TOOLS_APP_PROVIDER = 3,
00280 } ToolsAppType;
00281
00282
00291 typedef struct ToolsAppProvider {
00293 const gchar *name;
00300 ToolsAppType regType;
00302 size_t regSize;
00312 void (*activate)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, GError **err);
00321 void (*registerApp)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, gpointer reg);
00330 void (*shutdown)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov);
00343 void (*dumpState)(ToolsAppCtx *ctx, struct ToolsAppProvider *prov, gpointer reg);
00344 } ToolsAppProvider;
00345
00346
00357 typedef struct ToolsAppReg {
00358 ToolsAppType type;
00359 GArray *data;
00360 } ToolsAppReg;
00361
00362
00372 typedef struct ToolsPluginSignalCb {
00373 const gchar *signame;
00374 gpointer callback;
00375 gpointer clientData;
00376 } ToolsPluginSignalCb;
00377
00378
00387 typedef struct ToolsPluginData {
00389 char *name;
00391 GArray *regs;
00393 gpointer _private;
00394 } ToolsPluginData;
00395
00401 #if defined(G_PLATFORM_WIN32)
00402 # define TOOLS_MODULE_EXPORT __declspec(dllexport)
00403 #elif defined(GCC_EXPLICIT_EXPORT)
00404 # define TOOLS_MODULE_EXPORT __attribute__((visibility("default")))
00405 #else
00406 # define TOOLS_MODULE_EXPORT
00407 #endif
00408
00420 typedef ToolsPluginData *(*ToolsPluginOnLoad)(ToolsAppCtx *ctx);
00421
00424 #endif
00425