msi [2/6]: Add the IWineMsiRemotePackage interface

James Hawkins truiken at gmail.com
Mon Jun 25 18:34:48 CDT 2007


Hi,

Changelog:
* Add the IWineMsiRemotePackage interface.

 dlls/msi/msi_main.c    |    7 +++
 dlls/msi/msipriv.h     |    4 ++
 dlls/msi/msiserver.idl |   13 ++++++
 dlls/msi/package.c     |  109 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 133 insertions(+), 0 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/msi_main.c b/dlls/msi/msi_main.c
index 402e173..9384808 100644
--- a/dlls/msi/msi_main.c
+++ b/dlls/msi/msi_main.c
@@ -189,6 +189,7 @@ static const IClassFactoryVtbl MsiCF_Vtb
 };
 
 static IClassFactoryImpl MsiServer_CF = { &MsiCF_Vtbl, create_msiserver };
+static IClassFactoryImpl WineMsiRemotePackage_CF = { &MsiCF_Vtbl, create_msi_remote_package };
 
 /******************************************************************
  * DllGetClassObject          [MSI.@]
@@ -211,6 +212,12 @@ HRESULT WINAPI DllGetClassObject(REFCLSI
         FIXME("create %s object\n", debugstr_guid( rclsid ));
     }
 
+    if ( IsEqualCLSID (rclsid, &CLSID_IWineMsiRemotePackage) )
+    {
+        *ppv = (LPVOID) &WineMsiRemotePackage_CF;
+        return S_OK;
+    }
+
     return CLASS_E_CLASSNOTAVAILABLE;
 }
 
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index e577fc5..9a3d886 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -508,6 +508,8 @@ DEFINE_GUID(CLSID_IMsiServerX3, 0x000C10
 
 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
 
+DEFINE_GUID(CLSID_IWineMsiRemotePackage,0x902b3592,0x9d08,0x4dfd,0xa5,0x93,0xd0,0x7c,0x52,0x54,0x64,0x21);
+
 /* handle unicode/ascii output in the Msi* API functions */
 typedef struct {
     BOOL unicode;
@@ -529,10 +531,12 @@ UINT msi_strcpy_to_awstring( LPCWSTR str
 
 /* msi server interface */
 extern ITypeLib *get_msi_typelib( LPWSTR *path );
+extern HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj );
 
 /* handle functions */
 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
+extern MSIHANDLE alloc_msi_remote_handle( IUnknown *unk );
 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
 extern void msiobj_addref(MSIOBJECTHDR *);
 extern int msiobj_release(MSIOBJECTHDR *);
diff --git a/dlls/msi/msiserver.idl b/dlls/msi/msiserver.idl
index d0db26e..f652154 100644
--- a/dlls/msi/msiserver.idl
+++ b/dlls/msi/msiserver.idl
@@ -23,6 +23,19 @@ import "wtypes.idl";
 import "objidl.idl";
 import "oaidl.idl";
 
+[
+    uuid(902B3592-9D08-4dfd-A593-D07C52546421),
+    oleautomation,
+    object
+]
+interface IWineMsiRemotePackage : IUnknown
+{
+    HRESULT SetMsiHandle( [in] ULONG_PTR handle );
+    HRESULT GetActiveDatabase( [out] ULONG_PTR handle );
+    HRESULT GetProperty( [in] BSTR *property, [out] BSTR *value, [out] ULONG_PTR size );
+    HRESULT SetProperty( [in] BSTR *property, [in] BSTR *value );
+}
+
 [ uuid(000C1092-0000-0000-C000-000000000046), version(1.0) ]
 library WindowsInstaller
 {
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 1dd661d..13e68ed 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -20,6 +20,7 @@
 
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+#define COBJMACROS
 
 #include <stdarg.h>
 #include "windef.h"
@@ -44,6 +45,7 @@ #include "msidefs.h"
 #include "sddl.h"
 
 #include "msipriv.h"
+#include "msiserver.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
 
@@ -1390,3 +1392,110 @@ UINT WINAPI MsiGetPropertyW( MSIHANDLE h
 
     return MSI_GetProperty( hInstall, szName, &val, pchValueBuf );
 }
+
+typedef struct _msi_remote_package_impl {
+    const IWineMsiRemotePackageVtbl *lpVtbl;
+    MSIHANDLE package;
+    LONG refs;
+} msi_remote_package_impl;
+
+static inline msi_remote_package_impl* mrp_from_IWineMsiRemotePackage( IWineMsiRemotePackage* iface )
+{
+    return (msi_remote_package_impl*) iface;
+}
+
+static HRESULT WINAPI mrp_QueryInterface( IWineMsiRemotePackage *iface,
+                REFIID riid,LPVOID *ppobj)
+{
+    if( IsEqualCLSID( riid, &IID_IUnknown ) ||
+        IsEqualCLSID( riid, &IID_IWineMsiRemotePackage ) )
+    {
+        IUnknown_AddRef( iface );
+        *ppobj = iface;
+        return S_OK;
+    }
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI mrp_AddRef( IWineMsiRemotePackage *iface )
+{
+    msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
+
+    return InterlockedIncrement( &This->refs );
+}
+
+static ULONG WINAPI mrp_Release( IWineMsiRemotePackage *iface )
+{
+    msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
+    ULONG r;
+
+    r = InterlockedIncrement( &This->refs );
+    if (r == 0)
+    {
+        MsiCloseHandle( This->package );
+        msi_free( This );
+    }
+    return r;
+}
+
+static HRESULT WINAPI mrp_SetMsiHandle( IWineMsiRemotePackage *iface, ULONG_PTR handle )
+{
+    msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
+    This->package = (MSIHANDLE)handle;
+    return S_OK;
+}
+
+HRESULT WINAPI mrp_GetActiveDatabase( IWineMsiRemotePackage *iface, ULONG_PTR handle )
+{
+    msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
+    *(ULONG_PTR *)handle = MsiGetActiveDatabase(This->package);
+    return S_OK;
+}
+
+HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR *property, BSTR *value, ULONG_PTR size )
+{
+    msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
+    UINT r;
+
+    r = MsiGetPropertyW(This->package, (LPWSTR)property, (LPWSTR)value, (DWORD *)size);
+    if (r != ERROR_SUCCESS)
+        return HRESULT_FROM_WIN32(r);
+
+    return S_OK;
+}
+
+HRESULT WINAPI mrp_SetProperty( IWineMsiRemotePackage *iface, BSTR *property, BSTR *value )
+{
+    msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
+    UINT r = MsiSetPropertyW(This->package, (LPWSTR)property, (LPWSTR)value);
+    return HRESULT_FROM_WIN32(r);
+}
+
+static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl =
+{
+    mrp_QueryInterface,
+    mrp_AddRef,
+    mrp_Release,
+    mrp_SetMsiHandle,
+    mrp_GetActiveDatabase,
+    mrp_GetProperty,
+    mrp_SetProperty,
+};
+
+HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj )
+{
+    msi_remote_package_impl* This;
+
+    This = msi_alloc( sizeof *This );
+    if (!This)
+        return E_OUTOFMEMORY;
+
+    This->lpVtbl = &msi_remote_package_vtbl;
+    This->package = 0;
+    This->refs = 1;
+
+    *ppObj = This;
+
+    return S_OK;
+}
-- 
1.4.1



More information about the wine-patches mailing list