2005-01-21 11:17:01 +01:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 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
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-21 11:17:01 +01:00
|
|
|
*/
|
|
|
|
|
2007-11-12 01:13:08 +01:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2005-01-21 11:17:01 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "msi.h"
|
|
|
|
#include "msipriv.h"
|
2007-11-12 01:13:08 +01:00
|
|
|
#include "msiserver.h"
|
2005-01-21 11:17:01 +01:00
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
2005-01-21 11:17:01 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
static void MSI_ClosePreview( MSIOBJECTHDR *arg )
|
|
|
|
{
|
|
|
|
MSIPREVIEW *preview = (MSIPREVIEW *) arg;
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
msiobj_release( &preview->package->hdr );
|
2005-01-21 11:17:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE *db )
|
|
|
|
{
|
2005-01-28 13:39:57 +01:00
|
|
|
MSIPREVIEW *preview = NULL;
|
|
|
|
MSIPACKAGE *package;
|
2005-01-21 11:17:01 +01:00
|
|
|
|
2006-11-08 00:13:47 +01:00
|
|
|
package = MSI_CreatePackage( db, NULL );
|
2005-01-28 13:39:57 +01:00
|
|
|
if( package )
|
2005-01-21 11:17:01 +01:00
|
|
|
{
|
2005-01-28 13:39:57 +01:00
|
|
|
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 );
|
2005-01-21 11:17:01 +01:00
|
|
|
}
|
|
|
|
return preview;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiEnableUIPreview( MSIHANDLE hdb, MSIHANDLE* phPreview )
|
|
|
|
{
|
|
|
|
MSIDATABASE *db;
|
|
|
|
MSIPREVIEW *preview;
|
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %p\n", hdb, phPreview);
|
2005-01-21 11:17:01 +01:00
|
|
|
|
|
|
|
db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
|
|
|
|
if( !db )
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
|
|
|
IWineMsiRemoteDatabase *remote_database;
|
|
|
|
|
|
|
|
remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
|
|
|
|
if ( !remote_database )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
*phPreview = 0;
|
|
|
|
|
|
|
|
IWineMsiRemoteDatabase_Release( remote_database );
|
|
|
|
WARN("MsiEnableUIPreview not allowed during a custom action!\n");
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2005-01-21 11:17:01 +01:00
|
|
|
preview = MSI_EnableUIPreview( db );
|
|
|
|
if( preview )
|
|
|
|
{
|
|
|
|
*phPreview = alloc_msihandle( &preview->hdr );
|
|
|
|
msiobj_release( &preview->hdr );
|
|
|
|
r = ERROR_SUCCESS;
|
2006-08-28 18:44:35 +02:00
|
|
|
if (! *phPreview)
|
|
|
|
r = ERROR_NOT_ENOUGH_MEMORY;
|
2005-01-21 11:17:01 +01:00
|
|
|
}
|
2005-03-10 12:15:40 +01:00
|
|
|
msiobj_release( &db->hdr );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-06-17 23:31:06 +02:00
|
|
|
static UINT preview_event_handler( MSIPACKAGE *package, LPCWSTR event,
|
2005-02-02 10:55:51 +01:00
|
|
|
LPCWSTR argument, msi_dialog *dialog )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
|
|
|
MESSAGE("Preview dialog event '%s' (arg='%s')\n",
|
|
|
|
debugstr_w( event ), debugstr_w( argument ));
|
2005-06-17 23:31:06 +02:00
|
|
|
return ERROR_SUCCESS;
|
2005-01-28 13:39:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_PreviewDialogW( MSIPREVIEW *preview, LPCWSTR szDialogName )
|
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_dialog *dialog = NULL;
|
2005-01-28 13:39:57 +01:00
|
|
|
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 )
|
|
|
|
{
|
2006-09-29 01:20:40 +02:00
|
|
|
dialog = msi_dialog_create( preview->package, szDialogName, NULL,
|
2005-01-28 13:39:57 +01:00
|
|
|
preview_event_handler );
|
2005-02-02 10:55:51 +01:00
|
|
|
if( dialog )
|
|
|
|
msi_dialog_do_preview( dialog );
|
|
|
|
else
|
2005-01-28 13:39:57 +01:00
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
preview->dialog = dialog;
|
2005-01-21 11:17:01 +01:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiPreviewDialogW( MSIHANDLE hPreview, LPCWSTR szDialogName )
|
|
|
|
{
|
2005-01-28 13:39:57 +01:00
|
|
|
MSIPREVIEW *preview;
|
|
|
|
UINT r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s\n", hPreview, debugstr_w(szDialogName));
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
preview = msihandle2msiinfo( hPreview, MSIHANDLETYPE_PREVIEW );
|
|
|
|
if( !preview )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
r = MSI_PreviewDialogW( preview, szDialogName );
|
|
|
|
|
|
|
|
msiobj_release( &preview->hdr );
|
|
|
|
|
|
|
|
return r;
|
2005-01-21 11:17:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiPreviewDialogA( MSIHANDLE hPreview, LPCSTR szDialogName )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
UINT r;
|
2005-01-21 11:17:01 +01:00
|
|
|
LPWSTR strW = NULL;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s\n", hPreview, debugstr_a(szDialogName));
|
2005-01-21 11:17:01 +01:00
|
|
|
|
|
|
|
if( szDialogName )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
strW = strdupAtoW( szDialogName );
|
|
|
|
if( !strW )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2005-01-21 11:17:01 +01:00
|
|
|
}
|
|
|
|
r = MsiPreviewDialogW( hPreview, strW );
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( strW );
|
2005-01-21 11:17:01 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiPreviewBillboardW( MSIHANDLE hPreview, LPCWSTR szControlName,
|
|
|
|
LPCWSTR szBillboard)
|
|
|
|
{
|
2009-01-04 14:14:15 +01:00
|
|
|
FIXME("%d %s %s\n", hPreview, debugstr_w(szControlName),
|
2005-01-21 11:17:01 +01:00
|
|
|
debugstr_w(szBillboard));
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiPreviewBillboardA( MSIHANDLE hPreview, LPCSTR szControlName,
|
|
|
|
LPCSTR szBillboard)
|
|
|
|
{
|
2009-01-04 14:14:15 +01:00
|
|
|
FIXME("%d %s %s\n", hPreview, debugstr_a(szControlName),
|
2005-01-21 11:17:01 +01:00
|
|
|
debugstr_a(szBillboard));
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|