]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
[unity win32] Turn off unity capability on session lock/disconnect.
authorVMware, Inc <>
Tue, 29 Mar 2011 20:02:07 +0000 (13:02 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 20:02:07 +0000 (13:02 -0700)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/unity/unityPlugin.cpp
open-vm-tools/services/plugins/unity/unityPlugin.h
open-vm-tools/services/plugins/unity/unityPluginEntry.cpp

index ddd58d2863e46d3a7cb1ab38c9bef7613dde7478..af47d36ae92cb13730925ba79d80ca87ba6611a2 100644 (file)
@@ -213,24 +213,19 @@ UnityPlugin::~UnityPlugin()
  */
 
 std::vector<ToolsAppCapability>
-UnityPlugin::GetCapabilities(gboolean set) // IN: Whether capabilities are being
-                                           // set or unset.
-                                           // XXX UNUSED  Fix this or mark as such.
+UnityPlugin::GetCapabilities(gboolean set) // IN
 {
-   std::vector<ToolsAppCapability> capsVector;
-
    /*
-    * We can't use UNITY_RPC_UNITY_CAP here because that define includes the
-    * tools.capability prefix which CoreServices will automatically prepend to the
-    * supplied name.
+    * Note that we can't use UNITY_RPC_UNITY_CAP here because it includes the
+    * "tools.capability" prefix which vmtoolsd will automatically prepend to the
+    * supplied capability name.
     */
-   capsVector.push_back(ToolsAppCapabilityOldEntry(UNITY_CAP_NAME, Unity_IsSupported() ? 1 : 0));
-   capsVector.push_back(ToolsAppCapabilityOldEntry("unity.taskbar",
-                                                   Unity_IsSupported() ? 1 : 0));
-
-   capsVector.push_back(ToolsAppCapabilityNewEntry(UNITY_CAP_STATUS_UNITY_ACTIVE, TRUE));
-
-   return capsVector;
+   Bool b = set ? Unity_IsSupported() : FALSE;
+   std::vector<ToolsAppCapability> caps;
+   caps.push_back(ToolsAppCapabilityOldEntry(UNITY_CAP_NAME, b));
+   caps.push_back(ToolsAppCapabilityOldEntry("unity.taskbar", b));
+   caps.push_back(ToolsAppCapabilityNewEntry(UNITY_CAP_STATUS_UNITY_ACTIVE, b));
+   return caps;
 }
 
 
index f90ceb9d434198762419d18ac3be250b22bd7b77..7254d38b61a8177425790a493b59c02b1f0fbcf2 100644 (file)
@@ -141,6 +141,17 @@ public:
    virtual gboolean SetOption(gpointer src,
                               const std::string &option,
                               const std::string &value) = 0;
+
+#ifdef WIN32
+   // Handler for the TOOLS_CORE_SIG_SERVICE_CONTROL signal.
+   virtual DWORD OnServiceControl(gpointer src,
+                                  ToolsAppCtx *ctx,
+                                  SERVICE_STATUS_HANDLE handle,
+                                  guint control,
+                                  guint evtType,
+                                  gpointer evtData) = 0;
+#endif
+
    virtual std::vector<ToolsAppCapability> GetCapabilities(gboolean set) = 0;
    virtual std::vector<RpcChannelCallback> GetRpcCallbackList() = 0;
 
@@ -167,6 +178,7 @@ public:
    {
       return FALSE;
    }
+
    virtual std::vector<ToolsAppCapability> GetCapabilities(gboolean set);
    virtual std::vector<RpcChannelCallback> GetRpcCallbackList();
 
@@ -187,6 +199,13 @@ public:
    virtual std::vector<ToolsAppCapability> GetCapabilities(gboolean set);
    virtual void SessionChange(gpointer src, DWORD code, DWORD id) {};
 
+   virtual DWORD OnServiceControl(gpointer src,
+                                  ToolsAppCtx *ctx,
+                                  SERVICE_STATUS_HANDLE handle,
+                                  guint control,
+                                  guint evtType,
+                                  gpointer evtData);
+
 protected:
    boost::shared_ptr<UnityPBRPCServer> mUnityPBRPCServer;
 };
index c6d019e13eac946a335fa1b8a7a9866e861620c3..abeb44a1a632b546eb0cf4d2c01fe970e372afc7 100644 (file)
@@ -41,7 +41,6 @@ extern "C" {
 
 using namespace vmware::tools;
 
-
 /*
  *-----------------------------------------------------------------------------
  *
@@ -170,11 +169,42 @@ UnityPluginSetOption(gpointer src,            // IN: Event source.
    return pluginInstance->SetOption(src, std::string(option), std::string(value));
 }
 
+#ifdef WIN32
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * UnityPluginServiceControl --
+ *
+ *      C thunk for TOOLS_CORE_SIG_SERVICE_CONTROL messages.
+ *
+ * Results:
+ *      Returns the result of calling OnServiceControl on the plugin object.
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+DWORD
+UnityPluginServiceControl(gpointer src,                 // IN
+                          ToolsAppCtx *ctx,             // IN
+                          SERVICE_STATUS_HANDLE handle, // IN
+                          guint control,                // IN
+                          guint evtType,                // IN
+                          gpointer evtData,             // IN
+                          ToolsPluginData *data)        // IN
+{
+   ToolsPlugin *p = reinterpret_cast<ToolsPlugin*>(data->_private);
+   ASSERT(p);
+   return p->OnServiceControl(src, ctx, handle, control, evtType, evtData);
+}
+#endif
 
 /*
  *-----------------------------------------------------------------------------
  *
- * ToolsOnLoad` --
+ * ToolsOnLoad --
  *
  *      Plugin entry point.  Returns the registration data.
  *
@@ -202,6 +232,9 @@ ToolsOnLoad(ToolsAppCtx *ctx)           // IN: The app context.
          { TOOLS_CORE_SIG_SHUTDOWN, (void *) UnityPluginShutdown, &regData },
          { TOOLS_CORE_SIG_CAPABILITIES, (void *) UnityPluginCapabilities, &regData },
          { TOOLS_CORE_SIG_SET_OPTION, (void *) UnityPluginSetOption, &regData },
+#ifdef WIN32
+         { TOOLS_CORE_SIG_SERVICE_CONTROL, (void *) UnityPluginServiceControl, &regData },
+#endif
       };
 
       ToolsPlugin *pluginInstance = NULL;