ole32: Make CreateDirEntry a virtual method.
[wine/multimedia.git] / dlls / msi / preview.c
blob458e4a1cb0bb97d6324819b05829512c986bf7f9
1 /*
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
21 #define COBJMACROS
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnls.h"
28 #include "msi.h"
29 #include "msipriv.h"
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;
47 MSIPACKAGE *package;
49 package = MSI_CreatePackage( db, NULL );
50 if( package )
52 preview = alloc_msiobject( MSIHANDLETYPE_PREVIEW, sizeof (MSIPREVIEW),
53 MSI_ClosePreview );
54 if( preview )
56 preview->package = package;
57 msiobj_addref( &package->hdr );
59 msiobj_release( &package->hdr );
61 return preview;
64 UINT WINAPI MsiEnableUIPreview( MSIHANDLE hdb, MSIHANDLE* phPreview )
66 MSIDATABASE *db;
67 MSIPREVIEW *preview;
68 UINT r = ERROR_FUNCTION_FAILED;
70 TRACE("%d %p\n", hdb, phPreview);
72 db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
73 if( !db )
75 IWineMsiRemoteDatabase *remote_database;
77 remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
78 if ( !remote_database )
79 return ERROR_INVALID_HANDLE;
81 *phPreview = 0;
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 );
90 if( preview )
92 *phPreview = alloc_msihandle( &preview->hdr );
93 msiobj_release( &preview->hdr );
94 r = ERROR_SUCCESS;
95 if (! *phPreview)
96 r = ERROR_NOT_ENOUGH_MEMORY;
98 msiobj_release( &db->hdr );
100 return r;
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 */
120 if( szDialogName )
122 dialog = msi_dialog_create( preview->package, szDialogName, NULL,
123 preview_event_handler );
124 if( dialog )
125 msi_dialog_do_preview( dialog );
126 else
127 r = ERROR_FUNCTION_FAILED;
129 preview->dialog = dialog;
131 return r;
134 UINT WINAPI MsiPreviewDialogW( MSIHANDLE hPreview, LPCWSTR szDialogName )
136 MSIPREVIEW *preview;
137 UINT r;
139 TRACE("%d %s\n", hPreview, debugstr_w(szDialogName));
141 preview = msihandle2msiinfo( hPreview, MSIHANDLETYPE_PREVIEW );
142 if( !preview )
143 return ERROR_INVALID_HANDLE;
145 r = MSI_PreviewDialogW( preview, szDialogName );
147 msiobj_release( &preview->hdr );
149 return r;
152 UINT WINAPI MsiPreviewDialogA( MSIHANDLE hPreview, LPCSTR szDialogName )
154 UINT r;
155 LPWSTR strW = NULL;
157 TRACE("%d %s\n", hPreview, debugstr_a(szDialogName));
159 if( szDialogName )
161 strW = strdupAtoW( szDialogName );
162 if( !strW )
163 return ERROR_OUTOFMEMORY;
165 r = MsiPreviewDialogW( hPreview, strW );
166 msi_free( strW );
167 return r;
170 UINT WINAPI MsiPreviewBillboardW( MSIHANDLE hPreview, LPCWSTR szControlName,
171 LPCWSTR szBillboard)
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,
179 LPCSTR szBillboard)
181 FIXME("%d %s %s\n", hPreview, debugstr_a(szControlName),
182 debugstr_a(szBillboard));
183 return ERROR_CALL_NOT_IMPLEMENTED;