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 "guestCaps.h"
00038 #include "rpcChannel.h"
00039
00048 #define VMTOOLSAPP_ERROR(ctx, err) do { \
00049 g_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
00093 #define TOOLS_CORE_SIG_DUMP_STATE "tcs_dump_state"
00094
00102 #define TOOLS_CORE_SIG_RESET "tcs_reset"
00103
00116 #define TOOLS_CORE_SIG_SET_OPTION "tcs_set_option"
00117
00125 #define TOOLS_CORE_SIG_SHUTDOWN "tcs_shutdown"
00126
00127 #if defined(G_PLATFORM_WIN32)
00128
00137 #define TOOLS_CORE_SIG_SESSION_CHANGE "tcs_session_change"
00138 #endif
00139
00140
00145 typedef struct ToolsAppCtx {
00147 const gchar *name;
00149 gboolean isVMware;
00151 int errorCode;
00153 GMainLoop *mainLoop;
00155 RpcChannel *rpc;
00157 GKeyFile *config;
00158 #if defined(G_PLATFORM_WIN32)
00159
00160 gboolean comInitialized;
00161 #else
00162
00163 int blockFD;
00164 #endif
00165
00171 gpointer serviceObj;
00172 } ToolsAppCtx;
00173
00174 #if defined(G_PLATFORM_WIN32)
00175
00182 static INLINE gboolean
00183 ToolsCore_InitializeCOM(ToolsAppCtx *ctx)
00184 {
00185 if (!ctx->comInitialized) {
00186 HRESULT ret = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
00187 ctx->comInitialized = SUCCEEDED(ret);
00188 if (!ctx->comInitialized) {
00189 g_log(ctx->name, G_LOG_LEVEL_WARNING,
00190 "COM initialization failed(0x%x)\n", ret);
00191 }
00192 }
00193 return ctx->comInitialized;
00194 }
00195 #endif
00196
00197
00198
00199
00201 typedef enum {
00202 TOOLS_CAP_OLD = 0,
00203 TOOLS_CAP_OLD_NOVAL = 1,
00204 TOOLS_CAP_NEW = 2
00205 } ToolsCapabilityType;
00206
00216 typedef struct ToolsAppCapability {
00218 ToolsCapabilityType type;
00223 gchar *name;
00228 GuestCapabilities index;
00230 guint value;
00231 } ToolsAppCapability;
00232
00233
00234
00235
00237 typedef enum {
00241 TOOLS_APP_GUESTRPC = 1,
00246 TOOLS_APP_SIGNALS = 2
00247 } ToolsAppType;
00248
00249
00260 typedef struct ToolsAppReg {
00261 ToolsAppType type;
00262 GArray *data;
00263 } ToolsAppReg;
00264
00265
00275 typedef struct ToolsPluginSignalCb {
00276 const gchar *signame;
00277 gpointer callback;
00278 gpointer clientData;
00279 } ToolsPluginSignalCb;
00280
00281
00290 typedef struct ToolsPluginData {
00292 char *name;
00294 GArray *regs;
00296 gpointer _private;
00297 } ToolsPluginData;
00298
00304 #if defined(G_PLATFORM_WIN32)
00305 # define TOOLS_MODULE_EXPORT __declspec(dllexport)
00306 #elif defined(GCC_EXPLICIT_EXPORT)
00307 # define TOOLS_MODULE_EXPORT __attribute__((visibility("default")))
00308 #else
00309 # define TOOLS_MODULE_EXPORT
00310 #endif
00311
00323 typedef ToolsPluginData *(*ToolsPluginOnLoad)(ToolsAppCtx *ctx);
00324
00327 #endif
00328