From: VMware, Inc <> Date: Mon, 22 Mar 2010 22:11:21 +0000 (-0700) Subject: Internal branch sync. Included in this change: X-Git-Tag: 2010.03.20-243334~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d704f64487f28b0312ddf9b8aad02acb065554da;p=thirdparty%2Fopen-vm-tools.git Internal branch sync. Included in this change: . Allow the host to configure unity behaviour in the guest. . Avoid warnings when compiling with gcc 4.2. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/guestRpc/unity.x b/open-vm-tools/lib/guestRpc/unity.x index 95ee19c29..5d35e6302 100644 --- a/open-vm-tools/lib/guestRpc/unity.x +++ b/open-vm-tools/lib/guestRpc/unity.x @@ -29,8 +29,8 @@ /* * Enumerates the different versions of the messages. */ -enum UnityEnterVersion { - UNITY_ENTER_V1 = 1 +enum UnityOptionsVersion { + UNITY_OPTIONS_V1 = 1 }; /* @@ -38,18 +38,20 @@ enum UnityEnterVersion { * Unity mode. By default all these features are disabled. */ enum UnityFeatures { - UNITY_ADD_HIDDEN_WINDOWS_TO_TRACKER = 1 + UNITY_ADD_HIDDEN_WINDOWS_TO_TRACKER = 1, + UNITY_INTERLOCK_MINIMIZE_OPERATION = 2, + UNITY_SEND_WINDOW_CONTENTS = 4 }; /* * The structure used for version 1 of the message. */ -struct UnityEnterV1 { +struct UnityOptionsV1 { int featureMask; }; /* - * This defines the protocol for a 'unityEnter' message. + * This defines the protocol for a 'unityOptions' message. * * The union allows us to introduce new versions of the protocol later by * creating new values in the enumeration, without having to change much of @@ -58,9 +60,9 @@ struct UnityEnterV1 { * Since the union doesn't have a default case, de-serialization will fail if * an unknown version is provided on the wire. */ -union UnityEnter switch (UnityEnterVersion ver) { -case UNITY_ENTER_V1: - struct UnityEnterV1 *unityEnterV1; +union UnityOptions switch (UnityOptionsVersion ver) { +case UNITY_OPTIONS_V1: + struct UnityOptionsV1 *unityOptionsV1; }; diff --git a/open-vm-tools/lib/include/unityCommon.h b/open-vm-tools/lib/include/unityCommon.h index 49117fe7b..a30848550 100644 --- a/open-vm-tools/lib/include/unityCommon.h +++ b/open-vm-tools/lib/include/unityCommon.h @@ -230,6 +230,7 @@ #define UNITY_RPC_DESKTOP_CONFIG_SET "unity.desktop.config.set" #define UNITY_RPC_DESKTOP_ACTIVE_SET "unity.desktop.active.set" #define UNITY_RPC_WINDOW_DESKTOP_SET "unity.window.desktop.set" +#define UNITY_RPC_SET_OPTIONS "unity.set.options" #define UNITY_RPC_WINDOW_STICK "unity.window.stick" #define UNITY_RPC_WINDOW_UNSTICK "unity.window.unstick" #define UNITY_RPC_WINDOW_CONTENTS_REQUEST "unity.window.contents.request" @@ -756,6 +757,14 @@ desktop where the upper right {1,2} is the currently active desktop. @param[in] offset Offset into desktop configuration, as defined by @ref UNITY_RPC_DESKTOP_CONFIG_SET, 0 or greater. + @def UNITY_RPC_SET_OPTIONS + @brief Set optional behaviour for unity mode in the guest. + @code + UNITY_RPC_SET_OPTIONS + @endcode + @param[in] XDR encoded options mask. + @note This must be called before entering Unity mode - setting the options + after Unity mode has begun will result in undefined behaviour. @def UNITY_RPC_WINDOW_STICK @brief "Stick" a window to the screen. diff --git a/open-vm-tools/lib/unity/unity.c b/open-vm-tools/lib/unity/unity.c index 15fe3835c..21192b7ed 100644 --- a/open-vm-tools/lib/unity/unity.c +++ b/open-vm-tools/lib/unity/unity.c @@ -52,6 +52,7 @@ #include "dynxdr.h" #include "guestrpc/unity.h" #include "guestrpc/unityActive.h" +#include "guestrpc/unity.h" #include "appUtil.h" #include "xdrutil.h" #include @@ -64,6 +65,7 @@ typedef struct UnityState { UnityWindowTracker tracker; Bool forceEnable; Bool isEnabled; + uint32 currentOptions; // Last feature mask received via 'set.options' UnityVirtualDesktopArray virtDesktopArray; // Virtual desktop configuration UnityUpdateChannel updateChannel; // Unity update transmission channel. UnityPlatform *up; // Platform-specific state @@ -152,6 +154,15 @@ static Bool UnityTcloSetWindowDesktop(char const **result, size_t argsSize, void *clientData); +static void UnitySetAddHiddenWindows(Bool enabled); +static void UnitySetInterlockMinimizeOperation(Bool enabled); +static void UnitySetSendWindowContents(Bool enabled); + +/* + * Wrapper function for the "unity.set.options" RPC. + */ +static Bool UnityTcloSetUnityOptions(RpcInData *data); + /* * Wrapper function for the "unity.window.contents.request" RPC. */ @@ -209,6 +220,23 @@ static UnityCommandElem unityCommandTable[] = { { NULL, NULL } }; +typedef struct { + uint32 featureBit; + void (*setter)(Bool enabled); +} UnityFeatureSetter; + +/* + * Dispatch table for each unity option and a specific function to handle enabling + * or disabling the option. The function is called with an enable (TRUE) bool value. + */ +static UnityFeatureSetter unityFeatureTable[] = { + { UNITY_ADD_HIDDEN_WINDOWS_TO_TRACKER, UnitySetAddHiddenWindows }, + { UNITY_INTERLOCK_MINIMIZE_OPERATION, UnitySetInterlockMinimizeOperation }, + { UNITY_SEND_WINDOW_CONTENTS, UnitySetSendWindowContents }, + /* Add more Unity Feature Setters above this. */ + {0, NULL} +}; + /* * XXX: * According to Adar: @@ -455,6 +483,9 @@ Unity_InitBackdoor(struct RpcIn *rpcIn) // IN RpcIn_RegisterCallback(rpcIn, UNITY_RPC_WINDOW_DESKTOP_SET, UnityTcloSetWindowDesktop, NULL); + RpcIn_RegisterCallbackEx(rpcIn, UNITY_RPC_SET_OPTIONS, + UnityTcloSetUnityOptions, NULL); + RpcIn_RegisterCallbackEx(rpcIn, UNITY_RPC_WINDOW_CONTENTS_REQUEST, UnityTcloRequestWindowContents, NULL); @@ -2018,6 +2049,84 @@ error: } +/* + *---------------------------------------------------------------------------- + * + * UnityTcloSetUnityOptions -- + * + * Set the Unity options - must be be called before entering Unity mode. + * + * Results: + * TRUE if RPC was succesfully handled. + * FALSE otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +Bool +UnityTcloSetUnityOptions(RpcInData *data) +{ + Bool ret = TRUE; + UnityOptions optionsMsg; + int featureIndex = 0; + uint32 featuresChanged; + + memset(&optionsMsg, 0, sizeof optionsMsg); + + /* Check our arguments. */ + ASSERT(data); + ASSERT(data->name); + ASSERT(data->args); + + if (!(data && data->name && data->args)) { + Debug("%s: Invalid arguments.\n", __FUNCTION__); + ret = RPCIN_SETRETVALS(data, "Invalid arguments.", FALSE); + goto exit; + } + + Debug("%s: Got RPC, name: \"%s\", argument length: %"FMTSZ"u.\n", + __FUNCTION__, data->name, data->argsSize); + + /* + * Deserialize the XDR data. Note that the data begins with args + 1 since + * there is a space between the RPC name and the XDR serialization. + */ + if (!XdrUtil_Deserialize((char *)data->args + 1, data->argsSize - 1, + xdr_UnityOptions, &optionsMsg)) { + Debug("%s: Failed to deserialize data\n", __FUNCTION__); + ret = RPCIN_SETRETVALS(data, "Failed to deserialize data.", FALSE); + goto exit; + } + + /* + * For each potential feature bit XOR the current mask with the newly + * specified set, then if the bit has changed call the specific setter + * function with TRUE/FALSE according to the new state of the bit. + */ + featuresChanged = optionsMsg.UnityOptions_u.unityOptionsV1->featureMask ^ + unity.currentOptions; + while (unityFeatureTable[featureIndex].featureBit != 0) { + if (featuresChanged & unityFeatureTable[featureIndex].featureBit) { + unityFeatureTable[featureIndex].setter( + optionsMsg.UnityOptions_u.unityOptionsV1->featureMask & + unityFeatureTable[featureIndex].featureBit); + } + featureIndex++; + } + + ret = RPCIN_SETRETVALS(data, + "", + TRUE); +exit: + VMX_XDR_FREE(xdr_UnityOptions, &optionsMsg); + + return ret; +} + + /* *---------------------------------------------------------------------------- * @@ -2094,6 +2203,7 @@ exit: return ret; } + /* *---------------------------------------------------------------------------- * @@ -2152,7 +2262,7 @@ out: /* - *------------------------------------------------------------------------------ + *---------------------------------------------------------------------------- * * UnitySendWindowContents -- * @@ -2233,6 +2343,109 @@ exit: } +/* + *---------------------------------------------------------------------------- + * + * UnitySetAddHiddenWindows -- + * + * Set (or unset) whether hidden windows should be added to the tracker. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +void +UnitySetAddHiddenWindows(Bool enabled) +{ + /* + * Should we add hidden windows to the tracker (the host will use the trackers + * attribute field to display hidden windows in the appropriate manner.) + */ + if (enabled) { + Debug("%s: Adding hidden windows to tracker\n", __FUNCTION__); + } else { + Debug("%s: Do not add hidden windows to tracker\n", __FUNCTION__); + } +} + + +/* + *---------------------------------------------------------------------------- + * + * UnitySetInterlockMinimizeOperation -- + * + * Set (or unset) whether window operations should be denied/delayed and + * relayed to the host for later confirmation. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +void +UnitySetInterlockMinimizeOperation(Bool enabled) +{ + /* + * Should we interlock operations through the host. For example: instead of + * allowing minimize to occur immediately in the guest should we prevent the + * minimize of a window in the guest, then relay the minimize to the host and wait + * for the hosts confirmation before actually minimizing the window in the guest. + */ + if (enabled) { + Debug("%s: Interlocking minimize operations through the host\n", + __FUNCTION__); + } else { + Debug("%s: Do not interlock minimize operations through the host\n", + __FUNCTION__); + } +} + + +/* + *---------------------------------------------------------------------------- + * + * UnitySetSendWindowContents -- + * + * Set (or unset) whether window contents should be sent to the host. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +void +UnitySetSendWindowContents(Bool enabled) +{ + /* + * Is the host prepared to receive scraped window contents at any time - even though + * it may not have previously requested the window contents. Explicit requests from + * the host will always be honored - this flag determines whether the guest will send + * the window contents directly after a qualifying operation (like changes in the + * z-order of a window). + */ + if (enabled) { + Debug("%s: Sending window contents to the host on appropriate events\n", + __FUNCTION__); + } else { + Debug("%s: Do not send window contents to the host on appropriate events\n", + __FUNCTION__); + } +} + + /* *------------------------------------------------------------------------------ * diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 2bfa8a18d..e402b1dd5 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -1045,14 +1045,14 @@ NicInfoV3ToV2(const NicInfoV3 *infoV3) nicList = Util_SafeCalloc(sizeof *nicList, 1); - XDRUTIL_ARRAYAPPEND(nicList, nics, infoV3->nics.nics_len); + (void)XDRUTIL_ARRAYAPPEND(nicList, nics, infoV3->nics.nics_len); XDRUTIL_FOREACH(i, infoV3, nics) { GuestNicV3 *nic = XDRUTIL_GETITEM(infoV3, nics, i); GuestNic *oldNic = XDRUTIL_GETITEM(nicList, nics, i); Str_Strcpy(oldNic->macAddress, nic->macAddress, sizeof oldNic->macAddress); - XDRUTIL_ARRAYAPPEND(oldNic, ips, nic->ips.ips_len); + (void)XDRUTIL_ARRAYAPPEND(oldNic, ips, nic->ips.ips_len); XDRUTIL_FOREACH(j, nic, ips) { IpAddressEntry *ipEntry = XDRUTIL_GETITEM(nic, ips, j);