[1/2] msi: Implement MsiSetMode.

Hans Leidekker hans at codeweavers.com
Thu Feb 18 05:46:58 CST 2010


---
 dlls/msi/install.c          |   48 +++++++++++++++++++++++++++++++++++++++++-
 dlls/msi/msiserver.idl      |    1 +
 dlls/msi/package.c          |    8 +++++++
 dlls/msi/tests/automation.c |   15 +++++++++++++
 4 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index b1d741a..7a71867 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -719,8 +719,52 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode)
  */
 UINT WINAPI MsiSetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode, BOOL fState)
 {
-    FIXME("%d %d %d\n", hInstall, iRunMode, fState);
-    return ERROR_SUCCESS;
+    MSIPACKAGE *package;
+    UINT r;
+
+    TRACE("%d %d %d\n", hInstall, iRunMode, fState);
+
+    package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
+    if (!package)
+    {
+        HRESULT hr;
+        IWineMsiRemotePackage *remote_package;
+
+        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
+        if (!remote_package)
+            return FALSE;
+
+        hr = IWineMsiRemotePackage_SetMode( remote_package, iRunMode, fState );
+        IWineMsiRemotePackage_Release( remote_package );
+
+        if (FAILED(hr))
+        {
+            if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
+                return HRESULT_CODE(hr);
+
+            return ERROR_FUNCTION_FAILED;
+        }
+
+        return ERROR_SUCCESS;
+    }
+
+    switch (iRunMode)
+    {
+    case MSIRUNMODE_REBOOTATEND:
+        package->need_reboot = 1;
+        r = ERROR_SUCCESS;
+        break;
+
+    case MSIRUNMODE_REBOOTNOW:
+        FIXME("unimplemented run mode\n");
+        r = ERROR_FUNCTION_FAILED;
+        break;
+
+    default:
+        r = ERROR_ACCESS_DENIED;
+    }
+
+    return r;
 }
 
 /***********************************************************************
diff --git a/dlls/msi/msiserver.idl b/dlls/msi/msiserver.idl
index 8e49368..25210fe 100644
--- a/dlls/msi/msiserver.idl
+++ b/dlls/msi/msiserver.idl
@@ -63,6 +63,7 @@ interface IWineMsiRemotePackage : IUnknown
     HRESULT SetTargetPath( [in] BSTR folder, [in] BSTR value );
     HRESULT GetSourcePath( [in] BSTR folder, [out] BSTR *value, [out] DWORD *size );
     HRESULT GetMode( [in] MSIRUNMODE mode, [out] BOOL *ret );
+    HRESULT SetMode( [in] MSIRUNMODE mode, [in] BOOL state );
     HRESULT GetFeatureState( [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
     HRESULT SetFeatureState( [in] BSTR feature, [in] INSTALLSTATE state );
     HRESULT GetComponentState( [in] BSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 53804e2..ad6d4c6 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -2104,6 +2104,13 @@ static HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode
     return S_OK;
 }
 
+static HRESULT WINAPI mrp_SetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL state )
+{
+    msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
+    UINT r = MsiSetMode(This->package, mode, state);
+    return HRESULT_FROM_WIN32(r);
+}
+
 static HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature,
                                     INSTALLSTATE *installed, INSTALLSTATE *action )
 {
@@ -2196,6 +2203,7 @@ static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl =
     mrp_SetTargetPath,
     mrp_GetSourcePath,
     mrp_GetMode,
+    mrp_SetMode,
     mrp_GetFeatureState,
     mrp_SetFeatureState,
     mrp_GetComponentState,
diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c
index 8a0eede..cab6cb7 100644
--- a/dlls/msi/tests/automation.c
+++ b/dlls/msi/tests/automation.c
@@ -1865,6 +1865,10 @@ static void test_Session(IDispatch *pSession)
     ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr);
     todo_wine ok(!bool, "Reboot at end session mode is %d\n", bool);
 
+    hr = Session_ModeGet(pSession, MSIRUNMODE_MAINTENANCE, &bool);
+    ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr);
+    todo_wine ok(!bool, "Maintenance mode is %d\n", bool);
+
     /* Session::Mode, put */
     hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, TRUE);
     ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
@@ -1874,6 +1878,17 @@ static void test_Session(IDispatch *pSession)
     hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, FALSE);  /* set it again so we don't reboot */
     ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
 
+    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, TRUE);
+    todo_wine ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
+    hr = Session_ModeGet(pSession, MSIRUNMODE_REBOOTNOW, &bool);
+    ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr);
+    ok(bool, "Reboot now mode is %d, expected 1\n", bool);
+    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, FALSE);  /* set it again so we don't reboot */
+    todo_wine ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
+
+    hr = Session_ModePut(pSession, MSIRUNMODE_MAINTENANCE, TRUE);
+    ok(hr == DISP_E_EXCEPTION, "Session_ModePut failed, hresult 0x%08x\n", hr);
+
     /* Session::Database, get */
     hr = Session_Database(pSession, &pDatabase);
     ok(hr == S_OK, "Session_Database failed, hresult 0x%08x\n", hr);
-- 
1.6.3.3





More information about the wine-patches mailing list