From 5dfa44de4ac290069562487db45dee9108999527 Mon Sep 17 00:00:00 2001 From: Misha Koshelev Date: Sat, 3 Mar 2007 16:50:09 -0600 Subject: msi: automation: Implement basic Installer object and expose it. --- dlls/msi/automation.c | 59 +++++++++++++++++++++++++++++++++++++++++++ dlls/msi/msi_main.c | 6 ---- dlls/msi/msipriv.h | 1 + dlls/msi/tests/automation.c | 16 ++++++------ 4 files changed, 68 insertions(+), 14 deletions(-) diff --git a/dlls/msi/automation.c b/dlls/msi/automation.c index c8b7a93..ae2c4c3 100644 --- a/dlls/msi/automation.c +++ b/dlls/msi/automation.c @@ -953,8 +953,67 @@ HRESULT WINAPI SessionImpl_Invoke( return S_OK; } +HRESULT WINAPI InstallerImpl_Invoke( + AutomationObject* This, + DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS* pDispParams, + VARIANT* pVarResult, + EXCEPINFO* pExcepInfo, + UINT* puArgErr) +{ + MSIHANDLE msiHandle; + IDispatch *pDispatch = NULL; + UINT ret; + VARIANTARG varg0, varg1; + HRESULT hr; + + VariantInit(&varg0); + VariantInit(&varg1); + + switch (dispIdMember) + { + case DISPID_INSTALLER_OPENPACKAGE: + if (wFlags & DISPATCH_METHOD) + { + hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr); + if (FAILED(hr)) return hr; + hr = DispGetParam(pDispParams, 1, VT_I4, &varg1, puArgErr); + if (FAILED(hr)) return hr; + V_VT(pVarResult) = VT_DISPATCH; + if ((ret = MsiOpenPackageExW(V_BSTR(&varg0), V_I4(&varg1), &msiHandle)) == ERROR_SUCCESS) + { + if (SUCCEEDED(create_automation_object(msiHandle, NULL, (LPVOID)&pDispatch, &DIID_Session, SessionImpl_Invoke))) + { + IDispatch_AddRef(pDispatch); + V_DISPATCH(pVarResult) = pDispatch; + } + } + else + { + ERR("MsiOpenPackageEx returned %d\n", ret); + return DISP_E_EXCEPTION; + } + } + break; + + default: + return DISP_E_MEMBERNOTFOUND; + } + + return S_OK; +} + /* Wrapper around create_automation_object to create a session object. */ HRESULT create_session(MSIHANDLE msiHandle, IDispatch **pDispatch) { return create_automation_object(msiHandle, NULL, (LPVOID)pDispatch, &DIID_Session, SessionImpl_Invoke); } + +/* Wrapper around create_automation_object to create an installer object. */ +HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj) +{ + return create_automation_object(0, pOuter, ppObj, &DIID_Installer, InstallerImpl_Invoke); +} diff --git a/dlls/msi/msi_main.c b/dlls/msi/msi_main.c index a3dac7f..402e173 100644 --- a/dlls/msi/msi_main.c +++ b/dlls/msi/msi_main.c @@ -115,12 +115,6 @@ ITypeLib *get_msi_typelib( LPWSTR *path return msi_typelib; } -static HRESULT create_msiserver( IUnknown *pOuter, LPVOID *ppObj ) -{ - FIXME("\n"); - return E_FAIL; -} - typedef struct tagIClassFactoryImpl { const IClassFactoryVtbl *lpVtbl; HRESULT (*create_object)( IUnknown*, LPVOID* ); diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 57f2531..94c1ade 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -790,6 +790,7 @@ extern VOID ControlEvent_UnSubscribeToEv /* OLE automation */ extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch **pDispatch); +extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj); extern HRESULT WINAPI LoadTypeInfo(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid); /* Scripting */ diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c index 969f275..3178b2e 100644 --- a/dlls/msi/tests/automation.c +++ b/dlls/msi/tests/automation.c @@ -355,14 +355,14 @@ static void test_dispatch() /* Try with NULL params */ hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL); - ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08lx\n", (unsigned long int)hr); + todo_wine ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08lx\n", (unsigned long int)hr); /* Try one empty parameter */ dispparams.rgvarg = vararg; dispparams.cArgs = 1; VariantInit(&vararg[0]); hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL); - ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08lx\n", (unsigned long int)hr); + todo_wine ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08lx\n", (unsigned long int)hr); /* Try one parameter, function requires two */ VariantInit(&vararg[0]); @@ -815,16 +815,16 @@ static void test_Session(IDispatch *pSes /* Session::Mode, get */ hr = Session_ModeGet(pSession, MSIRUNMODE_REBOOTATEND, &bool); ok(SUCCEEDED(hr), "Session_ModeGet failed, hresult 0x%08lx\n", (unsigned long int)hr); - ok(!bool, "Reboot at end session mode is %d\n", bool); + todo_wine ok(!bool, "Reboot at end session mode is %d\n", bool); /* Session::Mode, put */ hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, TRUE); - ok(SUCCEEDED(hr), "Session_ModePut failed, hresult 0x%08lx\n", (unsigned long int)hr); + todo_wine ok(SUCCEEDED(hr), "Session_ModePut failed, hresult 0x%08lx\n", (unsigned long int)hr); hr = Session_ModeGet(pSession, MSIRUNMODE_REBOOTATEND, &bool); ok(SUCCEEDED(hr), "Session_ModeGet failed, hresult 0x%08lx\n", (unsigned long int)hr); ok(bool, "Reboot at end session mode is %d, expected 1\n", bool); hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, FALSE); /* set it again so we don't reboot */ - ok(SUCCEEDED(hr), "Session_ModePut failed, hresult 0x%08lx\n", (unsigned long int)hr); + todo_wine ok(SUCCEEDED(hr), "Session_ModePut failed, hresult 0x%08lx\n", (unsigned long int)hr); /* Session::Database, get */ hr = Session_Database(pSession, &pDatabase); @@ -911,15 +911,15 @@ START_TEST(automation) hr = CLSIDFromProgID(szProgId, &clsid); ok (SUCCEEDED(hr), "CLSIDFromProgID returned 0x%08lx\n", (unsigned long int)hr); hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk); - todo_wine ok(SUCCEEDED(hr), "CoCreateInstance returned 0x%08lx\n", (unsigned long int)hr); + ok(SUCCEEDED(hr), "CoCreateInstance returned 0x%08lx\n", (unsigned long int)hr); if (pUnk) { hr = IUnknown_QueryInterface(pUnk, &IID_IDispatch, (void **)&pInstaller); ok (SUCCEEDED(hr), "IUnknown::QueryInterface returned 0x%08lx\n", (unsigned long int)hr); - todo_wine test_dispatch(); - todo_wine test_Installer(); + test_dispatch(); + test_Installer(); hr = IUnknown_Release(pUnk); ok (SUCCEEDED(hr), "IUnknown::Release returned 0x%08lx\n", (unsigned long int)hr); -- 1.4.1