Commit 6d9c80e8 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Create an internal handle-free api for reading MSI database summary

information.
parent 2cb23165
...@@ -219,6 +219,16 @@ typedef struct tagMSIPREVIEW ...@@ -219,6 +219,16 @@ typedef struct tagMSIPREVIEW
msi_dialog *dialog; msi_dialog *dialog;
} MSIPREVIEW; } MSIPREVIEW;
#define MSI_MAX_PROPS 20
typedef struct tagMSISUMMARYINFO
{
MSIOBJECTHDR hdr;
MSIDATABASE *db;
DWORD update_count;
PROPVARIANT property[MSI_MAX_PROPS];
} MSISUMMARYINFO;
#define MSIHANDLETYPE_ANY 0 #define MSIHANDLETYPE_ANY 0
#define MSIHANDLETYPE_DATABASE 1 #define MSIHANDLETYPE_DATABASE 1
#define MSIHANDLETYPE_SUMMARYINFO 2 #define MSIHANDLETYPE_SUMMARYINFO 2
...@@ -401,6 +411,10 @@ extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * ...@@ -401,6 +411,10 @@ extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD *
extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * ); extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR ); extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
/* summary information */
extern MSISUMMARYINFO *MSI_GetSummaryInformationW( MSIDATABASE *db, UINT uiUpdateCount );
extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
/* undocumented functions */ /* undocumented functions */
UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD ); UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD * ); UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD * );
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msi); WINE_DEFAULT_DEBUG_CHANNEL(msi);
#define MSI_MAX_PROPS 20
#include "pshpack1.h" #include "pshpack1.h"
typedef struct { typedef struct {
...@@ -81,14 +79,6 @@ typedef struct { ...@@ -81,14 +79,6 @@ typedef struct {
#define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER)) #define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER))
typedef struct tagMSISUMMARYINFO
{
MSIOBJECTHDR hdr;
MSIDATABASE *db;
DWORD update_count;
PROPVARIANT property[MSI_MAX_PROPS];
} MSISUMMARYINFO;
static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y', static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
'I','n','f','o','r','m','a','t','i','o','n',0 }; 'I','n','f','o','r','m','a','t','i','o','n',0 };
...@@ -415,45 +405,19 @@ static UINT save_summary_info( MSISUMMARYINFO * si, IStream *stm ) ...@@ -415,45 +405,19 @@ static UINT save_summary_info( MSISUMMARYINFO * si, IStream *stm )
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase, MSISUMMARYINFO *MSI_GetSummaryInformationW( MSIDATABASE *db, UINT uiUpdateCount )
LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle )
{ {
UINT ret = ERROR_SUCCESS;
IStream *stm = NULL; IStream *stm = NULL;
MSISUMMARYINFO *si; MSISUMMARYINFO *si;
MSIHANDLE handle;
MSIDATABASE *db;
DWORD grfMode; DWORD grfMode;
HRESULT r; HRESULT r;
TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase), TRACE("%p %d\n", db, uiUpdateCount );
uiUpdateCount, pHandle);
if( !pHandle )
return ERROR_INVALID_PARAMETER;
if( szDatabase )
{
UINT res;
res = MSI_OpenDatabaseW(szDatabase, NULL, &db);
if( res != ERROR_SUCCESS )
return res;
}
else
{
db = msihandle2msiinfo(hDatabase, MSIHANDLETYPE_DATABASE);
if( !db )
return ERROR_INVALID_PARAMETER;
}
si = alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO, si = alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO,
sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo ); sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo );
if( !si ) if( !si )
{ return si;
ret = ERROR_FUNCTION_FAILED;
goto end;
}
msiobj_addref( &db->hdr ); msiobj_addref( &db->hdr );
si->db = db; si->db = db;
...@@ -469,14 +433,44 @@ UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase, ...@@ -469,14 +433,44 @@ UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase,
IStream_Release( stm ); IStream_Release( stm );
} }
handle = alloc_msihandle( &si->hdr ); return si;
if( handle ) }
*pHandle = handle;
UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase,
LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle )
{
MSISUMMARYINFO *si;
MSIDATABASE *db;
UINT ret = ERROR_FUNCTION_FAILED;
TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
uiUpdateCount, pHandle);
if( !pHandle )
return ERROR_INVALID_PARAMETER;
if( szDatabase )
{
ret = MSI_OpenDatabaseW( szDatabase, NULL, &db );
if( ret != ERROR_SUCCESS )
return ret;
}
else else
ret = ERROR_FUNCTION_FAILED; {
msiobj_release( &si->hdr ); db = msihandle2msiinfo( hDatabase, MSIHANDLETYPE_DATABASE );
if( !db )
return ERROR_INVALID_PARAMETER;
}
si = MSI_GetSummaryInformationW( db, uiUpdateCount );
if (si)
{
*pHandle = alloc_msihandle( &si->hdr );
if( *pHandle )
ret = ERROR_SUCCESS;
msiobj_release( &si->hdr );
}
end:
if( db ) if( db )
msiobj_release( &db->hdr ); msiobj_release( &db->hdr );
...@@ -537,6 +531,12 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, ...@@ -537,6 +531,12 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
if( !si ) if( !si )
return ERROR_INVALID_HANDLE; return ERROR_INVALID_HANDLE;
if ( uiProperty >= MSI_MAX_PROPS )
{
*puiDataType = VT_EMPTY;
return ret;
}
prop = &si->property[uiProperty]; prop = &si->property[uiProperty];
if( puiDataType ) if( puiDataType )
...@@ -588,6 +588,18 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, ...@@ -588,6 +588,18 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
return ret; return ret;
} }
LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty )
{
PROPVARIANT *prop;
if ( uiProperty >= MSI_MAX_PROPS )
return NULL;
prop = &si->property[uiProperty];
if( prop->vt != VT_LPSTR )
return NULL;
return strdupAtoW( prop->u.pszVal );
}
UINT WINAPI MsiSummaryInfoGetPropertyA( UINT WINAPI MsiSummaryInfoGetPropertyA(
MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue, MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue,
FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf) FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment