2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "msiserver.h"
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msi);
37 static void MSI_ClosePreview( MSIOBJECTHDR *arg )
39 MSIPREVIEW *preview = (MSIPREVIEW *) arg;
41 msiobj_release( &preview->package->hdr );
44 static MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE *db )
46 MSIPREVIEW *preview = NULL;
49 package = MSI_CreatePackage( db, NULL );
52 preview = alloc_msiobject( MSIHANDLETYPE_PREVIEW, sizeof (MSIPREVIEW),
56 preview->package = package;
57 msiobj_addref( &package->hdr );
59 msiobj_release( &package->hdr );
64 UINT WINAPI MsiEnableUIPreview( MSIHANDLE hdb, MSIHANDLE* phPreview )
68 UINT r = ERROR_FUNCTION_FAILED;
70 TRACE("%d %p\n", hdb, phPreview);
72 db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
75 IWineMsiRemoteDatabase *remote_database;
77 remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
78 if ( !remote_database )
79 return ERROR_INVALID_HANDLE;
83 IWineMsiRemoteDatabase_Release( remote_database );
84 WARN("MsiEnableUIPreview not allowed during a custom action!\n");
86 return ERROR_FUNCTION_FAILED;
89 preview = MSI_EnableUIPreview( db );
92 *phPreview = alloc_msihandle( &preview->hdr );
93 msiobj_release( &preview->hdr );
96 r = ERROR_NOT_ENOUGH_MEMORY;
98 msiobj_release( &db->hdr );
103 static UINT preview_event_handler( MSIPACKAGE *package, LPCWSTR event,
104 LPCWSTR argument, msi_dialog *dialog )
106 MESSAGE("Preview dialog event '%s' (arg='%s')\n",
107 debugstr_w( event ), debugstr_w( argument ));
108 return ERROR_SUCCESS;
111 static UINT MSI_PreviewDialogW( MSIPREVIEW *preview, LPCWSTR szDialogName )
113 msi_dialog *dialog = NULL;
114 UINT r = ERROR_SUCCESS;
116 if( preview->dialog )
117 msi_dialog_destroy( preview->dialog );
119 /* an empty name means we should just destroy the current preview dialog */
122 dialog = msi_dialog_create( preview->package, szDialogName, NULL,
123 preview_event_handler );
125 msi_dialog_do_preview( dialog );
127 r = ERROR_FUNCTION_FAILED;
129 preview->dialog = dialog;
134 UINT WINAPI MsiPreviewDialogW( MSIHANDLE hPreview, LPCWSTR szDialogName )
139 TRACE("%d %s\n", hPreview, debugstr_w(szDialogName));
141 preview = msihandle2msiinfo( hPreview, MSIHANDLETYPE_PREVIEW );
143 return ERROR_INVALID_HANDLE;
145 r = MSI_PreviewDialogW( preview, szDialogName );
147 msiobj_release( &preview->hdr );
152 UINT WINAPI MsiPreviewDialogA( MSIHANDLE hPreview, LPCSTR szDialogName )
157 TRACE("%d %s\n", hPreview, debugstr_a(szDialogName));
161 strW = strdupAtoW( szDialogName );
163 return ERROR_OUTOFMEMORY;
165 r = MsiPreviewDialogW( hPreview, strW );
170 UINT WINAPI MsiPreviewBillboardW( MSIHANDLE hPreview, LPCWSTR szControlName,
173 FIXME("%d %s %s\n", hPreview, debugstr_w(szControlName),
174 debugstr_w(szBillboard));
175 return ERROR_CALL_NOT_IMPLEMENTED;
178 UINT WINAPI MsiPreviewBillboardA( MSIHANDLE hPreview, LPCSTR szControlName,
181 FIXME("%d %s %s\n", hPreview, debugstr_a(szControlName),
182 debugstr_a(szBillboard));
183 return ERROR_CALL_NOT_IMPLEMENTED;