Commit 479213c4 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Implement MsiPreviewDialog.

parent 9b634b97
......@@ -10,6 +10,7 @@ C_SRCS = \
action.c \
create.c \
custom.c \
dialog.c \
distinct.c \
format.c \
handle.c \
......
......@@ -1467,8 +1467,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
msi_dialog_register_class();
break;
case DLL_PROCESS_DETACH:
msi_dialog_unregister_class();
/* FIXME: Cleanup */
break;
}
......
/*
* Implementation of the Microsoft Installer (msi.dll)
*
* Copyright 2002 Mike McCormack for CodeWeavers
* Copyright 2002-2005 Mike McCormack for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -211,10 +211,14 @@ typedef struct tagMSIPACKAGE
UINT CurrentInstallState;
} MSIPACKAGE;
struct tag_dialog_info;
typedef struct tag_dialog_info dialog_info;
typedef struct tagMSIPREVIEW
{
MSIOBJECTHDR hdr;
MSIDATABASE *db;
MSIPACKAGE *package;
dialog_info *dialog;
} MSIPREVIEW;
#define MSIHANDLETYPE_ANY 0
......@@ -232,7 +236,7 @@ typedef struct tagMSIPREVIEW
#define GUID_SIZE 39
#define MSIHANDLE_MAGIC 0x4d434923
#define MSIMAXHANDLES 0x80
#define MSIMAXHANDLES 0xf0
#define MSISUMINFO_OFFSET 0x30LL
......@@ -325,33 +329,41 @@ extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
extern UINT MSI_ViewClose( MSIQUERY* );
/* package internals */
extern UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE ** );
extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR);
extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE * );
extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE ** );
extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD* );
extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, DWORD*);
extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, DWORD * );
extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
extern UINT MSI_GetComponentStateW(MSIPACKAGE *, LPWSTR, INSTALLSTATE *, INSTALLSTATE *);
extern UINT MSI_GetFeatureStateW(MSIPACKAGE *, LPWSTR, INSTALLSTATE *, INSTALLSTATE *);
extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPWSTR, INSTALLSTATE *, INSTALLSTATE * );
extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPWSTR, INSTALLSTATE *, INSTALLSTATE * );
/* for deformating */
extern UINT MSI_FormatRecordW(MSIPACKAGE* package, MSIRECORD* record,
LPWSTR buffer, DWORD *size);
/* registry data encoding/decoding functions */
BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
BOOL squash_guid(LPCWSTR in, LPWSTR out);
BOOL encode_base85_guid(GUID *,LPWSTR);
BOOL decode_base85_guid(LPCWSTR,GUID*);
UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
UINT MSIREG_OpenFeatures(HKEY* key);
UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
UINT MSIREG_OpenComponents(HKEY* key);
UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
extern BOOL encode_base85_guid(GUID *,LPWSTR);
extern BOOL decode_base85_guid(LPCWSTR,GUID*);
extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenFeatures(HKEY* key);
extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenComponents(HKEY* key);
extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
/* msi dialog interface */
typedef VOID (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, HWND );
extern dialog_info *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog_event_handler );
extern void msi_dialog_destroy( dialog_info* );
extern void msi_dialog_register_class( void );
extern void msi_dialog_unregister_class( void );
/* UI globals */
extern INSTALLUILEVEL gUILevel;
......
......@@ -352,15 +352,14 @@ Privileged
ReleaseDC(0, dc);
}
UINT MSI_CreatePackage(MSIDATABASE *db, MSIPACKAGE **pPackage)
MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db )
{
static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 };
static const WCHAR szpi[] = {'%','i',0};
MSIPACKAGE *package = NULL;
WCHAR uilevel[10];
UINT ret = ERROR_FUNCTION_FAILED;
TRACE("%p %p\n", db, pPackage);
TRACE("%p\n", db);
package = alloc_msiobject( MSIHANDLETYPE_PACKAGE, sizeof (MSIPACKAGE),
MSI_FreePackage );
......@@ -387,22 +386,15 @@ UINT MSI_CreatePackage(MSIDATABASE *db, MSIPACKAGE **pPackage)
set_installer_properties(package);
sprintfW(uilevel,szpi,gUILevel);
MSI_SetPropertyW(package, szLevel, uilevel);
msiobj_addref( &package->hdr );
*pPackage = package;
ret = ERROR_SUCCESS;
}
if( package )
msiobj_release( &package->hdr );
return ret;
return package;
}
UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
{
MSIDATABASE *db = NULL;
UINT ret = ERROR_FUNCTION_FAILED;
MSIPACKAGE *package;
MSIHANDLE handle;
TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
......@@ -416,32 +408,34 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
}
else
{
ret = MSI_OpenDatabaseW(szPackage, MSIDBOPEN_READONLY, &db);
if( ret != ERROR_SUCCESS )
return ret;
UINT r = MSI_OpenDatabaseW(szPackage, MSIDBOPEN_READONLY, &db);
if( r != ERROR_SUCCESS )
return r;
}
ret = MSI_CreatePackage( db, pPackage );
package = MSI_CreatePackage( db );
msiobj_release( &db->hdr );
if( !package )
return ERROR_FUNCTION_FAILED;
/*
* FIXME: I don't think this is right. Maybe we should be storing the
* name of the database in the MSIDATABASE structure and fetching this
* info from there, or maybe this is only relevant to cached databases.
*/
if( ret == ERROR_SUCCESS && szPackage[0] != '#' )
if( szPackage[0] != '#' )
{
static const WCHAR OriginalDatabase[] =
{'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
static const WCHAR Database[] = {'D','A','T','A','B','A','S','E',0};
MSI_SetPropertyW(*pPackage, OriginalDatabase, szPackage);
MSI_SetPropertyW(*pPackage, Database, szPackage);
MSI_SetPropertyW( package, OriginalDatabase, szPackage );
MSI_SetPropertyW( package, Database, szPackage );
}
if( db )
msiobj_release( &db->hdr );
*pPackage = package;
return ret;
return ERROR_SUCCESS;
}
UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
......
......@@ -22,32 +22,39 @@
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winnls.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "msi.h"
#include "msipriv.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(msi);
static void MSI_ClosePreview( MSIOBJECTHDR *arg )
{
MSIPREVIEW *preview = (MSIPREVIEW *) arg;
msiobj_release( &preview->db->hdr );
msiobj_release( &preview->package->hdr );
}
MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE *db )
{
MSIPREVIEW *preview;
MSIPREVIEW *preview = NULL;
MSIPACKAGE *package;
preview = alloc_msiobject( MSIHANDLETYPE_PREVIEW, sizeof (MSIPREVIEW),
MSI_ClosePreview );
if( preview )
package = MSI_CreatePackage( db );
if( package )
{
preview->db = db;
msiobj_addref( &db->hdr );
preview = alloc_msiobject( MSIHANDLETYPE_PREVIEW, sizeof (MSIPREVIEW),
MSI_ClosePreview );
if( preview )
{
preview->package = package;
preview->dialog = 0;
msiobj_addref( &package->hdr );
}
msiobj_release( &package->hdr );
}
return preview;
}
......@@ -70,15 +77,54 @@ UINT WINAPI MsiEnableUIPreview( MSIHANDLE hdb, MSIHANDLE* phPreview )
msiobj_release( &preview->hdr );
r = ERROR_SUCCESS;
}
msiobj_release( &db->hdr );
return r;
}
static VOID preview_event_handler( MSIPACKAGE *package, LPCWSTR event,
LPCWSTR argument, HWND dialog )
{
MESSAGE("Preview dialog event '%s' (arg='%s')\n",
debugstr_w( event ), debugstr_w( argument ));
}
UINT MSI_PreviewDialogW( MSIPREVIEW *preview, LPCWSTR szDialogName )
{
dialog_info *dialog = NULL;
UINT r = ERROR_SUCCESS;
if( preview->dialog )
msi_dialog_destroy( preview->dialog );
/* an empty name means we should just destroy the current preview dialog */
if( szDialogName )
{
dialog = msi_dialog_create( preview->package, szDialogName,
preview_event_handler );
if( !dialog )
r = ERROR_FUNCTION_FAILED;
}
preview->dialog = dialog;
return r;
}
UINT WINAPI MsiPreviewDialogW( MSIHANDLE hPreview, LPCWSTR szDialogName )
{
FIXME("%ld %s\n", hPreview, debugstr_w(szDialogName));
return ERROR_CALL_NOT_IMPLEMENTED;
MSIPREVIEW *preview;
UINT r;
TRACE("%ld %s\n", hPreview, debugstr_w(szDialogName));
preview = msihandle2msiinfo( hPreview, MSIHANDLETYPE_PREVIEW );
if( !preview )
return ERROR_INVALID_HANDLE;
r = MSI_PreviewDialogW( preview, szDialogName );
msiobj_release( &preview->hdr );
return r;
}
UINT WINAPI MsiPreviewDialogA( MSIHANDLE hPreview, LPCSTR szDialogName )
......
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