Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Implementation of the Microsoft Installer (msi.dll) |
| 3 | * |
| 4 | * Copyright 2004 Aric Stewart for CodeWeavers |
| 5 | * |
| 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. |
| 10 | * |
| 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. |
| 15 | * |
| 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | /* |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 22 | * Pages I need |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 23 | * |
| 24 | http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/installexecutesequence_table.asp |
| 25 | |
| 26 | http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/standard_actions_reference.asp |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #include <stdarg.h> |
| 30 | #include <stdio.h> |
| 31 | |
Francois Gouget | 486d020 | 2004-10-07 03:06:48 +0000 | [diff] [blame] | 32 | #define COBJMACROS |
| 33 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 34 | #include "windef.h" |
| 35 | #include "winbase.h" |
| 36 | #include "winerror.h" |
| 37 | #include "winreg.h" |
| 38 | #include "wine/debug.h" |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 39 | #include "fdi.h" |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 40 | #include "msi.h" |
| 41 | #include "msiquery.h" |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 42 | #include "msvcrt/fcntl.h" |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 43 | #include "objbase.h" |
| 44 | #include "objidl.h" |
| 45 | #include "msipriv.h" |
| 46 | #include "winnls.h" |
| 47 | #include "winuser.h" |
| 48 | #include "shlobj.h" |
| 49 | #include "wine/unicode.h" |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 50 | #include "ver.h" |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 51 | |
| 52 | #define CUSTOM_ACTION_TYPE_MASK 0x3F |
| 53 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 54 | WINE_DEFAULT_DEBUG_CHANNEL(msi); |
| 55 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 56 | typedef struct tagMSIFEATURE |
| 57 | { |
| 58 | WCHAR Feature[96]; |
| 59 | WCHAR Feature_Parent[96]; |
| 60 | WCHAR Title[0x100]; |
| 61 | WCHAR Description[0x100]; |
| 62 | INT Display; |
| 63 | INT Level; |
| 64 | WCHAR Directory[96]; |
| 65 | INT Attributes; |
| 66 | |
| 67 | INSTALLSTATE State; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 68 | BOOL Enabled; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 69 | INT ComponentCount; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 70 | INT Components[1024]; /* yes hardcoded limit.... I am bad */ |
| 71 | INT Cost; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 72 | } MSIFEATURE; |
| 73 | |
| 74 | typedef struct tagMSICOMPONENT |
| 75 | { |
| 76 | WCHAR Component[96]; |
| 77 | WCHAR ComponentId[96]; |
| 78 | WCHAR Directory[96]; |
| 79 | INT Attributes; |
| 80 | WCHAR Condition[0x100]; |
| 81 | WCHAR KeyPath[96]; |
| 82 | |
| 83 | INSTALLSTATE State; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 84 | BOOL FeatureState; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 85 | BOOL Enabled; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 86 | INT Cost; |
Mike McCormack | 24e9a34 | 2004-07-06 18:56:12 +0000 | [diff] [blame] | 87 | } MSICOMPONENT; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 88 | |
| 89 | typedef struct tagMSIFOLDER |
| 90 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 91 | LPWSTR Directory; |
| 92 | LPWSTR TargetDefault; |
| 93 | LPWSTR SourceDefault; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 94 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 95 | LPWSTR ResolvedTarget; |
| 96 | LPWSTR ResolvedSource; |
| 97 | LPWSTR Property; /* initially set property */ |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 98 | INT ParentIndex; |
| 99 | INT State; |
| 100 | /* 0 = uninitialized */ |
| 101 | /* 1 = existing */ |
| 102 | /* 2 = created remove if empty */ |
| 103 | /* 3 = created persist if empty */ |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 104 | INT Cost; |
| 105 | INT Space; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 106 | }MSIFOLDER; |
| 107 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 108 | typedef struct tagMSIFILE |
| 109 | { |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 110 | LPWSTR File; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 111 | INT ComponentIndex; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 112 | LPWSTR FileName; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 113 | INT FileSize; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 114 | LPWSTR Version; |
| 115 | LPWSTR Language; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 116 | INT Attributes; |
| 117 | INT Sequence; |
| 118 | |
| 119 | INT State; |
| 120 | /* 0 = uninitialize */ |
| 121 | /* 1 = not present */ |
| 122 | /* 2 = present but replace */ |
| 123 | /* 3 = present do not replace */ |
| 124 | /* 4 = Installed */ |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 125 | LPWSTR SourcePath; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 126 | LPWSTR TargetPath; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 127 | BOOL Temporary; |
| 128 | }MSIFILE; |
| 129 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 130 | /* |
| 131 | * Prototypes |
| 132 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 133 | static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran); |
| 134 | static UINT ACTION_ProcessUISequence(MSIPACKAGE *package); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 135 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 136 | UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 137 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 138 | static UINT ACTION_LaunchConditions(MSIPACKAGE *package); |
| 139 | static UINT ACTION_CostInitialize(MSIPACKAGE *package); |
| 140 | static UINT ACTION_CreateFolders(MSIPACKAGE *package); |
| 141 | static UINT ACTION_CostFinalize(MSIPACKAGE *package); |
| 142 | static UINT ACTION_FileCost(MSIPACKAGE *package); |
| 143 | static UINT ACTION_InstallFiles(MSIPACKAGE *package); |
| 144 | static UINT ACTION_DuplicateFiles(MSIPACKAGE *package); |
| 145 | static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package); |
| 146 | static UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action); |
| 147 | static UINT ACTION_InstallInitialize(MSIPACKAGE *package); |
| 148 | static UINT ACTION_InstallValidate(MSIPACKAGE *package); |
| 149 | static UINT ACTION_ProcessComponents(MSIPACKAGE *package); |
| 150 | static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package); |
| 151 | static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package); |
| 152 | static UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package); |
| 153 | static UINT ACTION_CreateShortcuts(MSIPACKAGE *package); |
| 154 | static UINT ACTION_PublishProduct(MSIPACKAGE *package); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 155 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 156 | static UINT HANDLE_CustomType1(MSIPACKAGE *package, const LPWSTR source, |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 157 | const LPWSTR target, const INT type); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 158 | static UINT HANDLE_CustomType2(MSIPACKAGE *package, const LPWSTR source, |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 159 | const LPWSTR target, const INT type); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 160 | static UINT HANDLE_CustomType18(MSIPACKAGE *package, const LPWSTR source, |
| 161 | const LPWSTR target, const INT type); |
| 162 | static UINT HANDLE_CustomType50(MSIPACKAGE *package, const LPWSTR source, |
| 163 | const LPWSTR target, const INT type); |
| 164 | static UINT HANDLE_CustomType34(MSIPACKAGE *package, const LPWSTR source, |
| 165 | const LPWSTR target, const INT type); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 166 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 167 | static DWORD deformat_string(MSIPACKAGE *package, WCHAR* ptr,WCHAR** data); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 168 | static LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 169 | BOOL source, BOOL set_prop, MSIFOLDER **folder); |
| 170 | |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 171 | static int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 172 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 173 | /* |
| 174 | * consts and values used |
| 175 | */ |
| 176 | static const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0}; |
| 177 | static const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0}; |
| 178 | static const WCHAR cszTargetDir[] = {'T','A','R','G','E','T','D','I','R',0}; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 179 | static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0}; |
| 180 | static const WCHAR cszDatabase[]={'D','A','T','A','B','A','S','E',0}; |
Aric Stewart | eb0e0df | 2004-06-30 19:38:36 +0000 | [diff] [blame] | 181 | static const WCHAR c_collen[] = {'C',':','\\',0}; |
| 182 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 183 | static const WCHAR cszlsb[]={'[',0}; |
| 184 | static const WCHAR cszrsb[]={']',0}; |
| 185 | static const WCHAR cszbs[]={'\\',0}; |
| 186 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 187 | const static WCHAR szCreateFolders[] = |
| 188 | {'C','r','e','a','t','e','F','o','l','d','e','r','s',0}; |
| 189 | const static WCHAR szCostFinalize[] = |
| 190 | {'C','o','s','t','F','i','n','a','l','i','z','e',0}; |
| 191 | const static WCHAR szInstallFiles[] = |
| 192 | {'I','n','s','t','a','l','l','F','i','l','e','s',0}; |
| 193 | const static WCHAR szDuplicateFiles[] = |
| 194 | {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; |
| 195 | const static WCHAR szWriteRegistryValues[] = |
| 196 | {'W','r','i','t','e','R','e','g','i','s','t','r','y','V','a','l','u','e','s',0}; |
| 197 | const static WCHAR szCostInitialize[] = |
| 198 | {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0}; |
| 199 | const static WCHAR szFileCost[] = {'F','i','l','e','C','o','s','t',0}; |
| 200 | const static WCHAR szInstallInitialize[] = |
| 201 | {'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0}; |
| 202 | const static WCHAR szInstallValidate[] = |
| 203 | {'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0}; |
| 204 | const static WCHAR szLaunchConditions[] = |
| 205 | {'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','s',0}; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 206 | const static WCHAR szProcessComponents[] = |
| 207 | {'P','r','o','c','e','s','s','C','o','m','p','o','n','e','n','t','s',0}; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 208 | const static WCHAR szRegisterTypeLibraries[] = |
| 209 | {'R','e','g','i','s','t','e','r','T','y','p','e','L','i','b','r','a','r', |
| 210 | 'i','e','s',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 211 | const static WCHAR szRegisterClassInfo[] = |
| 212 | {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0}; |
| 213 | const static WCHAR szRegisterProgIdInfo[] = |
| 214 | {'R','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 215 | const static WCHAR szCreateShortcuts[] = |
| 216 | {'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0}; |
| 217 | const static WCHAR szPublishProduct[] = |
| 218 | {'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 219 | |
| 220 | /******************************************************** |
| 221 | * helper functions to get around current HACKS and such |
| 222 | ********************************************************/ |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 223 | inline static void reduce_to_longfilename(WCHAR* filename) |
| 224 | { |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 225 | LPWSTR p = strchrW(filename,'|'); |
| 226 | if (p) |
| 227 | memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR)); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 230 | inline static char *strdupWtoA( const WCHAR *str ) |
| 231 | { |
| 232 | char *ret = NULL; |
| 233 | if (str) |
| 234 | { |
| 235 | DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL |
| 236 | ); |
| 237 | if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) |
| 238 | WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); |
| 239 | } |
| 240 | return ret; |
| 241 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 242 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 243 | inline static WCHAR *strdupAtoW( const char *str ) |
| 244 | { |
| 245 | WCHAR *ret = NULL; |
| 246 | if (str) |
| 247 | { |
| 248 | DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); |
| 249 | if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) |
| 250 | MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); |
| 251 | } |
| 252 | return ret; |
| 253 | } |
| 254 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 255 | static LPWSTR dupstrW(LPCWSTR src) |
| 256 | { |
| 257 | LPWSTR dest; |
| 258 | if (!src) return NULL; |
| 259 | dest = HeapAlloc(GetProcessHeap(), 0, (strlenW(src)+1)*sizeof(WCHAR)); |
| 260 | strcpyW(dest, src); |
| 261 | return dest; |
| 262 | } |
| 263 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 264 | inline static WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index) |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 265 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 266 | UINT rc; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 267 | DWORD sz; |
| 268 | LPWSTR ret; |
| 269 | |
| 270 | sz = 0; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 271 | if (MSI_RecordIsNull(row,index)) |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 272 | return NULL; |
| 273 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 274 | rc = MSI_RecordGetStringW(row,index,NULL,&sz); |
| 275 | |
| 276 | /* having an empty string is different than NULL */ |
| 277 | if (sz == 0) |
| 278 | { |
| 279 | ret = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)); |
| 280 | ret[0] = 0; |
| 281 | return ret; |
| 282 | } |
| 283 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 284 | sz ++; |
| 285 | ret = HeapAlloc(GetProcessHeap(),0,sz * sizeof (WCHAR)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 286 | rc = MSI_RecordGetStringW(row,index,ret,&sz); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 287 | if (rc!=ERROR_SUCCESS) |
| 288 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 289 | ERR("Unable to load dynamic string\n"); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 290 | HeapFree(GetProcessHeap(), 0, ret); |
| 291 | ret = NULL; |
| 292 | } |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 293 | return ret; |
| 294 | } |
| 295 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 296 | inline static LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop, |
| 297 | UINT* rc) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 298 | { |
| 299 | DWORD sz = 0; |
| 300 | LPWSTR str; |
| 301 | UINT r; |
| 302 | |
| 303 | r = MSI_GetPropertyW(package, prop, NULL, &sz); |
Aric Stewart | 2595570 | 2004-12-22 17:13:26 +0000 | [diff] [blame] | 304 | if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 305 | { |
| 306 | if (rc) |
| 307 | *rc = r; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 308 | return NULL; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 309 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 310 | sz++; |
| 311 | str = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR)); |
| 312 | r = MSI_GetPropertyW(package, prop, str, &sz); |
| 313 | if (r != ERROR_SUCCESS) |
| 314 | { |
| 315 | HeapFree(GetProcessHeap(),0,str); |
| 316 | str = NULL; |
| 317 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 318 | if (rc) |
| 319 | *rc = r; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 320 | return str; |
| 321 | } |
| 322 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 323 | inline static int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component ) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 324 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 325 | int rc = -1; |
| 326 | DWORD i; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 327 | |
| 328 | for (i = 0; i < package->loaded_components; i++) |
| 329 | { |
| 330 | if (strcmpW(Component,package->components[i].Component)==0) |
| 331 | { |
| 332 | rc = i; |
| 333 | break; |
| 334 | } |
| 335 | } |
| 336 | return rc; |
| 337 | } |
| 338 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 339 | inline static int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature ) |
| 340 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 341 | int rc = -1; |
| 342 | DWORD i; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 343 | |
| 344 | for (i = 0; i < package->loaded_features; i++) |
| 345 | { |
| 346 | if (strcmpW(Feature,package->features[i].Feature)==0) |
| 347 | { |
| 348 | rc = i; |
| 349 | break; |
| 350 | } |
| 351 | } |
| 352 | return rc; |
| 353 | } |
| 354 | |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 355 | inline static int get_loaded_file(MSIPACKAGE* package, LPCWSTR file) |
| 356 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 357 | int rc = -1; |
| 358 | DWORD i; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 359 | |
| 360 | for (i = 0; i < package->loaded_files; i++) |
| 361 | { |
| 362 | if (strcmpW(file,package->files[i].File)==0) |
| 363 | { |
| 364 | rc = i; |
| 365 | break; |
| 366 | } |
| 367 | } |
| 368 | return rc; |
| 369 | } |
| 370 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 371 | |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 372 | static int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 373 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 374 | DWORD i; |
| 375 | DWORD index; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 376 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 377 | if (!package) |
| 378 | return -2; |
| 379 | |
| 380 | for (i=0; i < package->loaded_files; i++) |
| 381 | if (strcmpW(package->files[i].File,name)==0) |
| 382 | return -1; |
| 383 | |
| 384 | index = package->loaded_files; |
| 385 | package->loaded_files++; |
| 386 | if (package->loaded_files== 1) |
| 387 | package->files = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE)); |
| 388 | else |
| 389 | package->files = HeapReAlloc(GetProcessHeap(),0, |
| 390 | package->files , package->loaded_files * sizeof(MSIFILE)); |
| 391 | |
| 392 | memset(&package->files[index],0,sizeof(MSIFILE)); |
| 393 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 394 | package->files[index].File = dupstrW(name); |
| 395 | package->files[index].TargetPath = dupstrW(path); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 396 | package->files[index].Temporary = TRUE; |
| 397 | |
| 398 | TRACE("Tracking tempfile (%s)\n",debugstr_w(package->files[index].File)); |
| 399 | |
| 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | void ACTION_remove_tracked_tempfiles(MSIPACKAGE* package) |
| 404 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 405 | DWORD i; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 406 | |
| 407 | if (!package) |
| 408 | return; |
| 409 | |
| 410 | for (i = 0; i < package->loaded_files; i++) |
| 411 | { |
| 412 | if (package->files[i].Temporary) |
| 413 | DeleteFileW(package->files[i].TargetPath); |
| 414 | |
| 415 | } |
| 416 | } |
| 417 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 418 | static UINT ACTION_OpenQuery( MSIDATABASE *db, MSIQUERY **view, LPCWSTR fmt, ... ) |
| 419 | { |
| 420 | LPWSTR szQuery; |
| 421 | LPCWSTR p; |
| 422 | UINT sz, rc; |
| 423 | va_list va; |
| 424 | |
| 425 | /* figure out how much space we need to allocate */ |
| 426 | va_start(va, fmt); |
| 427 | sz = strlenW(fmt) + 1; |
| 428 | p = fmt; |
| 429 | while (*p) |
| 430 | { |
| 431 | p = strchrW(p, '%'); |
| 432 | if (!p) |
| 433 | break; |
| 434 | p++; |
| 435 | switch (*p) |
| 436 | { |
| 437 | case 's': /* a string */ |
| 438 | sz += strlenW(va_arg(va,LPCWSTR)); |
| 439 | break; |
| 440 | case 'd': |
| 441 | case 'i': /* an integer -2147483648 seems to be longest */ |
| 442 | sz += 3*sizeof(int); |
| 443 | (void)va_arg(va,int); |
| 444 | break; |
| 445 | case '%': /* a single % - leave it alone */ |
| 446 | break; |
| 447 | default: |
| 448 | FIXME("Unhandled character type %c\n",*p); |
| 449 | } |
| 450 | p++; |
| 451 | } |
| 452 | va_end(va); |
| 453 | |
| 454 | /* construct the string */ |
| 455 | szQuery = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR)); |
| 456 | va_start(va, fmt); |
| 457 | vsnprintfW(szQuery, sz, fmt, va); |
| 458 | va_end(va); |
| 459 | |
| 460 | /* perform the query */ |
| 461 | rc = MSI_DatabaseOpenViewW(db, szQuery, view); |
| 462 | HeapFree(GetProcessHeap(), 0, szQuery); |
| 463 | return rc; |
| 464 | } |
| 465 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 466 | static void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d ) |
| 467 | { |
| 468 | MSIRECORD * row; |
| 469 | |
| 470 | row = MSI_CreateRecord(4); |
| 471 | MSI_RecordSetInteger(row,1,a); |
| 472 | MSI_RecordSetInteger(row,2,b); |
| 473 | MSI_RecordSetInteger(row,3,c); |
| 474 | MSI_RecordSetInteger(row,4,d); |
| 475 | MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row); |
| 476 | msiobj_release(&row->hdr); |
| 477 | } |
| 478 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 479 | static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 480 | { |
| 481 | static const WCHAR Query_t[] = |
| 482 | {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','c','t','i','o', |
| 483 | 'n','T','e','x','t',' ','w','h','e','r','e',' ','A','c','t','i','o','n',' ','=', |
| 484 | ' ','\'','%','s','\'',0}; |
| 485 | WCHAR message[1024]; |
| 486 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 487 | MSIQUERY * view; |
| 488 | MSIRECORD * row = 0; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 489 | LPWSTR ptr; |
| 490 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 491 | if (!package->LastAction || strcmpW(package->LastAction,action)) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 492 | { |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 493 | rc = ACTION_OpenQuery(package->db, &view, Query_t, action); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 494 | if (rc != ERROR_SUCCESS) |
| 495 | return; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 496 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 497 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 498 | if (rc != ERROR_SUCCESS) |
| 499 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 500 | MSI_ViewClose(view); |
| 501 | return; |
| 502 | } |
| 503 | rc = MSI_ViewFetch(view,&row); |
| 504 | if (rc != ERROR_SUCCESS) |
| 505 | { |
| 506 | MSI_ViewClose(view); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 507 | return; |
| 508 | } |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 509 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 510 | if (MSI_RecordIsNull(row,3)) |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 511 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 512 | msiobj_release(&row->hdr); |
| 513 | MSI_ViewClose(view); |
| 514 | msiobj_release(&view->hdr); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 515 | return; |
| 516 | } |
| 517 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 518 | /* update the cached actionformat */ |
| 519 | if (package->ActionFormat) |
| 520 | HeapFree(GetProcessHeap(),0,package->ActionFormat); |
| 521 | package->ActionFormat = load_dynamic_stringW(row,3); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 522 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 523 | if (package->LastAction) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 524 | HeapFree(GetProcessHeap(),0,package->LastAction); |
| 525 | package->LastAction = dupstrW(action); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 526 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 527 | msiobj_release(&row->hdr); |
| 528 | MSI_ViewClose(view); |
| 529 | msiobj_release(&view->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 530 | } |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 531 | |
| 532 | message[0]=0; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 533 | ptr = package->ActionFormat; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 534 | while (*ptr) |
| 535 | { |
| 536 | LPWSTR ptr2; |
| 537 | LPWSTR data=NULL; |
| 538 | WCHAR tmp[1023]; |
| 539 | INT field; |
| 540 | |
| 541 | ptr2 = strchrW(ptr,'['); |
| 542 | if (ptr2) |
| 543 | { |
| 544 | strncpyW(tmp,ptr,ptr2-ptr); |
| 545 | tmp[ptr2-ptr]=0; |
| 546 | strcatW(message,tmp); |
| 547 | ptr2++; |
| 548 | field = atoiW(ptr2); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 549 | data = load_dynamic_stringW(record,field); |
| 550 | if (data) |
| 551 | { |
| 552 | strcatW(message,data); |
| 553 | HeapFree(GetProcessHeap(),0,data); |
| 554 | } |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 555 | ptr=strchrW(ptr2,']'); |
| 556 | ptr++; |
| 557 | } |
| 558 | else |
| 559 | { |
| 560 | strcatW(message,ptr); |
| 561 | break; |
| 562 | } |
| 563 | } |
| 564 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 565 | row = MSI_CreateRecord(1); |
| 566 | MSI_RecordSetStringW(row,1,message); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 567 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 568 | MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row); |
| 569 | msiobj_release(&row->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 573 | static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 574 | { |
| 575 | static const WCHAR template_s[]= |
| 576 | {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ','%','s','.',0}; |
| 577 | static const WCHAR format[] = |
| 578 | {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0}; |
| 579 | static const WCHAR Query_t[] = |
| 580 | {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','c','t','i','o', |
| 581 | 'n','T','e','x','t',' ','w','h','e','r','e',' ','A','c','t','i','o','n',' ','=', |
| 582 | ' ','\'','%','s','\'',0}; |
| 583 | WCHAR message[1024]; |
| 584 | WCHAR timet[0x100]; |
| 585 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 586 | MSIQUERY * view; |
| 587 | MSIRECORD * row = 0; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 588 | WCHAR *ActionText=NULL; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 589 | |
| 590 | GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100); |
| 591 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 592 | rc = ACTION_OpenQuery(package->db, &view, Query_t, action); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 593 | if (rc != ERROR_SUCCESS) |
| 594 | return; |
| 595 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 596 | if (rc != ERROR_SUCCESS) |
| 597 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 598 | MSI_ViewClose(view); |
| 599 | msiobj_release(&view->hdr); |
| 600 | return; |
| 601 | } |
| 602 | rc = MSI_ViewFetch(view,&row); |
| 603 | if (rc != ERROR_SUCCESS) |
| 604 | { |
| 605 | MSI_ViewClose(view); |
| 606 | msiobj_release(&view->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 607 | return; |
| 608 | } |
| 609 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 610 | ActionText = load_dynamic_stringW(row,2); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 611 | msiobj_release(&row->hdr); |
| 612 | MSI_ViewClose(view); |
| 613 | msiobj_release(&view->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 614 | |
| 615 | sprintfW(message,template_s,timet,action,ActionText); |
| 616 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 617 | row = MSI_CreateRecord(1); |
| 618 | MSI_RecordSetStringW(row,1,message); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 619 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 620 | MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row); |
| 621 | msiobj_release(&row->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 622 | HeapFree(GetProcessHeap(),0,ActionText); |
| 623 | } |
| 624 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 625 | static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start, |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 626 | UINT rc) |
| 627 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 628 | MSIRECORD * row; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 629 | static const WCHAR template_s[]= |
| 630 | {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ','%','s', |
| 631 | '.',0}; |
| 632 | static const WCHAR template_e[]= |
| 633 | {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ','%','s', |
| 634 | '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ','%','i','.',0}; |
| 635 | static const WCHAR format[] = |
| 636 | {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0}; |
| 637 | WCHAR message[1024]; |
| 638 | WCHAR timet[0x100]; |
| 639 | |
| 640 | GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100); |
| 641 | if (start) |
| 642 | sprintfW(message,template_s,timet,action); |
| 643 | else |
| 644 | sprintfW(message,template_e,timet,action,rc); |
| 645 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 646 | row = MSI_CreateRecord(1); |
| 647 | MSI_RecordSetStringW(row,1,message); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 648 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 649 | MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row); |
| 650 | msiobj_release(&row->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 651 | } |
| 652 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 653 | /* |
| 654 | * build_directory_name() |
| 655 | * |
| 656 | * This function is to save messing round with directory names |
| 657 | * It handles adding backslashes between path segments, |
| 658 | * and can add \ at the end of the directory name if told to. |
| 659 | * |
| 660 | * It takes a variable number of arguments. |
| 661 | * It always allocates a new string for the result, so make sure |
| 662 | * to free the return value when finished with it. |
| 663 | * |
| 664 | * The first arg is the number of path segments that follow. |
| 665 | * The arguments following count are a list of path segments. |
| 666 | * A path segment may be NULL. |
| 667 | * |
| 668 | * Path segments will be added with a \ seperating them. |
| 669 | * A \ will not be added after the last segment, however if the |
| 670 | * last segment is NULL, then the last character will be a \ |
| 671 | * |
| 672 | */ |
| 673 | static LPWSTR build_directory_name(DWORD count, ...) |
| 674 | { |
| 675 | DWORD sz = 1, i; |
| 676 | LPWSTR dir; |
| 677 | va_list va; |
| 678 | |
| 679 | va_start(va,count); |
| 680 | for(i=0; i<count; i++) |
| 681 | { |
| 682 | LPCWSTR str = va_arg(va,LPCWSTR); |
| 683 | if (str) |
| 684 | sz += strlenW(str) + 1; |
| 685 | } |
| 686 | va_end(va); |
| 687 | |
| 688 | dir = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR)); |
| 689 | dir[0]=0; |
| 690 | |
| 691 | va_start(va,count); |
| 692 | for(i=0; i<count; i++) |
| 693 | { |
| 694 | LPCWSTR str = va_arg(va,LPCWSTR); |
| 695 | if (!str) |
| 696 | continue; |
| 697 | strcatW(dir, str); |
| 698 | if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\') |
| 699 | strcatW(dir, cszbs); |
| 700 | } |
| 701 | return dir; |
| 702 | } |
| 703 | |
| 704 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 705 | /**************************************************** |
| 706 | * TOP level entry points |
| 707 | *****************************************************/ |
| 708 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 709 | UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath, |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 710 | LPCWSTR szCommandLine) |
| 711 | { |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 712 | DWORD sz; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 713 | WCHAR buffer[10]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 714 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 715 | static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 716 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 717 | if (szPackagePath) |
| 718 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 719 | LPWSTR p, check, path; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 720 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 721 | path = dupstrW(szPackagePath); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 722 | p = strrchrW(path,'\\'); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 723 | if (p) |
| 724 | { |
| 725 | p++; |
| 726 | *p=0; |
| 727 | } |
| 728 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 729 | check = load_dynamic_property(package, cszSourceDir,NULL); |
Aric Stewart | d0c971a | 2004-12-22 18:15:50 +0000 | [diff] [blame] | 730 | if (!check) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 731 | MSI_SetPropertyW(package, cszSourceDir, path); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 732 | else |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 733 | HeapFree(GetProcessHeap(), 0, check); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 734 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 735 | HeapFree(GetProcessHeap(), 0, path); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 736 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 737 | |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 738 | if (szCommandLine) |
| 739 | { |
| 740 | LPWSTR ptr,ptr2; |
| 741 | ptr = (LPWSTR)szCommandLine; |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 742 | |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 743 | while (*ptr) |
| 744 | { |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 745 | WCHAR prop[0x100]; |
| 746 | WCHAR val[0x100]; |
| 747 | |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 748 | TRACE("Looking at %s\n",debugstr_w(ptr)); |
| 749 | |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 750 | ptr2 = strchrW(ptr,'='); |
| 751 | if (ptr2) |
| 752 | { |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 753 | BOOL quote=FALSE; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 754 | DWORD len = 0; |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 755 | |
| 756 | while (*ptr == ' ') ptr++; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 757 | strncpyW(prop,ptr,ptr2-ptr); |
| 758 | prop[ptr2-ptr]=0; |
| 759 | ptr2++; |
| 760 | |
| 761 | ptr = ptr2; |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 762 | while (*ptr && (quote || (!quote && *ptr!=' '))) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 763 | { |
| 764 | if (*ptr == '"') |
| 765 | quote = !quote; |
| 766 | ptr++; |
| 767 | len++; |
| 768 | } |
| 769 | |
| 770 | if (*ptr2=='"') |
| 771 | { |
| 772 | ptr2++; |
| 773 | len -= 2; |
| 774 | } |
| 775 | strncpyW(val,ptr2,len); |
| 776 | val[len]=0; |
| 777 | |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 778 | if (strlenW(prop) > 0) |
| 779 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 780 | TRACE("Found commandline property (%s) = (%s)\n", |
| 781 | debugstr_w(prop), debugstr_w(val)); |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 782 | MSI_SetPropertyW(package,prop,val); |
| 783 | } |
| 784 | } |
| 785 | ptr++; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 786 | } |
| 787 | } |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 788 | |
| 789 | sz = 10; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 790 | if (MSI_GetPropertyW(package,szUILevel,buffer,&sz) == ERROR_SUCCESS) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 791 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 792 | if (atoiW(buffer) >= INSTALLUILEVEL_REDUCED) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 793 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 794 | rc = ACTION_ProcessUISequence(package); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 795 | if (rc == ERROR_SUCCESS) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 796 | rc = ACTION_ProcessExecSequence(package,TRUE); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 797 | } |
| 798 | else |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 799 | rc = ACTION_ProcessExecSequence(package,FALSE); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 800 | } |
| 801 | else |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 802 | rc = ACTION_ProcessExecSequence(package,FALSE); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 803 | |
| 804 | return rc; |
| 805 | } |
| 806 | |
| 807 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 808 | static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 809 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 810 | MSIQUERY * view; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 811 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 812 | static const WCHAR ExecSeqQuery[] = { |
| 813 | 's','e','l','e','c','t',' ','*',' ', |
| 814 | 'f','r','o','m',' ', |
| 815 | 'I','n','s','t','a','l','l','E','x','e','c','u','t','e', |
| 816 | 'S','e','q','u','e','n','c','e',' ', |
| 817 | 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ', |
| 818 | '>',' ','%','i',' ','o','r','d','e','r',' ', |
| 819 | 'b','y',' ','S','e','q','u','e','n','c','e',0 }; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 820 | MSIRECORD * row = 0; |
| 821 | static const WCHAR IVQuery[] = { |
| 822 | 's','e','l','e','c','t',' ','S','e','q','u','e','n','c','e',' ', |
| 823 | 'f','r','o','m',' ','I','n','s','t','a','l','l', |
| 824 | 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e',' ', |
| 825 | 'w','h','e','r','e',' ','A','c','t','i','o','n',' ','=',' ', |
| 826 | '`','I','n','s','t','a','l','l','V','a','l','i','d','a','t','e','`', |
| 827 | 0}; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 828 | INT seq = 0; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 829 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 830 | /* get the sequence number */ |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 831 | if (UIran) |
| 832 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 833 | rc = MSI_DatabaseOpenViewW(package->db, IVQuery, &view); |
| 834 | if (rc != ERROR_SUCCESS) |
| 835 | return rc; |
| 836 | rc = MSI_ViewExecute(view, 0); |
| 837 | if (rc != ERROR_SUCCESS) |
| 838 | { |
| 839 | MSI_ViewClose(view); |
| 840 | msiobj_release(&view->hdr); |
| 841 | return rc; |
| 842 | } |
| 843 | rc = MSI_ViewFetch(view,&row); |
| 844 | if (rc != ERROR_SUCCESS) |
| 845 | { |
| 846 | MSI_ViewClose(view); |
| 847 | msiobj_release(&view->hdr); |
| 848 | return rc; |
| 849 | } |
| 850 | seq = MSI_RecordGetInteger(row,1); |
| 851 | msiobj_release(&row->hdr); |
| 852 | MSI_ViewClose(view); |
| 853 | msiobj_release(&view->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 854 | } |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 855 | |
| 856 | rc = ACTION_OpenQuery(package->db, &view, ExecSeqQuery, seq); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 857 | if (rc == ERROR_SUCCESS) |
| 858 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 859 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 860 | |
| 861 | if (rc != ERROR_SUCCESS) |
| 862 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 863 | MSI_ViewClose(view); |
| 864 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 865 | goto end; |
| 866 | } |
| 867 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 868 | TRACE("Running the actions\n"); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 869 | |
| 870 | while (1) |
| 871 | { |
| 872 | WCHAR buffer[0x100]; |
| 873 | DWORD sz = 0x100; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 874 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 875 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 876 | if (rc != ERROR_SUCCESS) |
| 877 | { |
| 878 | rc = ERROR_SUCCESS; |
| 879 | break; |
| 880 | } |
| 881 | |
| 882 | /* check conditions */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 883 | if (!MSI_RecordIsNull(row,2)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 884 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 885 | LPWSTR cond = NULL; |
| 886 | cond = load_dynamic_stringW(row,2); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 887 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 888 | if (cond) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 889 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 890 | /* this is a hack to skip errors in the condition code */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 891 | if (MSI_EvaluateConditionW(package, cond) == |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 892 | MSICONDITION_FALSE) |
| 893 | { |
| 894 | HeapFree(GetProcessHeap(),0,cond); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 895 | msiobj_release(&row->hdr); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 896 | continue; |
| 897 | } |
| 898 | else |
| 899 | HeapFree(GetProcessHeap(),0,cond); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 900 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 904 | rc = MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 905 | if (rc != ERROR_SUCCESS) |
| 906 | { |
| 907 | ERR("Error is %x\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 908 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 909 | break; |
| 910 | } |
| 911 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 912 | rc = ACTION_PerformAction(package,buffer); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 913 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 914 | if (rc == ERROR_FUNCTION_NOT_CALLED) |
| 915 | rc = ERROR_SUCCESS; |
| 916 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 917 | if (rc != ERROR_SUCCESS) |
| 918 | { |
| 919 | ERR("Execution halted due to error (%i)\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 920 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 921 | break; |
| 922 | } |
| 923 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 924 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 925 | } |
| 926 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 927 | MSI_ViewClose(view); |
| 928 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | end: |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 932 | return rc; |
| 933 | } |
| 934 | |
| 935 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 936 | static UINT ACTION_ProcessUISequence(MSIPACKAGE *package) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 937 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 938 | MSIQUERY * view; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 939 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 940 | static const WCHAR ExecSeqQuery [] = { |
| 941 | 's','e','l','e','c','t',' ','*',' ', |
| 942 | 'f','r','o','m',' ','I','n','s','t','a','l','l', |
| 943 | 'U','I','S','e','q','u','e','n','c','e',' ', |
| 944 | 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ', '>',' ','0',' ', |
| 945 | 'o','r','d','e','r',' ','b','y',' ','S','e','q','u','e','n','c','e',0}; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 946 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 947 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 948 | |
| 949 | if (rc == ERROR_SUCCESS) |
| 950 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 951 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 952 | |
| 953 | if (rc != ERROR_SUCCESS) |
| 954 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 955 | MSI_ViewClose(view); |
| 956 | msiobj_release(&view->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 957 | goto end; |
| 958 | } |
| 959 | |
| 960 | TRACE("Running the actions \n"); |
| 961 | |
| 962 | while (1) |
| 963 | { |
| 964 | WCHAR buffer[0x100]; |
| 965 | DWORD sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 966 | MSIRECORD * row = 0; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 967 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 968 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 969 | if (rc != ERROR_SUCCESS) |
| 970 | { |
| 971 | rc = ERROR_SUCCESS; |
| 972 | break; |
| 973 | } |
| 974 | |
| 975 | /* check conditions */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 976 | if (!MSI_RecordIsNull(row,2)) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 977 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 978 | LPWSTR cond = NULL; |
| 979 | cond = load_dynamic_stringW(row,2); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 980 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 981 | if (cond) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 982 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 983 | /* this is a hack to skip errors in the condition code */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 984 | if (MSI_EvaluateConditionW(package, cond) == |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 985 | MSICONDITION_FALSE) |
| 986 | { |
| 987 | HeapFree(GetProcessHeap(),0,cond); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 988 | msiobj_release(&row->hdr); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 989 | continue; |
| 990 | } |
| 991 | else |
| 992 | HeapFree(GetProcessHeap(),0,cond); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 993 | } |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 997 | rc = MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 998 | if (rc != ERROR_SUCCESS) |
| 999 | { |
| 1000 | ERR("Error is %x\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1001 | msiobj_release(&row->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1002 | break; |
| 1003 | } |
| 1004 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1005 | rc = ACTION_PerformAction(package,buffer); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1006 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1007 | if (rc == ERROR_FUNCTION_NOT_CALLED) |
| 1008 | rc = ERROR_SUCCESS; |
| 1009 | |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1010 | if (rc != ERROR_SUCCESS) |
| 1011 | { |
| 1012 | ERR("Execution halted due to error (%i)\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1013 | msiobj_release(&row->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1014 | break; |
| 1015 | } |
| 1016 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1017 | msiobj_release(&row->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1018 | } |
| 1019 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1020 | MSI_ViewClose(view); |
| 1021 | msiobj_release(&view->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | end: |
| 1025 | return rc; |
| 1026 | } |
| 1027 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1028 | /******************************************************** |
| 1029 | * ACTION helper functions and functions that perform the actions |
| 1030 | *******************************************************/ |
| 1031 | |
| 1032 | /* |
| 1033 | * Alot of actions are really important even if they don't do anything |
| 1034 | * explicit.. Lots of properties are set at the beginning of the installation |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 1035 | * CostFinalize does a bunch of work to translated the directories and such |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1036 | * |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 1037 | * But until I get write access to the database that is hard, so I am going to |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1038 | * hack it to see if I can get something to run. |
| 1039 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1040 | UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1041 | { |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1042 | UINT rc = ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1043 | |
| 1044 | TRACE("Performing action (%s)\n",debugstr_w(action)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1045 | ui_actioninfo(package, action, TRUE, 0); |
| 1046 | ui_actionstart(package, action); |
| 1047 | ui_progress(package,2,1,0,0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1048 | |
Mike McCormack | 24e9a34 | 2004-07-06 18:56:12 +0000 | [diff] [blame] | 1049 | /* pre install, setup and configuration block */ |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 1050 | if (strcmpW(action,szLaunchConditions)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1051 | rc = ACTION_LaunchConditions(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1052 | else if (strcmpW(action,szCostInitialize)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1053 | rc = ACTION_CostInitialize(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1054 | else if (strcmpW(action,szFileCost)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1055 | rc = ACTION_FileCost(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1056 | else if (strcmpW(action,szCostFinalize)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1057 | rc = ACTION_CostFinalize(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1058 | else if (strcmpW(action,szInstallValidate)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1059 | rc = ACTION_InstallValidate(package); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1060 | |
| 1061 | /* install block */ |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 1062 | else if (strcmpW(action,szProcessComponents)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1063 | rc = ACTION_ProcessComponents(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1064 | else if (strcmpW(action,szInstallInitialize)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1065 | rc = ACTION_InstallInitialize(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1066 | else if (strcmpW(action,szCreateFolders)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1067 | rc = ACTION_CreateFolders(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1068 | else if (strcmpW(action,szInstallFiles)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1069 | rc = ACTION_InstallFiles(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1070 | else if (strcmpW(action,szDuplicateFiles)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1071 | rc = ACTION_DuplicateFiles(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1072 | else if (strcmpW(action,szWriteRegistryValues)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1073 | rc = ACTION_WriteRegistryValues(package); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 1074 | else if (strcmpW(action,szRegisterTypeLibraries)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1075 | rc = ACTION_RegisterTypeLibraries(package); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 1076 | else if (strcmpW(action,szRegisterClassInfo)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1077 | rc = ACTION_RegisterClassInfo(package); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 1078 | else if (strcmpW(action,szRegisterProgIdInfo)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1079 | rc = ACTION_RegisterProgIdInfo(package); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 1080 | else if (strcmpW(action,szCreateShortcuts)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1081 | rc = ACTION_CreateShortcuts(package); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 1082 | else if (strcmpW(action,szPublishProduct)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1083 | rc = ACTION_PublishProduct(package); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1084 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1085 | /* |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 1086 | Called during iTunes but unimplemented and seem important |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1087 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1088 | ResolveSource (sets SourceDir) |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1089 | RegisterProduct |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1090 | InstallFinalize |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1091 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1092 | else if ((rc = ACTION_CustomAction(package,action)) != ERROR_SUCCESS) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1093 | { |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1094 | FIXME("UNHANDLED MSI ACTION %s\n",debugstr_w(action)); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1095 | rc = ERROR_FUNCTION_NOT_CALLED; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1096 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1097 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1098 | ui_actioninfo(package, action, FALSE, rc); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1099 | return rc; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1103 | static UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1104 | { |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1105 | UINT rc = ERROR_SUCCESS; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1106 | MSIQUERY * view; |
| 1107 | MSIRECORD * row = 0; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1108 | static const WCHAR ExecSeqQuery[] = |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1109 | {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','C','u','s','t','o' |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1110 | ,'m','A','c','t','i','o','n',' ','w','h','e','r','e',' ','`','A','c','t','i' |
| 1111 | ,'o','n','`',' ','=',' ','`','%','s','`',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1112 | UINT type; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1113 | LPWSTR source; |
| 1114 | LPWSTR target; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1115 | WCHAR *deformated=NULL; |
| 1116 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1117 | rc = ACTION_OpenQuery(package->db, &view, ExecSeqQuery, action); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1118 | if (rc != ERROR_SUCCESS) |
| 1119 | return rc; |
| 1120 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1121 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1122 | if (rc != ERROR_SUCCESS) |
| 1123 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1124 | MSI_ViewClose(view); |
| 1125 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1126 | return rc; |
| 1127 | } |
| 1128 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1129 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1130 | if (rc != ERROR_SUCCESS) |
| 1131 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1132 | MSI_ViewClose(view); |
| 1133 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1134 | return rc; |
| 1135 | } |
| 1136 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1137 | type = MSI_RecordGetInteger(row,2); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1138 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1139 | source = load_dynamic_stringW(row,3); |
| 1140 | target = load_dynamic_stringW(row,4); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1141 | |
| 1142 | TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type, |
| 1143 | debugstr_w(source), debugstr_w(target)); |
| 1144 | |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 1145 | /* we are ignoring ALOT of flags and important synchronization stuff */ |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1146 | switch (type & CUSTOM_ACTION_TYPE_MASK) |
| 1147 | { |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1148 | case 1: /* DLL file stored in a Binary table stream */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1149 | rc = HANDLE_CustomType1(package,source,target,type); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1150 | break; |
Mike McCormack | 24e9a34 | 2004-07-06 18:56:12 +0000 | [diff] [blame] | 1151 | case 2: /* EXE file stored in a Binary table strem */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1152 | rc = HANDLE_CustomType2(package,source,target,type); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1153 | break; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1154 | case 18: /*EXE file installed with package */ |
| 1155 | rc = HANDLE_CustomType18(package,source,target,type); |
| 1156 | break; |
| 1157 | case 50: /*EXE file specified by a property value */ |
| 1158 | rc = HANDLE_CustomType50(package,source,target,type); |
| 1159 | break; |
| 1160 | case 34: /*EXE to be run in specified directory */ |
| 1161 | rc = HANDLE_CustomType34(package,source,target,type); |
| 1162 | break; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1163 | case 35: /* Directory set with formatted text. */ |
| 1164 | case 51: /* Property set with formatted text. */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1165 | deformat_string(package,target,&deformated); |
| 1166 | rc = MSI_SetPropertyW(package,source,deformated); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1167 | HeapFree(GetProcessHeap(),0,deformated); |
| 1168 | break; |
| 1169 | default: |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1170 | FIXME("UNHANDLED ACTION TYPE %i (%s %s)\n", |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1171 | type & CUSTOM_ACTION_TYPE_MASK, debugstr_w(source), |
| 1172 | debugstr_w(target)); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1175 | HeapFree(GetProcessHeap(),0,source); |
| 1176 | HeapFree(GetProcessHeap(),0,target); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1177 | msiobj_release(&row->hdr); |
| 1178 | MSI_ViewClose(view); |
| 1179 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1180 | return rc; |
| 1181 | } |
| 1182 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1183 | static UINT store_binary_to_temp(MSIPACKAGE *package, const LPWSTR source, |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1184 | LPWSTR tmp_file) |
| 1185 | { |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1186 | DWORD sz=MAX_PATH; |
| 1187 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1188 | if (MSI_GetPropertyW(package, cszTempFolder, tmp_file, &sz) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1189 | != ERROR_SUCCESS) |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1190 | GetTempPathW(MAX_PATH,tmp_file); |
| 1191 | |
| 1192 | strcatW(tmp_file,source); |
| 1193 | |
| 1194 | if (GetFileAttributesW(tmp_file) != INVALID_FILE_ATTRIBUTES) |
| 1195 | { |
| 1196 | TRACE("File already exists\n"); |
| 1197 | return ERROR_SUCCESS; |
| 1198 | } |
| 1199 | else |
| 1200 | { |
| 1201 | /* write out the file */ |
| 1202 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1203 | MSIQUERY * view; |
| 1204 | MSIRECORD * row = 0; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1205 | static const WCHAR fmt[] = |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1206 | {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','B','i' |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1207 | ,'n','a','r','y',' ','w','h','e','r','e',' ','N','a','m','e','=','`','%','s','`',0}; |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1208 | HANDLE the_file; |
| 1209 | CHAR buffer[1024]; |
| 1210 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1211 | if (track_tempfile(package, source, tmp_file)!=0) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1212 | FIXME("File Name in temp tracking collision\n"); |
| 1213 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1214 | the_file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, |
| 1215 | FILE_ATTRIBUTE_NORMAL, NULL); |
| 1216 | |
| 1217 | if (the_file == INVALID_HANDLE_VALUE) |
| 1218 | return ERROR_FUNCTION_FAILED; |
| 1219 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1220 | rc = ACTION_OpenQuery(package->db, &view, fmt, source); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1221 | if (rc != ERROR_SUCCESS) |
| 1222 | return rc; |
| 1223 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1224 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1225 | if (rc != ERROR_SUCCESS) |
| 1226 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1227 | MSI_ViewClose(view); |
| 1228 | msiobj_release(&view->hdr); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1229 | return rc; |
| 1230 | } |
| 1231 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1232 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1233 | if (rc != ERROR_SUCCESS) |
| 1234 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1235 | MSI_ViewClose(view); |
| 1236 | msiobj_release(&view->hdr); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1237 | return rc; |
| 1238 | } |
| 1239 | |
| 1240 | do |
| 1241 | { |
| 1242 | DWORD write; |
| 1243 | sz = 1024; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1244 | rc = MSI_RecordReadStream(row,2,buffer,&sz); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1245 | if (rc != ERROR_SUCCESS) |
| 1246 | { |
| 1247 | ERR("Failed to get stream\n"); |
| 1248 | CloseHandle(the_file); |
| 1249 | DeleteFileW(tmp_file); |
| 1250 | break; |
| 1251 | } |
| 1252 | WriteFile(the_file,buffer,sz,&write,NULL); |
| 1253 | } while (sz == 1024); |
| 1254 | |
| 1255 | CloseHandle(the_file); |
| 1256 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1257 | msiobj_release(&row->hdr); |
| 1258 | MSI_ViewClose(view); |
| 1259 | msiobj_release(&view->hdr); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | return ERROR_SUCCESS; |
| 1263 | } |
| 1264 | |
Aric Stewart | 6a787c7 | 2004-07-30 00:00:25 +0000 | [diff] [blame] | 1265 | typedef UINT __stdcall CustomEntry(MSIHANDLE); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1266 | typedef struct |
| 1267 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1268 | MSIPACKAGE *package; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1269 | WCHAR target[MAX_PATH]; |
| 1270 | WCHAR source[MAX_PATH]; |
| 1271 | } thread_struct; |
| 1272 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 1273 | #if 0 |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1274 | static DWORD WINAPI DllThread(LPVOID info) |
| 1275 | { |
| 1276 | HANDLE DLL; |
| 1277 | LPSTR proc; |
| 1278 | thread_struct *stuff; |
| 1279 | CustomEntry *fn; |
| 1280 | |
| 1281 | stuff = (thread_struct*)info; |
| 1282 | |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 1283 | TRACE("Asynchronous start (%s, %s) \n", debugstr_w(stuff->source), |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1284 | debugstr_w(stuff->target)); |
| 1285 | |
| 1286 | DLL = LoadLibraryW(stuff->source); |
| 1287 | if (DLL) |
| 1288 | { |
| 1289 | proc = strdupWtoA( stuff->target ); |
| 1290 | fn = (CustomEntry*)GetProcAddress(DLL,proc); |
| 1291 | if (fn) |
| 1292 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1293 | MSIHANDLE hPackage; |
| 1294 | MSIPACKAGE *package = stuff->package; |
| 1295 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1296 | TRACE("Calling function\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1297 | hPackage = msiobj_findhandle( &package->hdr ); |
| 1298 | if( !hPackage ) |
| 1299 | ERR("Handle for object %p not found\n", package ); |
| 1300 | fn(hPackage); |
| 1301 | msiobj_release( &package->hdr ); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1302 | } |
| 1303 | else |
| 1304 | ERR("Cannot load functon\n"); |
| 1305 | |
| 1306 | HeapFree(GetProcessHeap(),0,proc); |
| 1307 | FreeLibrary(DLL); |
| 1308 | } |
| 1309 | else |
| 1310 | ERR("Unable to load library\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1311 | msiobj_release( &stuff->package->hdr ); |
| 1312 | HeapFree( GetProcessHeap(), 0, info ); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1313 | return 0; |
| 1314 | } |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 1315 | #endif |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1316 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1317 | static UINT HANDLE_CustomType1(MSIPACKAGE *package, const LPWSTR source, |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1318 | const LPWSTR target, const INT type) |
| 1319 | { |
| 1320 | WCHAR tmp_file[MAX_PATH]; |
| 1321 | CustomEntry *fn; |
| 1322 | HANDLE DLL; |
| 1323 | LPSTR proc; |
| 1324 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1325 | store_binary_to_temp(package, source, tmp_file); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1326 | |
| 1327 | TRACE("Calling function %s from %s\n",debugstr_w(target), |
| 1328 | debugstr_w(tmp_file)); |
| 1329 | |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1330 | if (!strchrW(tmp_file,'.')) |
| 1331 | { |
| 1332 | static const WCHAR dot[]={'.',0}; |
| 1333 | strcatW(tmp_file,dot); |
| 1334 | } |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1335 | |
| 1336 | if (type & 0xc0) |
| 1337 | { |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 1338 | /* DWORD ThreadId; */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1339 | thread_struct *info = HeapAlloc( GetProcessHeap(), 0, sizeof(*info) ); |
| 1340 | |
| 1341 | /* msiobj_addref( &package->hdr ); */ |
| 1342 | info->package = package; |
| 1343 | strcpyW(info->target,target); |
| 1344 | strcpyW(info->source,tmp_file); |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 1345 | TRACE("Start Asynchronous execution\n"); |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 1346 | FIXME("DATABASE NOT THREADSAFE... not starting\n"); |
| 1347 | /* CreateThread(NULL,0,DllThread,(LPVOID)&info,0,&ThreadId); */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1348 | /* FIXME: release the package if the CreateThread fails */ |
| 1349 | HeapFree( GetProcessHeap(), 0, info ); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 1350 | return ERROR_SUCCESS; |
| 1351 | } |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1352 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1353 | DLL = LoadLibraryW(tmp_file); |
| 1354 | if (DLL) |
| 1355 | { |
| 1356 | proc = strdupWtoA( target ); |
| 1357 | fn = (CustomEntry*)GetProcAddress(DLL,proc); |
| 1358 | if (fn) |
| 1359 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1360 | MSIHANDLE hPackage; |
| 1361 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1362 | TRACE("Calling function\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1363 | hPackage = msiobj_findhandle( &package->hdr ); |
| 1364 | if( !hPackage ) |
| 1365 | ERR("Handle for object %p not found\n", package ); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1366 | fn(hPackage); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1367 | msiobj_release( &package->hdr ); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1368 | } |
| 1369 | else |
| 1370 | ERR("Cannot load functon\n"); |
| 1371 | |
| 1372 | HeapFree(GetProcessHeap(),0,proc); |
| 1373 | FreeLibrary(DLL); |
| 1374 | } |
| 1375 | else |
| 1376 | ERR("Unable to load library\n"); |
| 1377 | |
| 1378 | return ERROR_SUCCESS; |
| 1379 | } |
| 1380 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1381 | static UINT HANDLE_CustomType2(MSIPACKAGE *package, const LPWSTR source, |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1382 | const LPWSTR target, const INT type) |
| 1383 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1384 | WCHAR tmp_file[MAX_PATH]; |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1385 | STARTUPINFOW si; |
| 1386 | PROCESS_INFORMATION info; |
| 1387 | BOOL rc; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1388 | INT len; |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1389 | WCHAR *deformated; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1390 | WCHAR *cmd; |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1391 | static const WCHAR spc[] = {' ',0}; |
| 1392 | |
| 1393 | memset(&si,0,sizeof(STARTUPINFOW)); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1394 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1395 | store_binary_to_temp(package, source, tmp_file); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1396 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1397 | deformat_string(package,target,&deformated); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1398 | |
| 1399 | len = strlenW(tmp_file) + strlenW(deformated) + 2; |
| 1400 | |
| 1401 | cmd = (WCHAR*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*len); |
| 1402 | |
| 1403 | strcpyW(cmd,tmp_file); |
| 1404 | strcatW(cmd,spc); |
| 1405 | strcatW(cmd,deformated); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1406 | |
| 1407 | HeapFree(GetProcessHeap(),0,deformated); |
| 1408 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1409 | TRACE("executing exe %s \n",debugstr_w(cmd)); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1410 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1411 | rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1412 | c_collen, &si, &info); |
| 1413 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1414 | HeapFree(GetProcessHeap(),0,cmd); |
| 1415 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1416 | if ( !rc ) |
| 1417 | { |
| 1418 | ERR("Unable to execute command\n"); |
| 1419 | return ERROR_SUCCESS; |
| 1420 | } |
| 1421 | |
| 1422 | if (!(type & 0xc0)) |
| 1423 | WaitForSingleObject(info.hProcess,INFINITE); |
| 1424 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1425 | CloseHandle( info.hProcess ); |
| 1426 | CloseHandle( info.hThread ); |
| 1427 | return ERROR_SUCCESS; |
| 1428 | } |
| 1429 | |
| 1430 | static UINT HANDLE_CustomType18(MSIPACKAGE *package, const LPWSTR source, |
| 1431 | const LPWSTR target, const INT type) |
| 1432 | { |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1433 | STARTUPINFOW si; |
| 1434 | PROCESS_INFORMATION info; |
| 1435 | BOOL rc; |
| 1436 | WCHAR *deformated; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1437 | WCHAR *cmd; |
| 1438 | INT len; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1439 | static const WCHAR spc[] = {' ',0}; |
| 1440 | int index; |
| 1441 | |
| 1442 | memset(&si,0,sizeof(STARTUPINFOW)); |
| 1443 | |
| 1444 | index = get_loaded_file(package,source); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1445 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1446 | len = strlenW(package->files[index].TargetPath); |
| 1447 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1448 | deformat_string(package,target,&deformated); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1449 | len += strlenW(deformated); |
| 1450 | len += 2; |
| 1451 | |
| 1452 | cmd = (WCHAR*)HeapAlloc(GetProcessHeap(),0,len * sizeof(WCHAR)); |
| 1453 | |
| 1454 | strcpyW(cmd, package->files[index].TargetPath); |
| 1455 | strcatW(cmd, spc); |
| 1456 | strcatW(cmd, deformated); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1457 | |
| 1458 | HeapFree(GetProcessHeap(),0,deformated); |
| 1459 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1460 | TRACE("executing exe %s \n",debugstr_w(cmd)); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1461 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1462 | rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1463 | c_collen, &si, &info); |
| 1464 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1465 | HeapFree(GetProcessHeap(),0,cmd); |
| 1466 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1467 | if ( !rc ) |
| 1468 | { |
| 1469 | ERR("Unable to execute command\n"); |
| 1470 | return ERROR_SUCCESS; |
| 1471 | } |
| 1472 | |
| 1473 | if (!(type & 0xc0)) |
| 1474 | WaitForSingleObject(info.hProcess,INFINITE); |
| 1475 | |
| 1476 | CloseHandle( info.hProcess ); |
| 1477 | CloseHandle( info.hThread ); |
| 1478 | return ERROR_SUCCESS; |
| 1479 | } |
| 1480 | |
| 1481 | static UINT HANDLE_CustomType50(MSIPACKAGE *package, const LPWSTR source, |
| 1482 | const LPWSTR target, const INT type) |
| 1483 | { |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1484 | STARTUPINFOW si; |
| 1485 | PROCESS_INFORMATION info; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1486 | WCHAR *prop; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1487 | BOOL rc; |
| 1488 | WCHAR *deformated; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1489 | WCHAR *cmd; |
| 1490 | INT len; |
| 1491 | UINT prc; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1492 | static const WCHAR spc[] = {' ',0}; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1493 | |
| 1494 | memset(&si,0,sizeof(STARTUPINFOW)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1495 | memset(&info,0,sizeof(PROCESS_INFORMATION)); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1496 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1497 | prop = load_dynamic_property(package,source,&prc); |
| 1498 | if (!prop) |
| 1499 | return prc; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1500 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1501 | deformat_string(package,target,&deformated); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1502 | len = strlenW(prop) + strlenW(deformated) + 2; |
| 1503 | cmd = (WCHAR*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*len); |
| 1504 | |
| 1505 | strcpyW(cmd,prop); |
| 1506 | strcatW(cmd,spc); |
| 1507 | strcatW(cmd,deformated); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1508 | |
| 1509 | HeapFree(GetProcessHeap(),0,deformated); |
| 1510 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1511 | TRACE("executing exe %s \n",debugstr_w(cmd)); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1512 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1513 | rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1514 | c_collen, &si, &info); |
| 1515 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1516 | HeapFree(GetProcessHeap(),0,cmd); |
| 1517 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1518 | if ( !rc ) |
| 1519 | { |
| 1520 | ERR("Unable to execute command\n"); |
| 1521 | return ERROR_SUCCESS; |
| 1522 | } |
| 1523 | |
| 1524 | if (!(type & 0xc0)) |
| 1525 | WaitForSingleObject(info.hProcess,INFINITE); |
| 1526 | |
| 1527 | CloseHandle( info.hProcess ); |
| 1528 | CloseHandle( info.hThread ); |
| 1529 | return ERROR_SUCCESS; |
| 1530 | } |
| 1531 | |
| 1532 | static UINT HANDLE_CustomType34(MSIPACKAGE *package, const LPWSTR source, |
| 1533 | const LPWSTR target, const INT type) |
| 1534 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1535 | LPWSTR filename, deformated; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1536 | STARTUPINFOW si; |
| 1537 | PROCESS_INFORMATION info; |
| 1538 | BOOL rc; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1539 | |
| 1540 | memset(&si,0,sizeof(STARTUPINFOW)); |
| 1541 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1542 | filename = resolve_folder(package, source, FALSE, FALSE, NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1543 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1544 | if (!filename) |
| 1545 | return ERROR_FUNCTION_FAILED; |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1546 | |
| 1547 | SetCurrentDirectoryW(filename); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1548 | HeapFree(GetProcessHeap(),0,filename); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1549 | |
| 1550 | deformat_string(package,target,&deformated); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1551 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1552 | TRACE("executing exe %s \n",debugstr_w(deformated)); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1553 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1554 | rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL, |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1555 | c_collen, &si, &info); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1556 | HeapFree(GetProcessHeap(),0,deformated); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1557 | |
| 1558 | if ( !rc ) |
| 1559 | { |
| 1560 | ERR("Unable to execute command\n"); |
| 1561 | return ERROR_SUCCESS; |
| 1562 | } |
| 1563 | |
| 1564 | if (!(type & 0xc0)) |
| 1565 | WaitForSingleObject(info.hProcess,INFINITE); |
| 1566 | |
| 1567 | CloseHandle( info.hProcess ); |
| 1568 | CloseHandle( info.hThread ); |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1569 | return ERROR_SUCCESS; |
| 1570 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1571 | |
| 1572 | /*********************************************************************** |
| 1573 | * create_full_pathW |
| 1574 | * |
| 1575 | * Recursively create all directories in the path. |
| 1576 | * |
| 1577 | * shamelessly stolen from setupapi/queue.c |
| 1578 | */ |
| 1579 | static BOOL create_full_pathW(const WCHAR *path) |
| 1580 | { |
| 1581 | BOOL ret = TRUE; |
| 1582 | int len; |
| 1583 | WCHAR *new_path; |
| 1584 | |
| 1585 | new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) * |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 1586 | sizeof(WCHAR)); |
| 1587 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1588 | strcpyW(new_path, path); |
| 1589 | |
| 1590 | while((len = strlenW(new_path)) && new_path[len - 1] == '\\') |
| 1591 | new_path[len - 1] = 0; |
| 1592 | |
| 1593 | while(!CreateDirectoryW(new_path, NULL)) |
| 1594 | { |
| 1595 | WCHAR *slash; |
| 1596 | DWORD last_error = GetLastError(); |
| 1597 | if(last_error == ERROR_ALREADY_EXISTS) |
| 1598 | break; |
| 1599 | |
| 1600 | if(last_error != ERROR_PATH_NOT_FOUND) |
| 1601 | { |
| 1602 | ret = FALSE; |
| 1603 | break; |
| 1604 | } |
| 1605 | |
| 1606 | if(!(slash = strrchrW(new_path, '\\'))) |
| 1607 | { |
| 1608 | ret = FALSE; |
| 1609 | break; |
| 1610 | } |
| 1611 | |
| 1612 | len = slash - new_path; |
| 1613 | new_path[len] = 0; |
| 1614 | if(!create_full_pathW(new_path)) |
| 1615 | { |
| 1616 | ret = FALSE; |
| 1617 | break; |
| 1618 | } |
| 1619 | new_path[len] = '\\'; |
| 1620 | } |
| 1621 | |
| 1622 | HeapFree(GetProcessHeap(), 0, new_path); |
| 1623 | return ret; |
| 1624 | } |
| 1625 | |
| 1626 | /* |
| 1627 | * Also we cannot enable/disable components either, so for now I am just going |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 1628 | * to do all the directories for all the components. |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1629 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1630 | static UINT ACTION_CreateFolders(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1631 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1632 | static const WCHAR ExecSeqQuery[] = { |
| 1633 | 's','e','l','e','c','t',' ','D','i','r','e','c','t','o','r','y','_',' ', |
| 1634 | 'f','r','o','m',' ','C','r','e','a','t','e','F','o','l','d','e','r',0 }; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1635 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1636 | MSIQUERY *view; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1637 | MSIFOLDER *folder; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1638 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1639 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view ); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1640 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1641 | return ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1642 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1643 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1644 | if (rc != ERROR_SUCCESS) |
| 1645 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1646 | MSI_ViewClose(view); |
| 1647 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1648 | return rc; |
| 1649 | } |
| 1650 | |
| 1651 | while (1) |
| 1652 | { |
| 1653 | WCHAR dir[0x100]; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1654 | LPWSTR full_path; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1655 | DWORD sz; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1656 | MSIRECORD *row = NULL, *uirow; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1657 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1658 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1659 | if (rc != ERROR_SUCCESS) |
| 1660 | { |
| 1661 | rc = ERROR_SUCCESS; |
| 1662 | break; |
| 1663 | } |
| 1664 | |
| 1665 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1666 | rc = MSI_RecordGetStringW(row,1,dir,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1667 | |
| 1668 | if (rc!= ERROR_SUCCESS) |
| 1669 | { |
| 1670 | ERR("Unable to get folder id \n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1671 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1672 | continue; |
| 1673 | } |
| 1674 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 1675 | sz = MAX_PATH; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1676 | full_path = resolve_folder(package,dir,FALSE,FALSE,&folder); |
| 1677 | if (!full_path) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1678 | { |
| 1679 | ERR("Unable to resolve folder id %s\n",debugstr_w(dir)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1680 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1681 | continue; |
| 1682 | } |
| 1683 | |
| 1684 | TRACE("Folder is %s\n",debugstr_w(full_path)); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1685 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1686 | /* UI stuff */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1687 | uirow = MSI_CreateRecord(1); |
| 1688 | MSI_RecordSetStringW(uirow,1,full_path); |
| 1689 | ui_actiondata(package,szCreateFolders,uirow); |
| 1690 | msiobj_release( &uirow->hdr ); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1691 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1692 | if (folder->State == 0) |
| 1693 | create_full_pathW(full_path); |
| 1694 | |
| 1695 | folder->State = 3; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1696 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1697 | msiobj_release(&row->hdr); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1698 | HeapFree(GetProcessHeap(),0,full_path); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1699 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1700 | MSI_ViewClose(view); |
| 1701 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1702 | |
| 1703 | return rc; |
| 1704 | } |
| 1705 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1706 | static int load_component(MSIPACKAGE* package, MSIRECORD * row) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1707 | { |
| 1708 | int index = package->loaded_components; |
| 1709 | DWORD sz; |
| 1710 | |
| 1711 | /* fill in the data */ |
| 1712 | |
| 1713 | package->loaded_components++; |
| 1714 | if (package->loaded_components == 1) |
| 1715 | package->components = HeapAlloc(GetProcessHeap(),0, |
| 1716 | sizeof(MSICOMPONENT)); |
| 1717 | else |
| 1718 | package->components = HeapReAlloc(GetProcessHeap(),0, |
| 1719 | package->components, package->loaded_components * |
| 1720 | sizeof(MSICOMPONENT)); |
| 1721 | |
| 1722 | memset(&package->components[index],0,sizeof(MSICOMPONENT)); |
| 1723 | |
| 1724 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1725 | MSI_RecordGetStringW(row,1,package->components[index].Component,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1726 | |
| 1727 | TRACE("Loading Component %s\n", |
| 1728 | debugstr_w(package->components[index].Component)); |
| 1729 | |
| 1730 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1731 | if (!MSI_RecordIsNull(row,2)) |
| 1732 | MSI_RecordGetStringW(row,2,package->components[index].ComponentId,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1733 | |
| 1734 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1735 | MSI_RecordGetStringW(row,3,package->components[index].Directory,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1736 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1737 | package->components[index].Attributes = MSI_RecordGetInteger(row,4); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1738 | |
| 1739 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1740 | MSI_RecordGetStringW(row,5,package->components[index].Condition,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1741 | |
| 1742 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1743 | MSI_RecordGetStringW(row,6,package->components[index].KeyPath,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1744 | |
| 1745 | package->components[index].State = INSTALLSTATE_UNKNOWN; |
| 1746 | package->components[index].Enabled = TRUE; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1747 | package->components[index].FeatureState= FALSE; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1748 | |
| 1749 | return index; |
| 1750 | } |
| 1751 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1752 | static void load_feature(MSIPACKAGE* package, MSIRECORD * row) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1753 | { |
| 1754 | int index = package->loaded_features; |
| 1755 | DWORD sz; |
| 1756 | static const WCHAR Query1[] = {'S','E','L','E','C','T',' ','C','o','m','p', |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1757 | 'o','n','e','n','t','_',' ','F','R','O','M',' ','F','e','a','t','u','r','e', |
| 1758 | 'C','o','m','p','o','n','e','n','t','s',' ','W','H','E','R','E',' ','F','e', |
| 1759 | 'a','t','u','r','e','_','=','\'','%','s','\'',0}; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1760 | static const WCHAR Query2[] = {'S','E','L','E','C','T',' ','*',' ','F','R', |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1761 | 'O','M',' ','C','o','m','p','o','n','e','n','t',' ','W','H','E','R','E',' ','C', |
| 1762 | 'o','m','p','o','n','e','n','t','=','\'','%','s','\'',0}; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1763 | MSIQUERY * view; |
| 1764 | MSIQUERY * view2; |
| 1765 | MSIRECORD * row2; |
| 1766 | MSIRECORD * row3; |
| 1767 | UINT rc; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1768 | |
| 1769 | /* fill in the data */ |
| 1770 | |
| 1771 | package->loaded_features ++; |
| 1772 | if (package->loaded_features == 1) |
| 1773 | package->features = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFEATURE)); |
| 1774 | else |
| 1775 | package->features = HeapReAlloc(GetProcessHeap(),0,package->features, |
| 1776 | package->loaded_features * sizeof(MSIFEATURE)); |
| 1777 | |
| 1778 | memset(&package->features[index],0,sizeof(MSIFEATURE)); |
| 1779 | |
| 1780 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1781 | MSI_RecordGetStringW(row,1,package->features[index].Feature,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1782 | |
| 1783 | TRACE("Loading feature %s\n",debugstr_w(package->features[index].Feature)); |
| 1784 | |
| 1785 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1786 | if (!MSI_RecordIsNull(row,2)) |
| 1787 | MSI_RecordGetStringW(row,2,package->features[index].Feature_Parent,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1788 | |
| 1789 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1790 | if (!MSI_RecordIsNull(row,3)) |
| 1791 | MSI_RecordGetStringW(row,3,package->features[index].Title,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1792 | |
| 1793 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1794 | if (!MSI_RecordIsNull(row,4)) |
| 1795 | MSI_RecordGetStringW(row,4,package->features[index].Description,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1796 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1797 | if (!MSI_RecordIsNull(row,5)) |
| 1798 | package->features[index].Display = MSI_RecordGetInteger(row,5); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1799 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1800 | package->features[index].Level= MSI_RecordGetInteger(row,6); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1801 | |
| 1802 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1803 | if (!MSI_RecordIsNull(row,7)) |
| 1804 | MSI_RecordGetStringW(row,7,package->features[index].Directory,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1805 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1806 | package->features[index].Attributes= MSI_RecordGetInteger(row,8); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1807 | package->features[index].State = INSTALLSTATE_UNKNOWN; |
| 1808 | |
| 1809 | /* load feature components */ |
| 1810 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1811 | rc = ACTION_OpenQuery(package->db, &view, Query1, package->features[index].Feature); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1812 | if (rc != ERROR_SUCCESS) |
| 1813 | return; |
| 1814 | rc = MSI_ViewExecute(view,0); |
| 1815 | if (rc != ERROR_SUCCESS) |
| 1816 | { |
| 1817 | MSI_ViewClose(view); |
| 1818 | msiobj_release(&view->hdr); |
| 1819 | return; |
| 1820 | } |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1821 | while (1) |
| 1822 | { |
| 1823 | DWORD sz = 0x100; |
| 1824 | WCHAR buffer[0x100]; |
| 1825 | DWORD rc; |
| 1826 | INT c_indx; |
| 1827 | INT cnt = package->features[index].ComponentCount; |
| 1828 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1829 | rc = MSI_ViewFetch(view,&row2); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1830 | if (rc != ERROR_SUCCESS) |
| 1831 | break; |
| 1832 | |
| 1833 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1834 | MSI_RecordGetStringW(row2,1,buffer,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1835 | |
| 1836 | /* check to see if the component is already loaded */ |
| 1837 | c_indx = get_loaded_component(package,buffer); |
| 1838 | if (c_indx != -1) |
| 1839 | { |
| 1840 | TRACE("Component %s already loaded at %i\n", debugstr_w(buffer), |
| 1841 | c_indx); |
| 1842 | package->features[index].Components[cnt] = c_indx; |
| 1843 | package->features[index].ComponentCount ++; |
| 1844 | } |
| 1845 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1846 | rc = ACTION_OpenQuery(package->db, &view2, Query2, buffer); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1847 | if (rc != ERROR_SUCCESS) |
| 1848 | { |
| 1849 | msiobj_release( &row2->hdr ); |
| 1850 | continue; |
| 1851 | } |
| 1852 | rc = MSI_ViewExecute(view2,0); |
| 1853 | if (rc != ERROR_SUCCESS) |
| 1854 | { |
| 1855 | msiobj_release( &row2->hdr ); |
| 1856 | MSI_ViewClose(view2); |
| 1857 | msiobj_release( &view2->hdr ); |
| 1858 | continue; |
| 1859 | } |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1860 | while (1) |
| 1861 | { |
| 1862 | DWORD rc; |
| 1863 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1864 | rc = MSI_ViewFetch(view2,&row3); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1865 | if (rc != ERROR_SUCCESS) |
| 1866 | break; |
| 1867 | c_indx = load_component(package,row3); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1868 | msiobj_release( &row3->hdr ); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1869 | |
| 1870 | package->features[index].Components[cnt] = c_indx; |
| 1871 | package->features[index].ComponentCount ++; |
| 1872 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1873 | MSI_ViewClose(view2); |
| 1874 | msiobj_release( &view2->hdr ); |
| 1875 | msiobj_release( &row2->hdr ); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1876 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1877 | MSI_ViewClose(view); |
| 1878 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1879 | } |
| 1880 | |
| 1881 | /* |
| 1882 | * I am not doing any of the costing functionality yet. |
| 1883 | * Mostly looking at doing the Component and Feature loading |
| 1884 | * |
| 1885 | * The native MSI does ALOT of modification to tables here. Mostly adding alot |
| 1886 | * of temporary columns to the Feature and Component tables. |
| 1887 | * |
Mike McCormack | 24e9a34 | 2004-07-06 18:56:12 +0000 | [diff] [blame] | 1888 | * note: native msi also tracks the short filename. but I am only going to |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1889 | * track the long ones. Also looking at this directory table |
| 1890 | * it appears that the directory table does not get the parents |
| 1891 | * resolved base on property only based on their entrys in the |
| 1892 | * directory table. |
| 1893 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1894 | static UINT ACTION_CostInitialize(MSIPACKAGE *package) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1895 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1896 | MSIQUERY * view; |
| 1897 | MSIRECORD * row; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1898 | UINT rc; |
| 1899 | static const WCHAR Query_all[] = { |
| 1900 | 'S','E','L','E','C','T',' ','*',' ', |
| 1901 | 'F','R','O','M',' ','F','e','a','t','u','r','e',0}; |
| 1902 | static const WCHAR szCosting[] = { |
| 1903 | 'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 }; |
| 1904 | static const WCHAR szZero[] = { '0', 0 }; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1905 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1906 | MSI_SetPropertyW(package, szCosting, szZero); |
| 1907 | MSI_SetPropertyW(package, cszRootDrive , c_collen); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1908 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1909 | rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view); |
| 1910 | if (rc != ERROR_SUCCESS) |
| 1911 | return rc; |
| 1912 | rc = MSI_ViewExecute(view,0); |
| 1913 | if (rc != ERROR_SUCCESS) |
| 1914 | { |
| 1915 | MSI_ViewClose(view); |
| 1916 | msiobj_release(&view->hdr); |
| 1917 | return rc; |
| 1918 | } |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1919 | while (1) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1920 | { |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1921 | DWORD rc; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1922 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1923 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1924 | if (rc != ERROR_SUCCESS) |
| 1925 | break; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1926 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1927 | load_feature(package,row); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1928 | msiobj_release(&row->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1929 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1930 | MSI_ViewClose(view); |
| 1931 | msiobj_release(&view->hdr); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1932 | |
| 1933 | return ERROR_SUCCESS; |
| 1934 | } |
| 1935 | |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1936 | static UINT load_file(MSIPACKAGE* package, MSIRECORD * row) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1937 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1938 | DWORD index = package->loaded_files; |
| 1939 | DWORD i; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1940 | LPWSTR buffer; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1941 | |
| 1942 | /* fill in the data */ |
| 1943 | |
| 1944 | package->loaded_files++; |
| 1945 | if (package->loaded_files== 1) |
| 1946 | package->files = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE)); |
| 1947 | else |
| 1948 | package->files = HeapReAlloc(GetProcessHeap(),0, |
| 1949 | package->files , package->loaded_files * sizeof(MSIFILE)); |
| 1950 | |
| 1951 | memset(&package->files[index],0,sizeof(MSIFILE)); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1952 | |
| 1953 | package->files[index].File = load_dynamic_stringW(row, 1); |
| 1954 | buffer = load_dynamic_stringW(row, 2); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1955 | |
| 1956 | package->files[index].ComponentIndex = -1; |
| 1957 | for (i = 0; i < package->loaded_components; i++) |
| 1958 | if (strcmpW(package->components[i].Component,buffer)==0) |
| 1959 | { |
| 1960 | package->files[index].ComponentIndex = i; |
| 1961 | break; |
| 1962 | } |
| 1963 | if (package->files[index].ComponentIndex == -1) |
| 1964 | ERR("Unfound Component %s\n",debugstr_w(buffer)); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1965 | HeapFree(GetProcessHeap(), 0, buffer); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1966 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1967 | package->files[index].FileName = load_dynamic_stringW(row,3); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1968 | |
| 1969 | reduce_to_longfilename(package->files[index].FileName); |
| 1970 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1971 | package->files[index].FileSize = MSI_RecordGetInteger(row,4); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1972 | package->files[index].Version = load_dynamic_stringW(row, 5); |
| 1973 | package->files[index].Language = load_dynamic_stringW(row, 6); |
| 1974 | package->files[index].Attributes= MSI_RecordGetInteger(row,7); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1975 | package->files[index].Sequence= MSI_RecordGetInteger(row,8); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1976 | |
| 1977 | package->files[index].Temporary = FALSE; |
| 1978 | package->files[index].State = 0; |
| 1979 | |
| 1980 | TRACE("File Loaded (%s)\n",debugstr_w(package->files[index].File)); |
| 1981 | |
| 1982 | return ERROR_SUCCESS; |
| 1983 | } |
| 1984 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1985 | static UINT ACTION_FileCost(MSIPACKAGE *package) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1986 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1987 | MSIQUERY * view; |
| 1988 | MSIRECORD * row; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1989 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1990 | static const WCHAR Query[] = { |
| 1991 | 'S','E','L','E','C','T',' ','*',' ', |
| 1992 | 'F','R','O','M',' ','F','i','l','e',' ', |
| 1993 | 'O','r','d','e','r',' ','b','y',' ','S','e','q','u','e','n','c','e', 0}; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1994 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1995 | if (!package) |
| 1996 | return ERROR_INVALID_HANDLE; |
| 1997 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1998 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1999 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2000 | return ERROR_SUCCESS; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2001 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2002 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2003 | if (rc != ERROR_SUCCESS) |
| 2004 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2005 | MSI_ViewClose(view); |
| 2006 | msiobj_release(&view->hdr); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2007 | return ERROR_SUCCESS; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2008 | } |
| 2009 | |
| 2010 | while (1) |
| 2011 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2012 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2013 | if (rc != ERROR_SUCCESS) |
| 2014 | { |
| 2015 | rc = ERROR_SUCCESS; |
| 2016 | break; |
| 2017 | } |
| 2018 | load_file(package,row); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2019 | msiobj_release(&row->hdr); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2020 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2021 | MSI_ViewClose(view); |
| 2022 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2023 | |
| 2024 | return ERROR_SUCCESS; |
| 2025 | } |
| 2026 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2027 | static INT load_folder(MSIPACKAGE *package, const WCHAR* dir) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2028 | |
| 2029 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2030 | static const WCHAR Query[] = |
| 2031 | {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','D','i','r','e','c', |
| 2032 | 't','o','r','y',' ','w','h','e','r','e',' ','`','D','i','r','e','c','t', |
| 2033 | 'o','r','y','`',' ','=',' ','`','%','s','`',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2034 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2035 | MSIQUERY * view; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2036 | LPWSTR targetdir, parent, srcdir; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2037 | MSIRECORD * row = 0; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2038 | INT index = -1; |
| 2039 | DWORD i; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 2040 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2041 | TRACE("Looking for dir %s\n",debugstr_w(dir)); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2042 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2043 | for (i = 0; i < package->loaded_folders; i++) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2044 | { |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2045 | if (strcmpW(package->folders[i].Directory,dir)==0) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2046 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2047 | TRACE(" %s retuning on index %lu\n",debugstr_w(dir),i); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2048 | return i; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2049 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2050 | } |
| 2051 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2052 | TRACE("Working to load %s\n",debugstr_w(dir)); |
| 2053 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2054 | index = package->loaded_folders++; |
| 2055 | if (package->loaded_folders==1) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2056 | package->folders = HeapAlloc(GetProcessHeap(),0, |
| 2057 | sizeof(MSIFOLDER)); |
| 2058 | else |
| 2059 | package->folders= HeapReAlloc(GetProcessHeap(),0, |
| 2060 | package->folders, package->loaded_folders* |
| 2061 | sizeof(MSIFOLDER)); |
| 2062 | |
| 2063 | memset(&package->folders[index],0,sizeof(MSIFOLDER)); |
| 2064 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2065 | package->folders[index].Directory = dupstrW(dir); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2066 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2067 | rc = ACTION_OpenQuery(package->db, &view, Query, dir); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2068 | if (rc != ERROR_SUCCESS) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2069 | return -1; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2070 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2071 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2072 | if (rc != ERROR_SUCCESS) |
| 2073 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2074 | MSI_ViewClose(view); |
| 2075 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2076 | return -1; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2077 | } |
| 2078 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2079 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2080 | if (rc != ERROR_SUCCESS) |
| 2081 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2082 | MSI_ViewClose(view); |
| 2083 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2084 | return -1; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2085 | } |
| 2086 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2087 | targetdir = load_dynamic_stringW(row,3); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2088 | |
| 2089 | /* split src and target dir */ |
| 2090 | if (strchrW(targetdir,':')) |
| 2091 | { |
| 2092 | srcdir=strchrW(targetdir,':'); |
| 2093 | *srcdir=0; |
| 2094 | srcdir ++; |
| 2095 | } |
| 2096 | else |
| 2097 | srcdir=NULL; |
| 2098 | |
| 2099 | /* for now only pick long filename versions */ |
| 2100 | if (strchrW(targetdir,'|')) |
| 2101 | { |
| 2102 | targetdir = strchrW(targetdir,'|'); |
| 2103 | *targetdir = 0; |
| 2104 | targetdir ++; |
| 2105 | } |
| 2106 | if (srcdir && strchrW(srcdir,'|')) |
| 2107 | { |
| 2108 | srcdir= strchrW(srcdir,'|'); |
| 2109 | *srcdir= 0; |
| 2110 | srcdir ++; |
| 2111 | } |
| 2112 | |
| 2113 | /* now check for root dirs */ |
| 2114 | if (targetdir[0] == '.' && targetdir[1] == 0) |
| 2115 | targetdir = NULL; |
| 2116 | |
| 2117 | if (srcdir && srcdir[0] == '.' && srcdir[1] == 0) |
| 2118 | srcdir = NULL; |
| 2119 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2120 | if (targetdir) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2121 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2122 | TRACE(" TargetDefault = %s\n",debugstr_w(targetdir)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2123 | if (package->folders[index].TargetDefault) |
| 2124 | HeapFree(GetProcessHeap(),0, package->folders[index].TargetDefault); |
| 2125 | package->folders[index].TargetDefault = dupstrW(targetdir); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2126 | } |
| 2127 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2128 | if (srcdir) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2129 | package->folders[index].SourceDefault = dupstrW(srcdir); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2130 | else if (targetdir) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2131 | package->folders[index].SourceDefault = dupstrW(targetdir); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2132 | HeapFree(GetProcessHeap(), 0, targetdir); |
| 2133 | |
| 2134 | parent = load_dynamic_stringW(row,2); |
| 2135 | if (parent) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2136 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2137 | i = load_folder(package,parent); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2138 | package->folders[index].ParentIndex = i; |
| 2139 | TRACE("Parent is index %i... %s %s\n", |
| 2140 | package->folders[index].ParentIndex, |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2141 | debugstr_w(package->folders[package->folders[index].ParentIndex].Directory), |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2142 | debugstr_w(parent)); |
| 2143 | } |
| 2144 | else |
| 2145 | package->folders[index].ParentIndex = -2; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2146 | HeapFree(GetProcessHeap(), 0, parent); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2147 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2148 | package->folders[index].Property = load_dynamic_property(package, dir,NULL); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2149 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2150 | msiobj_release(&row->hdr); |
| 2151 | MSI_ViewClose(view); |
| 2152 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2153 | TRACE(" %s retuning on index %i\n",debugstr_w(dir),index); |
| 2154 | return index; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2155 | } |
| 2156 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2157 | |
| 2158 | static LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2159 | BOOL source, BOOL set_prop, MSIFOLDER **folder) |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 2160 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2161 | DWORD i; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2162 | LPWSTR p, path = NULL; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2163 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2164 | TRACE("Working to resolve %s\n",debugstr_w(name)); |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2165 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2166 | /* special resolving for Target and Source root dir */ |
| 2167 | if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2168 | { |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2169 | if (!source) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2170 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2171 | path = load_dynamic_property(package,cszTargetDir,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2172 | if (!path) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2173 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2174 | path = load_dynamic_property(package,cszRootDrive,NULL); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2175 | if (set_prop) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2176 | MSI_SetPropertyW(package,cszTargetDir,path); |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2177 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2178 | if (folder) |
| 2179 | *folder = &(package->folders[0]); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2180 | return path; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2181 | } |
| 2182 | else |
| 2183 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2184 | path = load_dynamic_property(package,cszSourceDir,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2185 | if (!path) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2186 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2187 | path = load_dynamic_property(package,cszDatabase,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2188 | if (path) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2189 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2190 | p = strrchrW(path,'\\'); |
| 2191 | if (p) |
| 2192 | *p++ = 0; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2193 | } |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2194 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2195 | if (folder) |
| 2196 | *folder = &(package->folders[0]); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2197 | return path; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2198 | } |
| 2199 | } |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2200 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2201 | for (i = 0; i < package->loaded_folders; i++) |
| 2202 | { |
| 2203 | if (strcmpW(package->folders[i].Directory,name)==0) |
| 2204 | break; |
| 2205 | } |
| 2206 | |
| 2207 | if (i >= package->loaded_folders) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2208 | return NULL; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2209 | |
| 2210 | if (folder) |
| 2211 | *folder = &(package->folders[i]); |
| 2212 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2213 | if (!source && package->folders[i].ResolvedTarget) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2214 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2215 | path = dupstrW(package->folders[i].ResolvedTarget); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2216 | TRACE(" already resolved to %s\n",debugstr_w(path)); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2217 | return path; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2218 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2219 | else if (source && package->folders[i].ResolvedSource) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2220 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2221 | path = dupstrW(package->folders[i].ResolvedSource); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2222 | return path; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2223 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2224 | else if (!source && package->folders[i].Property) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2225 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2226 | path = dupstrW(package->folders[i].Property); |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2227 | TRACE(" internally set to %s\n",debugstr_w(path)); |
| 2228 | if (set_prop) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2229 | MSI_SetPropertyW(package,name,path); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2230 | return path; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2231 | } |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2232 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2233 | if (package->folders[i].ParentIndex >= 0) |
| 2234 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2235 | LPWSTR parent = package->folders[package->folders[i].ParentIndex].Directory; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2236 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2237 | TRACE(" ! Parent is %s\n", debugstr_w(parent)); |
Robert Shearman | dce07c4 | 2004-09-17 18:11:14 +0000 | [diff] [blame] | 2238 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2239 | p = resolve_folder(package, parent, source, set_prop, NULL); |
Aric Stewart | 1ab0e41 | 2004-07-06 18:42:56 +0000 | [diff] [blame] | 2240 | if (!source) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2241 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2242 | TRACE(" TargetDefault = %s\n",debugstr_w(package->folders[i].TargetDefault)); |
| 2243 | path = build_directory_name(3, p, package->folders[i].TargetDefault, NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2244 | package->folders[i].ResolvedTarget = dupstrW(path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2245 | TRACE(" resolved into %s\n",debugstr_w(path)); |
| 2246 | if (set_prop) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2247 | MSI_SetPropertyW(package,name,path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2248 | } |
Aric Stewart | 1ab0e41 | 2004-07-06 18:42:56 +0000 | [diff] [blame] | 2249 | else |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2250 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2251 | path = build_directory_name(3, p, package->folders[i].SourceDefault, NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2252 | package->folders[i].ResolvedSource = dupstrW(path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2253 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2254 | HeapFree(GetProcessHeap(),0,p); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2255 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2256 | return path; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 2257 | } |
| 2258 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2259 | /* |
| 2260 | * Alot is done in this function aside from just the costing. |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 2261 | * The costing needs to be implemented at some point but for now I am going |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2262 | * to focus on the directory building |
| 2263 | * |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2264 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2265 | static UINT ACTION_CostFinalize(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2266 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2267 | static const WCHAR ExecSeqQuery[] = { |
| 2268 | 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ', |
| 2269 | 'D','i','r','e','c','t','o','r','y',0}; |
| 2270 | static const WCHAR ConditionQuery[] = { |
| 2271 | 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ', |
| 2272 | 'C','o','n','d','i','t','i','o','n',0}; |
| 2273 | static const WCHAR szCosting[] = { |
| 2274 | 'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 }; |
| 2275 | static const WCHAR szOne[] = { '1', 0 }; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2276 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2277 | MSIQUERY * view; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2278 | DWORD i; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 2279 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2280 | TRACE("Building Directory properties\n"); |
| 2281 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2282 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2283 | if (rc == ERROR_SUCCESS) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2284 | { |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2285 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2286 | if (rc != ERROR_SUCCESS) |
| 2287 | { |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2288 | MSI_ViewClose(view); |
| 2289 | msiobj_release(&view->hdr); |
| 2290 | return rc; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2291 | } |
| 2292 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2293 | while (1) |
| 2294 | { |
| 2295 | WCHAR name[0x100]; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2296 | LPWSTR path; |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2297 | MSIRECORD * row = 0; |
| 2298 | DWORD sz; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2299 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2300 | rc = MSI_ViewFetch(view,&row); |
| 2301 | if (rc != ERROR_SUCCESS) |
| 2302 | { |
| 2303 | rc = ERROR_SUCCESS; |
| 2304 | break; |
| 2305 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2306 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2307 | sz=0x100; |
| 2308 | MSI_RecordGetStringW(row,1,name,&sz); |
| 2309 | |
| 2310 | /* This helper function now does ALL the work */ |
| 2311 | TRACE("Dir %s ...\n",debugstr_w(name)); |
| 2312 | load_folder(package,name); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2313 | path = resolve_folder(package,name,FALSE,TRUE,NULL); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2314 | TRACE("resolves to %s\n",debugstr_w(path)); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2315 | HeapFree( GetProcessHeap(), 0, path); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2316 | |
| 2317 | msiobj_release(&row->hdr); |
| 2318 | } |
| 2319 | MSI_ViewClose(view); |
| 2320 | msiobj_release(&view->hdr); |
| 2321 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2322 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2323 | TRACE("File calculations %i files\n",package->loaded_files); |
| 2324 | |
| 2325 | for (i = 0; i < package->loaded_files; i++) |
| 2326 | { |
| 2327 | MSICOMPONENT* comp = NULL; |
| 2328 | MSIFILE* file= NULL; |
| 2329 | |
| 2330 | file = &package->files[i]; |
| 2331 | if (file->ComponentIndex >= 0) |
| 2332 | comp = &package->components[file->ComponentIndex]; |
| 2333 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2334 | if (file->Temporary == TRUE) |
| 2335 | continue; |
| 2336 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2337 | if (comp) |
| 2338 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2339 | LPWSTR p; |
| 2340 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2341 | /* calculate target */ |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2342 | p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2343 | |
| 2344 | if (file->TargetPath) |
| 2345 | HeapFree(GetProcessHeap(),0,file->TargetPath); |
| 2346 | |
| 2347 | TRACE("file %s is named %s\n", |
| 2348 | debugstr_w(file->File),debugstr_w(file->FileName)); |
| 2349 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2350 | file->TargetPath = build_directory_name(2, p, file->FileName); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2351 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2352 | HeapFree(GetProcessHeap(),0,p); |
| 2353 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2354 | TRACE("file %s resolves to %s\n", |
| 2355 | debugstr_w(file->File),debugstr_w(file->TargetPath)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2356 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2357 | if (GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES) |
| 2358 | { |
| 2359 | file->State = 1; |
| 2360 | comp->Cost += file->FileSize; |
| 2361 | } |
| 2362 | else |
| 2363 | { |
| 2364 | if (file->Version[0]) |
| 2365 | { |
| 2366 | DWORD handle; |
| 2367 | DWORD versize; |
| 2368 | UINT sz; |
| 2369 | LPVOID version; |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2370 | static const WCHAR name[] = |
| 2371 | {'\\',0}; |
| 2372 | static const WCHAR name_fmt[] = |
| 2373 | {'%','u','.','%','u','.','%','u','.','%','u',0}; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2374 | WCHAR filever[0x100]; |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2375 | VS_FIXEDFILEINFO *lpVer; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2376 | |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2377 | FIXME("Version comparison.. \n"); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2378 | versize = GetFileVersionInfoSizeW(file->TargetPath,&handle); |
| 2379 | version = HeapAlloc(GetProcessHeap(),0,versize); |
| 2380 | GetFileVersionInfoW(file->TargetPath, 0, versize, version); |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2381 | |
| 2382 | VerQueryValueW(version, name, (LPVOID*)&lpVer, &sz); |
| 2383 | |
| 2384 | sprintfW(filever,name_fmt, |
| 2385 | HIWORD(lpVer->dwFileVersionMS), |
| 2386 | LOWORD(lpVer->dwFileVersionMS), |
| 2387 | HIWORD(lpVer->dwFileVersionLS), |
| 2388 | LOWORD(lpVer->dwFileVersionLS)); |
| 2389 | |
| 2390 | TRACE("new %s old %s\n", debugstr_w(file->Version), |
| 2391 | debugstr_w(filever)); |
| 2392 | if (strcmpiW(filever,file->Version)<0) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2393 | { |
| 2394 | file->State = 2; |
| 2395 | FIXME("cost should be diff in size\n"); |
| 2396 | comp->Cost += file->FileSize; |
| 2397 | } |
| 2398 | else |
| 2399 | file->State = 3; |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2400 | HeapFree(GetProcessHeap(),0,version); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2401 | } |
| 2402 | else |
| 2403 | file->State = 3; |
| 2404 | } |
| 2405 | } |
| 2406 | } |
| 2407 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2408 | TRACE("Evaluating Condition Table\n"); |
Aric Stewart | 2e9b5f7 | 2004-07-04 00:31:17 +0000 | [diff] [blame] | 2409 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2410 | rc = MSI_DatabaseOpenViewW(package->db, ConditionQuery, &view); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2411 | if (rc == ERROR_SUCCESS) |
| 2412 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2413 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2414 | if (rc != ERROR_SUCCESS) |
| 2415 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2416 | MSI_ViewClose(view); |
| 2417 | msiobj_release(&view->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2418 | return rc; |
| 2419 | } |
| 2420 | |
| 2421 | while (1) |
| 2422 | { |
| 2423 | WCHAR Feature[0x100]; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2424 | MSIRECORD * row = 0; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2425 | DWORD sz; |
| 2426 | int feature_index; |
| 2427 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2428 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2429 | |
| 2430 | if (rc != ERROR_SUCCESS) |
| 2431 | { |
| 2432 | rc = ERROR_SUCCESS; |
| 2433 | break; |
| 2434 | } |
| 2435 | |
| 2436 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2437 | MSI_RecordGetStringW(row,1,Feature,&sz); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2438 | |
| 2439 | feature_index = get_loaded_feature(package,Feature); |
| 2440 | if (feature_index < 0) |
| 2441 | ERR("FAILED to find loaded feature %s\n",debugstr_w(Feature)); |
| 2442 | else |
| 2443 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 2444 | LPWSTR Condition; |
| 2445 | Condition = load_dynamic_stringW(row,3); |
| 2446 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2447 | if (MSI_EvaluateConditionW(package,Condition) == |
| 2448 | MSICONDITION_TRUE) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2449 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2450 | int level = MSI_RecordGetInteger(row,2); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2451 | TRACE("Reseting feature %s to level %i\n", |
| 2452 | debugstr_w(Feature), level); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2453 | package->features[feature_index].Level = level; |
| 2454 | } |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 2455 | HeapFree(GetProcessHeap(),0,Condition); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2456 | } |
| 2457 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2458 | msiobj_release(&row->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2459 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2460 | MSI_ViewClose(view); |
| 2461 | msiobj_release(&view->hdr); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2462 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2463 | |
| 2464 | TRACE("Enabling or Disabling Components\n"); |
| 2465 | for (i = 0; i < package->loaded_components; i++) |
| 2466 | { |
| 2467 | if (package->components[i].Condition[0]) |
| 2468 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2469 | if (MSI_EvaluateConditionW(package, |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2470 | package->components[i].Condition) == MSICONDITION_FALSE) |
| 2471 | { |
| 2472 | TRACE("Disabling component %s\n", |
| 2473 | debugstr_w(package->components[i].Component)); |
| 2474 | package->components[i].Enabled = FALSE; |
| 2475 | } |
| 2476 | } |
| 2477 | } |
| 2478 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2479 | MSI_SetPropertyW(package,szCosting,szOne); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2480 | return ERROR_SUCCESS; |
| 2481 | } |
| 2482 | |
| 2483 | /* |
| 2484 | * This is a helper function for handling embedded cabinet media |
| 2485 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2486 | static UINT writeout_cabinet_stream(MSIPACKAGE *package, WCHAR* stream_name, |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2487 | WCHAR* source) |
| 2488 | { |
| 2489 | UINT rc; |
| 2490 | USHORT* data; |
| 2491 | UINT size; |
| 2492 | DWORD write; |
| 2493 | HANDLE the_file; |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2494 | WCHAR tmp[MAX_PATH]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2495 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2496 | rc = read_raw_stream_data(package->db,stream_name,&data,&size); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2497 | if (rc != ERROR_SUCCESS) |
| 2498 | return rc; |
| 2499 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2500 | write = MAX_PATH; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2501 | if (MSI_GetPropertyW(package, cszTempFolder, tmp, &write)) |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2502 | GetTempPathW(MAX_PATH,tmp); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2503 | |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2504 | GetTempFileNameW(tmp,stream_name,0,source); |
| 2505 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2506 | track_tempfile(package,strrchrW(source,'\\'), source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2507 | the_file = CreateFileW(source, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, |
| 2508 | FILE_ATTRIBUTE_NORMAL, NULL); |
| 2509 | |
| 2510 | if (the_file == INVALID_HANDLE_VALUE) |
| 2511 | { |
| 2512 | rc = ERROR_FUNCTION_FAILED; |
| 2513 | goto end; |
| 2514 | } |
| 2515 | |
| 2516 | WriteFile(the_file,data,size,&write,NULL); |
| 2517 | CloseHandle(the_file); |
| 2518 | TRACE("wrote %li bytes to %s\n",write,debugstr_w(source)); |
| 2519 | end: |
| 2520 | HeapFree(GetProcessHeap(),0,data); |
| 2521 | return rc; |
| 2522 | } |
| 2523 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2524 | |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2525 | /* Support functions for FDI functions */ |
| 2526 | |
| 2527 | static void * cabinet_alloc(ULONG cb) |
| 2528 | { |
| 2529 | return HeapAlloc(GetProcessHeap(), 0, cb); |
| 2530 | } |
| 2531 | |
| 2532 | static void cabinet_free(void *pv) |
| 2533 | { |
| 2534 | HeapFree(GetProcessHeap(), 0, pv); |
| 2535 | } |
| 2536 | |
| 2537 | static INT_PTR cabinet_open(char *pszFile, int oflag, int pmode) |
| 2538 | { |
| 2539 | DWORD dwAccess = 0; |
| 2540 | DWORD dwShareMode = 0; |
| 2541 | DWORD dwCreateDisposition = OPEN_EXISTING; |
| 2542 | switch (oflag & _O_ACCMODE) |
| 2543 | { |
| 2544 | case _O_RDONLY: |
| 2545 | dwAccess = GENERIC_READ; |
| 2546 | dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE; |
| 2547 | break; |
| 2548 | case _O_WRONLY: |
| 2549 | dwAccess = GENERIC_WRITE; |
| 2550 | dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; |
| 2551 | break; |
| 2552 | case _O_RDWR: |
| 2553 | dwAccess = GENERIC_READ | GENERIC_WRITE; |
| 2554 | dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; |
| 2555 | break; |
| 2556 | } |
| 2557 | if ((oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) |
| 2558 | dwCreateDisposition = CREATE_NEW; |
| 2559 | else if (oflag & _O_CREAT) |
| 2560 | dwCreateDisposition = CREATE_ALWAYS; |
| 2561 | return (INT_PTR)CreateFileA(pszFile, dwAccess, dwShareMode, NULL, dwCreateDisposition, 0, NULL); |
| 2562 | } |
| 2563 | |
| 2564 | static UINT cabinet_read(INT_PTR hf, void *pv, UINT cb) |
| 2565 | { |
| 2566 | DWORD dwRead; |
| 2567 | if (ReadFile((HANDLE)hf, pv, cb, &dwRead, NULL)) |
| 2568 | return dwRead; |
| 2569 | return 0; |
| 2570 | } |
| 2571 | |
| 2572 | static UINT cabinet_write(INT_PTR hf, void *pv, UINT cb) |
| 2573 | { |
| 2574 | DWORD dwWritten; |
| 2575 | if (WriteFile((HANDLE)hf, pv, cb, &dwWritten, NULL)) |
| 2576 | return dwWritten; |
| 2577 | return 0; |
| 2578 | } |
| 2579 | |
| 2580 | static int cabinet_close(INT_PTR hf) |
| 2581 | { |
| 2582 | return CloseHandle((HANDLE)hf) ? 0 : -1; |
| 2583 | } |
| 2584 | |
| 2585 | static long cabinet_seek(INT_PTR hf, long dist, int seektype) |
| 2586 | { |
| 2587 | /* flags are compatible and so are passed straight through */ |
| 2588 | return SetFilePointer((HANDLE)hf, dist, NULL, seektype); |
| 2589 | } |
| 2590 | |
| 2591 | static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin) |
| 2592 | { |
| 2593 | /* FIXME: try to do more processing in this function */ |
| 2594 | switch (fdint) |
| 2595 | { |
| 2596 | case fdintCOPY_FILE: |
| 2597 | { |
| 2598 | ULONG len = strlen((char*)pfdin->pv) + strlen(pfdin->psz1); |
| 2599 | char *file = cabinet_alloc((len+1)*sizeof(char)); |
| 2600 | |
| 2601 | strcpy(file, (char*)pfdin->pv); |
| 2602 | strcat(file, pfdin->psz1); |
| 2603 | |
| 2604 | TRACE("file: %s\n", debugstr_a(file)); |
| 2605 | |
| 2606 | return cabinet_open(file, _O_WRONLY | _O_CREAT, 0); |
| 2607 | } |
| 2608 | case fdintCLOSE_FILE_INFO: |
| 2609 | { |
| 2610 | FILETIME ft; |
| 2611 | FILETIME ftLocal; |
| 2612 | if (!DosDateTimeToFileTime(pfdin->date, pfdin->time, &ft)) |
| 2613 | return -1; |
| 2614 | if (!LocalFileTimeToFileTime(&ft, &ftLocal)) |
| 2615 | return -1; |
| 2616 | if (!SetFileTime((HANDLE)pfdin->hf, &ftLocal, 0, &ftLocal)) |
| 2617 | return -1; |
| 2618 | |
| 2619 | cabinet_close(pfdin->hf); |
| 2620 | return 1; |
| 2621 | } |
| 2622 | default: |
| 2623 | return 0; |
| 2624 | } |
| 2625 | } |
| 2626 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2627 | /*********************************************************************** |
| 2628 | * extract_cabinet_file |
| 2629 | * |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2630 | * Extract files from a cab file. |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2631 | */ |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2632 | static BOOL extract_cabinet_file(const WCHAR* source, const WCHAR* path) |
| 2633 | { |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2634 | HFDI hfdi; |
| 2635 | ERF erf; |
| 2636 | BOOL ret; |
| 2637 | char *cabinet; |
| 2638 | char *cab_path; |
| 2639 | |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2640 | TRACE("Extracting %s to %s\n",debugstr_w(source), debugstr_w(path)); |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2641 | |
| 2642 | hfdi = FDICreate(cabinet_alloc, |
| 2643 | cabinet_free, |
| 2644 | cabinet_open, |
| 2645 | cabinet_read, |
| 2646 | cabinet_write, |
| 2647 | cabinet_close, |
| 2648 | cabinet_seek, |
| 2649 | 0, |
| 2650 | &erf); |
| 2651 | if (!hfdi) |
| 2652 | { |
| 2653 | ERR("FDICreate failed\n"); |
| 2654 | return FALSE; |
| 2655 | } |
| 2656 | |
| 2657 | if (!(cabinet = strdupWtoA( source ))) |
| 2658 | { |
| 2659 | FDIDestroy(hfdi); |
| 2660 | return FALSE; |
| 2661 | } |
| 2662 | if (!(cab_path = strdupWtoA( path ))) |
| 2663 | { |
| 2664 | FDIDestroy(hfdi); |
| 2665 | HeapFree(GetProcessHeap(), 0, cabinet); |
| 2666 | return FALSE; |
| 2667 | } |
| 2668 | |
| 2669 | ret = FDICopy(hfdi, cabinet, "", 0, cabinet_notify, NULL, cab_path); |
| 2670 | |
| 2671 | if (!ret) |
| 2672 | ERR("FDICopy failed\n"); |
| 2673 | |
| 2674 | FDIDestroy(hfdi); |
| 2675 | |
| 2676 | HeapFree(GetProcessHeap(), 0, cabinet); |
| 2677 | HeapFree(GetProcessHeap(), 0, cab_path); |
| 2678 | |
| 2679 | return ret; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2680 | } |
| 2681 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2682 | static UINT ready_media_for_file(MSIPACKAGE *package, UINT sequence, |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2683 | WCHAR* path) |
| 2684 | { |
| 2685 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2686 | MSIQUERY * view; |
| 2687 | MSIRECORD * row = 0; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2688 | WCHAR source[MAX_PATH]; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2689 | static const WCHAR ExecSeqQuery[] = { |
| 2690 | 's','e','l','e','c','t',' ','*',' ', |
| 2691 | 'f','r','o','m',' ','M','e','d','i','a',' ', |
| 2692 | 'w','h','e','r','e',' ','L','a','s','t','S','e','q','u','e','n','c','e',' ','>','=',' ','%','i',' ', |
| 2693 | 'o','r','d','e','r',' ','b','y',' ','L','a','s','t','S','e','q','u','e','n','c','e',0}; |
| 2694 | WCHAR Query[1024]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2695 | WCHAR cab[0x100]; |
| 2696 | DWORD sz=0x100; |
| 2697 | INT seq; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2698 | static UINT last_sequence = 0; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2699 | |
| 2700 | if (sequence <= last_sequence) |
| 2701 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2702 | TRACE("Media already ready (%u, %u)\n",sequence,last_sequence); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2703 | return ERROR_SUCCESS; |
| 2704 | } |
| 2705 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2706 | sprintfW(Query,ExecSeqQuery,sequence); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2707 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2708 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2709 | if (rc != ERROR_SUCCESS) |
| 2710 | return rc; |
| 2711 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2712 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2713 | if (rc != ERROR_SUCCESS) |
| 2714 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2715 | MSI_ViewClose(view); |
| 2716 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2717 | return rc; |
| 2718 | } |
| 2719 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2720 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2721 | if (rc != ERROR_SUCCESS) |
| 2722 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2723 | MSI_ViewClose(view); |
| 2724 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2725 | return rc; |
| 2726 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2727 | seq = MSI_RecordGetInteger(row,2); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2728 | last_sequence = seq; |
| 2729 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2730 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2731 | { |
| 2732 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2733 | MSI_RecordGetStringW(row,4,cab,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2734 | TRACE("Source is CAB %s\n",debugstr_w(cab)); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2735 | /* the stream does not contain the # character */ |
| 2736 | if (cab[0]=='#') |
| 2737 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2738 | writeout_cabinet_stream(package,&cab[1],source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2739 | strcpyW(path,source); |
| 2740 | *(strrchrW(path,'\\')+1)=0; |
| 2741 | } |
| 2742 | else |
| 2743 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 2744 | sz = MAX_PATH; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2745 | if (MSI_GetPropertyW(package, cszSourceDir, source, &sz)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2746 | { |
| 2747 | ERR("No Source dir defined \n"); |
| 2748 | rc = ERROR_FUNCTION_FAILED; |
| 2749 | } |
| 2750 | else |
| 2751 | { |
| 2752 | strcpyW(path,source); |
| 2753 | strcatW(source,cab); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2754 | /* extract the cab file into a folder in the temp folder */ |
| 2755 | sz = MAX_PATH; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2756 | if (MSI_GetPropertyW(package, cszTempFolder,path, &sz) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2757 | != ERROR_SUCCESS) |
| 2758 | GetTempPathW(MAX_PATH,path); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2759 | } |
| 2760 | } |
| 2761 | rc = !extract_cabinet_file(source,path); |
| 2762 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2763 | msiobj_release(&row->hdr); |
| 2764 | MSI_ViewClose(view); |
| 2765 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2766 | return rc; |
| 2767 | } |
| 2768 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2769 | inline static UINT create_component_directory ( MSIPACKAGE* package, INT component) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2770 | { |
| 2771 | UINT rc; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2772 | MSIFOLDER *folder; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2773 | LPWSTR install_path; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2774 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2775 | install_path = resolve_folder(package, package->components[component].Directory, |
| 2776 | FALSE, FALSE, &folder); |
| 2777 | if (!install_path) |
| 2778 | return ERROR_FUNCTION_FAILED; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2779 | |
| 2780 | /* create the path */ |
| 2781 | if (folder->State == 0) |
| 2782 | { |
| 2783 | create_full_pathW(install_path); |
| 2784 | folder->State = 2; |
| 2785 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2786 | HeapFree(GetProcessHeap(), 0, install_path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2787 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2788 | return rc; |
| 2789 | } |
| 2790 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2791 | static UINT ACTION_InstallFiles(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2792 | { |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2793 | UINT rc = ERROR_SUCCESS; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2794 | DWORD index; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2795 | MSIRECORD * uirow; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2796 | WCHAR uipath[MAX_PATH]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2797 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2798 | if (!package) |
| 2799 | return ERROR_INVALID_HANDLE; |
| 2800 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2801 | /* increment progress bar each time action data is sent */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2802 | ui_progress(package,1,1,1,0); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2803 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2804 | for (index = 0; index < package->loaded_files; index++) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2805 | { |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2806 | WCHAR path_to_source[MAX_PATH]; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2807 | MSIFILE *file; |
| 2808 | |
| 2809 | file = &package->files[index]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2810 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2811 | if (file->Temporary) |
| 2812 | continue; |
| 2813 | |
| 2814 | if (!package->components[file->ComponentIndex].Enabled || |
| 2815 | !package->components[file->ComponentIndex].FeatureState) |
| 2816 | { |
| 2817 | TRACE("File %s is not scheduled for install\n", |
| 2818 | debugstr_w(file->File)); |
| 2819 | continue; |
| 2820 | } |
| 2821 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2822 | if ((file->State == 1) || (file->State == 2)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2823 | { |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2824 | TRACE("Installing %s\n",debugstr_w(file->File)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2825 | rc = ready_media_for_file(package,file->Sequence,path_to_source); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2826 | /* |
| 2827 | * WARNING! |
| 2828 | * our file table could change here because a new temp file |
| 2829 | * may have been created |
| 2830 | */ |
| 2831 | file = &package->files[index]; |
| 2832 | if (rc != ERROR_SUCCESS) |
| 2833 | { |
| 2834 | ERR("Unable to ready media\n"); |
| 2835 | rc = ERROR_FUNCTION_FAILED; |
| 2836 | break; |
| 2837 | } |
| 2838 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2839 | create_component_directory( package, file->ComponentIndex); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2840 | |
| 2841 | strcpyW(file->SourcePath, path_to_source); |
| 2842 | strcatW(file->SourcePath, file->File); |
| 2843 | |
| 2844 | TRACE("file paths %s to %s\n",debugstr_w(file->SourcePath), |
| 2845 | debugstr_w(file->TargetPath)); |
| 2846 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2847 | /* the UI chunk */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2848 | uirow=MSI_CreateRecord(9); |
| 2849 | MSI_RecordSetStringW(uirow,1,file->File); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2850 | strcpyW(uipath,file->TargetPath); |
| 2851 | *(strrchrW(uipath,'\\')+1)=0; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2852 | MSI_RecordSetStringW(uirow,9,uipath); |
| 2853 | MSI_RecordSetInteger(uirow,6,file->FileSize); |
| 2854 | ui_actiondata(package,szInstallFiles,uirow); |
| 2855 | msiobj_release( &uirow->hdr ); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2856 | |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2857 | if (!MoveFileW(file->SourcePath,file->TargetPath)) |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 2858 | { |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2859 | rc = GetLastError(); |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2860 | ERR("Unable to move file (%s -> %s) (error %d)\n", |
| 2861 | debugstr_w(file->SourcePath), debugstr_w(file->TargetPath), |
| 2862 | rc); |
| 2863 | if (rc == ERROR_ALREADY_EXISTS && file->State == 2) |
| 2864 | { |
| 2865 | CopyFileW(file->SourcePath,file->TargetPath,FALSE); |
| 2866 | DeleteFileW(file->SourcePath); |
| 2867 | rc = 0; |
| 2868 | } |
| 2869 | else |
| 2870 | break; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 2871 | } |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2872 | else |
| 2873 | file->State = 4; |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2874 | |
| 2875 | ui_progress(package,2,0,0,0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2876 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2877 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2878 | |
| 2879 | return rc; |
| 2880 | } |
| 2881 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2882 | inline static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key, |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2883 | LPWSTR* file_source) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2884 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2885 | DWORD index; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2886 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2887 | if (!package) |
| 2888 | return ERROR_INVALID_HANDLE; |
| 2889 | |
| 2890 | for (index = 0; index < package->loaded_files; index ++) |
| 2891 | { |
| 2892 | if (strcmpW(file_key,package->files[index].File)==0) |
| 2893 | { |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2894 | if (package->files[index].State >= 3) |
| 2895 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2896 | *file_source = dupstrW(package->files[index].TargetPath); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2897 | return ERROR_SUCCESS; |
| 2898 | } |
| 2899 | else |
| 2900 | return ERROR_FILE_NOT_FOUND; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2901 | } |
| 2902 | } |
| 2903 | |
| 2904 | return ERROR_FUNCTION_FAILED; |
| 2905 | } |
| 2906 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2907 | static UINT ACTION_DuplicateFiles(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2908 | { |
| 2909 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2910 | MSIQUERY * view; |
| 2911 | MSIRECORD * row = 0; |
| 2912 | static const WCHAR ExecSeqQuery[] = { |
| 2913 | 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ', |
| 2914 | 'D','u','p','l','i','c','a','t','e','F','i','l','e',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2915 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2916 | if (!package) |
| 2917 | return ERROR_INVALID_HANDLE; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2918 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2919 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2920 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2921 | return ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2922 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2923 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2924 | if (rc != ERROR_SUCCESS) |
| 2925 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2926 | MSI_ViewClose(view); |
| 2927 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2928 | return rc; |
| 2929 | } |
| 2930 | |
| 2931 | while (1) |
| 2932 | { |
| 2933 | WCHAR file_key[0x100]; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2934 | WCHAR *file_source = NULL; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2935 | WCHAR dest_name[0x100]; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2936 | LPWSTR dest_path, dest; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2937 | WCHAR component[0x100]; |
| 2938 | INT component_index; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2939 | |
| 2940 | DWORD sz=0x100; |
| 2941 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2942 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2943 | if (rc != ERROR_SUCCESS) |
| 2944 | { |
| 2945 | rc = ERROR_SUCCESS; |
| 2946 | break; |
| 2947 | } |
| 2948 | |
| 2949 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2950 | rc = MSI_RecordGetStringW(row,2,component,&sz); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2951 | if (rc != ERROR_SUCCESS) |
| 2952 | { |
| 2953 | ERR("Unable to get component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2954 | msiobj_release(&row->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2955 | break; |
| 2956 | } |
| 2957 | |
| 2958 | component_index = get_loaded_component(package,component); |
| 2959 | if (!package->components[component_index].Enabled || |
| 2960 | !package->components[component_index].FeatureState) |
| 2961 | { |
| 2962 | TRACE("Skipping copy due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2963 | msiobj_release(&row->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2964 | continue; |
| 2965 | } |
| 2966 | |
| 2967 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2968 | rc = MSI_RecordGetStringW(row,3,file_key,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2969 | if (rc != ERROR_SUCCESS) |
| 2970 | { |
| 2971 | ERR("Unable to get file key\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2972 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2973 | break; |
| 2974 | } |
| 2975 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2976 | rc = get_file_target(package,file_key,&file_source); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2977 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2978 | if (rc != ERROR_SUCCESS) |
| 2979 | { |
| 2980 | ERR("Original file unknown %s\n",debugstr_w(file_key)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2981 | msiobj_release(&row->hdr); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 2982 | if (file_source) |
| 2983 | HeapFree(GetProcessHeap(),0,file_source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2984 | break; |
| 2985 | } |
| 2986 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2987 | if (MSI_RecordIsNull(row,4)) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2988 | { |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2989 | strcpyW(dest_name,strrchrW(file_source,'\\')+1); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2990 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2991 | else |
| 2992 | { |
| 2993 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2994 | MSI_RecordGetStringW(row,4,dest_name,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2995 | reduce_to_longfilename(dest_name); |
| 2996 | } |
| 2997 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2998 | if (MSI_RecordIsNull(row,5)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2999 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3000 | LPWSTR p; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3001 | dest_path = dupstrW(file_source); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3002 | p = strrchrW(dest_path,'\\'); |
| 3003 | if (p) |
| 3004 | *p=0; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3005 | } |
| 3006 | else |
| 3007 | { |
| 3008 | WCHAR destkey[0x100]; |
| 3009 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3010 | MSI_RecordGetStringW(row,5,destkey,&sz); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 3011 | sz = 0x100; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3012 | dest_path = resolve_folder(package, destkey, FALSE,FALSE,NULL); |
| 3013 | if (!dest_path) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3014 | { |
| 3015 | ERR("Unable to get destination folder\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3016 | msiobj_release(&row->hdr); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3017 | if (file_source) |
| 3018 | HeapFree(GetProcessHeap(),0,file_source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3019 | break; |
| 3020 | } |
| 3021 | } |
| 3022 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3023 | dest = build_directory_name(2, dest_path, dest_name); |
| 3024 | HeapFree(GetProcessHeap(), 0, dest_path); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3025 | |
| 3026 | TRACE("Duplicating file %s to %s\n",debugstr_w(file_source), |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3027 | debugstr_w(dest)); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3028 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3029 | if (strcmpW(file_source,dest)) |
| 3030 | rc = !CopyFileW(file_source,dest,TRUE); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3031 | else |
| 3032 | rc = ERROR_SUCCESS; |
| 3033 | |
| 3034 | if (rc != ERROR_SUCCESS) |
| 3035 | ERR("Failed to copy file\n"); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 3036 | |
| 3037 | FIXME("We should track these duplicate files as well\n"); |
| 3038 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3039 | msiobj_release(&row->hdr); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3040 | HeapFree(GetProcessHeap(),0,dest); |
| 3041 | HeapFree(GetProcessHeap(),0,file_source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3042 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3043 | MSI_ViewClose(view); |
| 3044 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3045 | return rc; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3046 | } |
| 3047 | |
| 3048 | |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 3049 | /* OK this value is "interpretted" and then formatted based on the |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3050 | first few characters */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3051 | static LPSTR parse_value(MSIPACKAGE *package, WCHAR *value, DWORD *type, |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3052 | DWORD *size) |
| 3053 | { |
| 3054 | LPSTR data = NULL; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3055 | if (value[0]=='#' && value[1]!='#' && value[1]!='%') |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3056 | { |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3057 | if (value[1]=='x') |
| 3058 | { |
| 3059 | LPWSTR ptr; |
| 3060 | CHAR byte[5]; |
| 3061 | LPWSTR deformated; |
| 3062 | int count; |
| 3063 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3064 | deformat_string(package, &value[2], &deformated); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3065 | |
| 3066 | /* binary value type */ |
| 3067 | ptr = deformated; |
| 3068 | *type=REG_BINARY; |
| 3069 | *size = strlenW(ptr)/2; |
| 3070 | data = HeapAlloc(GetProcessHeap(),0,*size); |
| 3071 | |
| 3072 | byte[0] = '0'; |
| 3073 | byte[1] = 'x'; |
| 3074 | byte[4] = 0; |
| 3075 | count = 0; |
| 3076 | while (*ptr) |
| 3077 | { |
| 3078 | byte[2]= *ptr; |
| 3079 | ptr++; |
| 3080 | byte[3]= *ptr; |
| 3081 | ptr++; |
| 3082 | data[count] = (BYTE)strtol(byte,NULL,0); |
| 3083 | count ++; |
| 3084 | } |
| 3085 | HeapFree(GetProcessHeap(),0,deformated); |
| 3086 | |
| 3087 | TRACE("Data %li bytes(%i)\n",*size,count); |
| 3088 | } |
| 3089 | else |
| 3090 | { |
| 3091 | LPWSTR deformated; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3092 | deformat_string(package, &value[1], &deformated); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3093 | |
| 3094 | *type=REG_DWORD; |
| 3095 | *size = sizeof(DWORD); |
| 3096 | data = HeapAlloc(GetProcessHeap(),0,*size); |
| 3097 | *(LPDWORD)data = atoiW(deformated); |
| 3098 | TRACE("DWORD %i\n",*data); |
| 3099 | |
| 3100 | HeapFree(GetProcessHeap(),0,deformated); |
| 3101 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3102 | } |
| 3103 | else |
| 3104 | { |
| 3105 | WCHAR *ptr; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3106 | *type=REG_SZ; |
| 3107 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3108 | if (value[0]=='#') |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3109 | { |
| 3110 | if (value[1]=='%') |
| 3111 | { |
| 3112 | ptr = &value[2]; |
| 3113 | *type=REG_EXPAND_SZ; |
| 3114 | } |
| 3115 | else |
| 3116 | ptr = &value[1]; |
| 3117 | } |
| 3118 | else |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3119 | ptr=value; |
| 3120 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3121 | *size = deformat_string(package, ptr,(LPWSTR*)&data); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3122 | } |
| 3123 | return data; |
| 3124 | } |
| 3125 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3126 | static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3127 | { |
| 3128 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3129 | MSIQUERY * view; |
| 3130 | MSIRECORD * row = 0; |
| 3131 | static const WCHAR ExecSeqQuery[] = { |
| 3132 | 's','e','l','e','c','t',' ','*',' ', |
| 3133 | 'f','r','o','m',' ','R','e','g','i','s','t','r','y',0 }; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3134 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3135 | if (!package) |
| 3136 | return ERROR_INVALID_HANDLE; |
| 3137 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3138 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3139 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3140 | return ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3141 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3142 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3143 | if (rc != ERROR_SUCCESS) |
| 3144 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3145 | MSI_ViewClose(view); |
| 3146 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3147 | return rc; |
| 3148 | } |
| 3149 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3150 | /* increment progress bar each time action data is sent */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3151 | ui_progress(package,1,1,1,0); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3152 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3153 | while (1) |
| 3154 | { |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3155 | static const WCHAR szHCR[] = |
| 3156 | {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T','\\',0}; |
| 3157 | static const WCHAR szHCU[] = |
| 3158 | {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\',0}; |
| 3159 | static const WCHAR szHLM[] = |
| 3160 | {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E', |
| 3161 | '\\',0}; |
| 3162 | static const WCHAR szHU[] = |
| 3163 | {'H','K','E','Y','_','U','S','E','R','S','\\',0}; |
| 3164 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3165 | LPSTR value_data = NULL; |
| 3166 | HKEY root_key, hkey; |
| 3167 | DWORD type,size; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3168 | LPWSTR value, key, name, component; |
| 3169 | LPCWSTR szRoot; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3170 | INT component_index; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3171 | MSIRECORD * uirow; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3172 | LPWSTR uikey; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3173 | INT root; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3174 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3175 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3176 | if (rc != ERROR_SUCCESS) |
| 3177 | { |
| 3178 | rc = ERROR_SUCCESS; |
| 3179 | break; |
| 3180 | } |
| 3181 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3182 | value = NULL; |
| 3183 | key = NULL; |
| 3184 | uikey = NULL; |
| 3185 | name = NULL; |
| 3186 | |
| 3187 | component = load_dynamic_stringW(row, 6); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3188 | component_index = get_loaded_component(package,component); |
| 3189 | |
| 3190 | if (!package->components[component_index].Enabled || |
| 3191 | !package->components[component_index].FeatureState) |
| 3192 | { |
| 3193 | TRACE("Skipping write due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3194 | msiobj_release(&row->hdr); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3195 | goto next; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3196 | } |
| 3197 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3198 | /* null values have special meanings during uninstalls and such */ |
| 3199 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3200 | if(MSI_RecordIsNull(row,5)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3201 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3202 | msiobj_release(&row->hdr); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3203 | goto next; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3204 | } |
| 3205 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3206 | root = MSI_RecordGetInteger(row,2); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3207 | key = load_dynamic_stringW(row, 3); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3208 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3209 | name = load_dynamic_stringW(row, 4); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3210 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3211 | /* get the root key */ |
| 3212 | switch (root) |
| 3213 | { |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3214 | case 0: root_key = HKEY_CLASSES_ROOT; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3215 | szRoot = szHCR; |
| 3216 | break; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3217 | case 1: root_key = HKEY_CURRENT_USER; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3218 | szRoot = szHCU; |
| 3219 | break; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3220 | case 2: root_key = HKEY_LOCAL_MACHINE; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3221 | szRoot = szHLM; |
| 3222 | break; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3223 | case 3: root_key = HKEY_USERS; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3224 | szRoot = szHU; |
| 3225 | break; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3226 | default: |
| 3227 | ERR("Unknown root %i\n",root); |
| 3228 | root_key=NULL; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3229 | szRoot = NULL; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3230 | break; |
| 3231 | } |
| 3232 | if (!root_key) |
| 3233 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3234 | msiobj_release(&row->hdr); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3235 | goto next; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3236 | } |
| 3237 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3238 | size = strlenW(key) + strlenW(szRoot) + 1; |
| 3239 | uikey = HeapAlloc(GetProcessHeap(), 0, size*sizeof(WCHAR)); |
| 3240 | strcpyW(uikey,szRoot); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3241 | strcatW(uikey,key); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3242 | if (RegCreateKeyW( root_key, key, &hkey)) |
| 3243 | { |
| 3244 | ERR("Could not create key %s\n",debugstr_w(key)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3245 | msiobj_release(&row->hdr); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3246 | goto next; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3247 | } |
| 3248 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3249 | value = load_dynamic_stringW(row,5); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3250 | value_data = parse_value(package, value, &type, &size); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3251 | |
| 3252 | if (value_data) |
| 3253 | { |
| 3254 | TRACE("Setting value %s\n",debugstr_w(name)); |
| 3255 | RegSetValueExW(hkey, name, 0, type, value_data, size); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3256 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3257 | uirow = MSI_CreateRecord(3); |
| 3258 | MSI_RecordSetStringW(uirow,2,name); |
| 3259 | MSI_RecordSetStringW(uirow,1,uikey); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3260 | |
| 3261 | if (type == REG_SZ) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3262 | MSI_RecordSetStringW(uirow,3,(LPWSTR)value_data); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3263 | else |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3264 | MSI_RecordSetStringW(uirow,3,value); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3265 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3266 | ui_actiondata(package,szWriteRegistryValues,uirow); |
| 3267 | ui_progress(package,2,0,0,0); |
| 3268 | msiobj_release( &uirow->hdr ); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3269 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3270 | HeapFree(GetProcessHeap(),0,value_data); |
| 3271 | } |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3272 | HeapFree(GetProcessHeap(),0,value); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3273 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3274 | msiobj_release(&row->hdr); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3275 | RegCloseKey(hkey); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3276 | next: |
| 3277 | if (uikey) |
| 3278 | HeapFree(GetProcessHeap(),0,uikey); |
| 3279 | if (key) |
| 3280 | HeapFree(GetProcessHeap(),0,key); |
| 3281 | if (name) |
| 3282 | HeapFree(GetProcessHeap(),0,name); |
| 3283 | if (component) |
| 3284 | HeapFree(GetProcessHeap(),0,component); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3285 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3286 | MSI_ViewClose(view); |
| 3287 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3288 | return rc; |
| 3289 | } |
| 3290 | |
| 3291 | /* |
| 3292 | * This helper function should probably go alot of places |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3293 | * |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 3294 | * Thinking about this, maybe this should become yet another Bison file |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3295 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3296 | static DWORD deformat_string(MSIPACKAGE *package, WCHAR* ptr,WCHAR** data) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3297 | { |
| 3298 | WCHAR* mark=NULL; |
| 3299 | DWORD size=0; |
| 3300 | DWORD chunk=0; |
| 3301 | WCHAR key[0x100]; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3302 | LPWSTR value; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 3303 | DWORD sz; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3304 | UINT rc; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3305 | |
| 3306 | /* scan for special characters */ |
| 3307 | if (!strchrW(ptr,'[') || (strchrW(ptr,'[') && !strchrW(ptr,']'))) |
| 3308 | { |
| 3309 | /* not formatted */ |
| 3310 | size = (strlenW(ptr)+1) * sizeof(WCHAR); |
| 3311 | *data = HeapAlloc(GetProcessHeap(),0,size); |
| 3312 | strcpyW(*data,ptr); |
| 3313 | return size; |
| 3314 | } |
| 3315 | |
| 3316 | /* formatted string located */ |
| 3317 | mark = strchrW(ptr,'['); |
| 3318 | if (mark != ptr) |
| 3319 | { |
| 3320 | INT cnt = (mark - ptr); |
| 3321 | TRACE("%i (%i) characters before marker\n",cnt,(mark-ptr)); |
| 3322 | size = cnt * sizeof(WCHAR); |
| 3323 | size += sizeof(WCHAR); |
| 3324 | *data = HeapAlloc(GetProcessHeap(),0,size); |
| 3325 | strncpyW(*data,ptr,cnt); |
| 3326 | (*data)[cnt]=0; |
| 3327 | } |
| 3328 | else |
| 3329 | { |
| 3330 | size = sizeof(WCHAR); |
| 3331 | *data = HeapAlloc(GetProcessHeap(),0,size); |
| 3332 | (*data)[0]=0; |
| 3333 | } |
| 3334 | mark++; |
| 3335 | strcpyW(key,mark); |
| 3336 | *strchrW(key,']')=0; |
| 3337 | mark = strchrW(mark,']'); |
| 3338 | mark++; |
| 3339 | TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark)); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3340 | sz = 0; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3341 | rc = MSI_GetPropertyW(package, key, NULL, &sz); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3342 | if ((rc == ERROR_SUCCESS) || (rc == ERROR_MORE_DATA)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3343 | { |
| 3344 | LPWSTR newdata; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3345 | |
| 3346 | sz++; |
| 3347 | value = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3348 | MSI_GetPropertyW(package, key, value, &sz); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3349 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3350 | chunk = (strlenW(value)+1) * sizeof(WCHAR); |
| 3351 | size+=chunk; |
| 3352 | newdata = HeapReAlloc(GetProcessHeap(),0,*data,size); |
| 3353 | *data = newdata; |
| 3354 | strcatW(*data,value); |
| 3355 | } |
| 3356 | TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark)); |
| 3357 | if (*mark!=0) |
| 3358 | { |
| 3359 | LPWSTR newdata; |
| 3360 | chunk = (strlenW(mark)+1) * sizeof(WCHAR); |
| 3361 | size+=chunk; |
| 3362 | newdata = HeapReAlloc(GetProcessHeap(),0,*data,size); |
| 3363 | *data = newdata; |
| 3364 | strcatW(*data,mark); |
| 3365 | } |
| 3366 | (*data)[strlenW(*data)]=0; |
| 3367 | TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark)); |
| 3368 | |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 3369 | /* recursively do this to clean up */ |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3370 | mark = HeapAlloc(GetProcessHeap(),0,size); |
| 3371 | strcpyW(mark,*data); |
| 3372 | TRACE("String at this point %s\n",debugstr_w(mark)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3373 | size = deformat_string(package,mark,data); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3374 | HeapFree(GetProcessHeap(),0,mark); |
| 3375 | return size; |
| 3376 | } |
| 3377 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3378 | static UINT ACTION_InstallInitialize(MSIPACKAGE *package) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3379 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3380 | LPWSTR level; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3381 | INT install_level; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 3382 | DWORD i; |
| 3383 | INT j; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3384 | LPWSTR override = NULL; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3385 | static const WCHAR all[]={'A','L','L',0}; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3386 | static const WCHAR szlevel[] = { |
| 3387 | 'I','N','S','T','A','L','L','L','E','V','E','L',0}; |
| 3388 | static const WCHAR szAddLocal[] = { |
| 3389 | 'A','D','D','L','O','C','A','L',0}; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3390 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3391 | /* I do not know if this is where it should happen.. but */ |
| 3392 | |
| 3393 | TRACE("Checking Install Level\n"); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3394 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3395 | level = load_dynamic_property(package,szlevel,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3396 | if (level) |
| 3397 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3398 | install_level = atoiW(level); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3399 | HeapFree(GetProcessHeap(), 0, level); |
| 3400 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3401 | else |
| 3402 | install_level = 1; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3403 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3404 | override = load_dynamic_property(package,szAddLocal,NULL); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3405 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3406 | /* |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3407 | * Components FeatureState defaults to FALSE. The idea is we want to |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3408 | * enable the component is ANY feature that uses it is enabled to install |
| 3409 | */ |
| 3410 | for(i = 0; i < package->loaded_features; i++) |
| 3411 | { |
| 3412 | BOOL feature_state= ((package->features[i].Level > 0) && |
| 3413 | (package->features[i].Level <= install_level)); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3414 | |
| 3415 | if (override && (strcmpiW(override,all)==0 || |
| 3416 | strstrW(override,package->features[i].Feature))) |
| 3417 | { |
| 3418 | TRACE("Override of install level found\n"); |
| 3419 | feature_state = TRUE; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 3420 | package->features[i].Enabled = feature_state; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3421 | } |
| 3422 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3423 | TRACE("Feature %s has a state of %i\n", |
| 3424 | debugstr_w(package->features[i].Feature), feature_state); |
| 3425 | for( j = 0; j < package->features[i].ComponentCount; j++) |
| 3426 | { |
| 3427 | package->components[package->features[i].Components[j]].FeatureState |
| 3428 | |= feature_state; |
| 3429 | } |
| 3430 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3431 | if (override) |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3432 | HeapFree(GetProcessHeap(),0,override); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3433 | /* |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3434 | * So basically we ONLY want to install a component if its Enabled AND |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3435 | * FeatureState are both TRUE |
| 3436 | */ |
| 3437 | return ERROR_SUCCESS; |
| 3438 | } |
| 3439 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3440 | static UINT ACTION_InstallValidate(MSIPACKAGE *package) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3441 | { |
| 3442 | DWORD progress = 0; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3443 | static const WCHAR q1[]={ |
| 3444 | 'S','E','L','E','C','T',' ','*',' ', |
| 3445 | 'F','R','O','M',' ','R','e','g','i','s','t','r','y',0}; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3446 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3447 | MSIQUERY * view; |
| 3448 | MSIRECORD * row = 0; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3449 | |
| 3450 | TRACE(" InstallValidate \n"); |
| 3451 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3452 | rc = MSI_DatabaseOpenViewW(package->db, q1, &view); |
| 3453 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3454 | return ERROR_SUCCESS; |
| 3455 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3456 | rc = MSI_ViewExecute(view, 0); |
| 3457 | if (rc != ERROR_SUCCESS) |
| 3458 | { |
| 3459 | MSI_ViewClose(view); |
| 3460 | msiobj_release(&view->hdr); |
| 3461 | return rc; |
| 3462 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3463 | while (1) |
| 3464 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3465 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3466 | if (rc != ERROR_SUCCESS) |
| 3467 | { |
| 3468 | rc = ERROR_SUCCESS; |
| 3469 | break; |
| 3470 | } |
| 3471 | progress +=1; |
| 3472 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3473 | msiobj_release(&row->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3474 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3475 | MSI_ViewClose(view); |
| 3476 | msiobj_release(&view->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3477 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3478 | ui_progress(package,0,progress+package->loaded_files,0,0); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3479 | |
| 3480 | return ERROR_SUCCESS; |
| 3481 | } |
| 3482 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3483 | static UINT ACTION_LaunchConditions(MSIPACKAGE *package) |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3484 | { |
| 3485 | UINT rc; |
Mike McCormack | f3c8b83 | 2004-07-19 19:35:05 +0000 | [diff] [blame] | 3486 | MSIQUERY * view = NULL; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3487 | MSIRECORD * row = 0; |
| 3488 | static const WCHAR ExecSeqQuery[] = { |
| 3489 | 'S','E','L','E','C','T',' ','*',' ', |
| 3490 | 'f','r','o','m',' ','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n',0}; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3491 | static const WCHAR title[]= |
| 3492 | {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0}; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3493 | |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3494 | TRACE("Checking launch conditions\n"); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3495 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3496 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3497 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3498 | return ERROR_SUCCESS; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3499 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3500 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3501 | if (rc != ERROR_SUCCESS) |
| 3502 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3503 | MSI_ViewClose(view); |
| 3504 | msiobj_release(&view->hdr); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3505 | return rc; |
| 3506 | } |
| 3507 | |
| 3508 | rc = ERROR_SUCCESS; |
| 3509 | while (rc == ERROR_SUCCESS) |
| 3510 | { |
| 3511 | LPWSTR cond = NULL; |
| 3512 | LPWSTR message = NULL; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3513 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3514 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3515 | if (rc != ERROR_SUCCESS) |
| 3516 | { |
| 3517 | rc = ERROR_SUCCESS; |
| 3518 | break; |
| 3519 | } |
| 3520 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3521 | cond = load_dynamic_stringW(row,1); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3522 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3523 | if (MSI_EvaluateConditionW(package,cond) != MSICONDITION_TRUE) |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3524 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3525 | message = load_dynamic_stringW(row,2); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3526 | MessageBoxW(NULL,message,title,MB_OK); |
| 3527 | HeapFree(GetProcessHeap(),0,message); |
| 3528 | rc = ERROR_FUNCTION_FAILED; |
| 3529 | } |
| 3530 | HeapFree(GetProcessHeap(),0,cond); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3531 | msiobj_release(&row->hdr); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3532 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3533 | MSI_ViewClose(view); |
| 3534 | msiobj_release(&view->hdr); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3535 | return rc; |
| 3536 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3537 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3538 | static LPWSTR resolve_keypath( MSIPACKAGE* package, INT |
| 3539 | component_index) |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3540 | { |
| 3541 | MSICOMPONENT* cmp = &package->components[component_index]; |
| 3542 | |
| 3543 | if (cmp->KeyPath[0]==0) |
| 3544 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3545 | LPWSTR p = resolve_folder(package,cmp->Directory,FALSE,FALSE,NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3546 | return p; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3547 | } |
| 3548 | if ((cmp->Attributes & 0x4) || (cmp->Attributes & 0x20)) |
| 3549 | { |
| 3550 | FIXME("UNIMPLEMENTED keypath as Registry or ODBC Source\n"); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3551 | return NULL; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3552 | } |
| 3553 | else |
| 3554 | { |
| 3555 | int j; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3556 | j = get_loaded_file(package,cmp->KeyPath); |
| 3557 | |
| 3558 | if (j>=0) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3559 | { |
| 3560 | LPWSTR p = dupstrW(package->files[j].TargetPath); |
| 3561 | return p; |
| 3562 | } |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3563 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3564 | return NULL; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3565 | } |
| 3566 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3567 | /* |
| 3568 | * Ok further analysis makes me think that this work is |
| 3569 | * actually done in the PublishComponents and PublishFeatures |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 3570 | * step, and not here. It appears like the keypath and all that is |
| 3571 | * resolved in this step, however actually written in the Publish steps. |
Alexandre Julliard | 77b1276 | 2004-07-09 19:43:29 +0000 | [diff] [blame] | 3572 | * But we will leave it here for now because it is unclear |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3573 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3574 | static UINT ACTION_ProcessComponents(MSIPACKAGE *package) |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3575 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3576 | LPWSTR productcode; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3577 | WCHAR squished_pc[0x100]; |
| 3578 | WCHAR squished_cc[0x100]; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3579 | UINT rc; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 3580 | DWORD i; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3581 | HKEY hkey=0,hkey2=0,hkey3=0; |
| 3582 | static const WCHAR szProductCode[]= |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3583 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3584 | static const WCHAR szInstaller[] = { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3585 | 'S','o','f','t','w','a','r','e','\\', |
| 3586 | 'M','i','c','r','o','s','o','f','t','\\', |
| 3587 | 'W','i','n','d','o','w','s','\\', |
| 3588 | 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', |
| 3589 | 'I','n','s','t','a','l','l','e','r',0 }; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3590 | static const WCHAR szFeatures[] = { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3591 | 'F','e','a','t','u','r','e','s',0 }; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3592 | static const WCHAR szComponents[] = { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3593 | 'C','o','m','p','o','n','e','n','t','s',0 }; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3594 | |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3595 | if (!package) |
| 3596 | return ERROR_INVALID_HANDLE; |
| 3597 | |
| 3598 | /* writes the Component and Features values to the registry */ |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3599 | productcode = load_dynamic_property(package,szProductCode,&rc); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3600 | if (!productcode) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3601 | return rc; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3602 | |
| 3603 | squash_guid(productcode,squished_pc); |
| 3604 | rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,szInstaller,&hkey); |
| 3605 | if (rc != ERROR_SUCCESS) |
| 3606 | goto end; |
| 3607 | |
| 3608 | rc = RegCreateKeyW(hkey,szFeatures,&hkey2); |
| 3609 | if (rc != ERROR_SUCCESS) |
| 3610 | goto end; |
| 3611 | |
| 3612 | rc = RegCreateKeyW(hkey2,squished_pc,&hkey3); |
| 3613 | if (rc != ERROR_SUCCESS) |
| 3614 | goto end; |
| 3615 | |
Alexandre Julliard | 77b1276 | 2004-07-09 19:43:29 +0000 | [diff] [blame] | 3616 | /* here the guids are base 85 encoded */ |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3617 | for (i = 0; i < package->loaded_features; i++) |
Alexandre Julliard | 77b1276 | 2004-07-09 19:43:29 +0000 | [diff] [blame] | 3618 | { |
| 3619 | LPWSTR data = NULL; |
| 3620 | GUID clsid; |
| 3621 | int j; |
| 3622 | INT size; |
| 3623 | |
| 3624 | size = package->features[i].ComponentCount*21*sizeof(WCHAR); |
| 3625 | data = HeapAlloc(GetProcessHeap(), 0, size); |
| 3626 | |
| 3627 | data[0] = 0; |
| 3628 | for (j = 0; j < package->features[i].ComponentCount; j++) |
| 3629 | { |
| 3630 | WCHAR buf[21]; |
| 3631 | TRACE("From %s\n",debugstr_w(package->components |
| 3632 | [package->features[i].Components[j]].ComponentId)); |
| 3633 | CLSIDFromString(package->components |
| 3634 | [package->features[i].Components[j]].ComponentId, |
| 3635 | &clsid); |
| 3636 | encode_base85_guid(&clsid,buf); |
| 3637 | TRACE("to %s\n",debugstr_w(buf)); |
| 3638 | strcatW(data,buf); |
| 3639 | } |
| 3640 | |
| 3641 | size = strlenW(data)*sizeof(WCHAR); |
| 3642 | RegSetValueExW(hkey3,package->features[i].Feature,0,REG_SZ, |
| 3643 | (LPSTR)data,size); |
| 3644 | HeapFree(GetProcessHeap(),0,data); |
| 3645 | } |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3646 | |
| 3647 | RegCloseKey(hkey3); |
| 3648 | RegCloseKey(hkey2); |
| 3649 | |
| 3650 | rc = RegCreateKeyW(hkey,szComponents,&hkey2); |
| 3651 | if (rc != ERROR_SUCCESS) |
| 3652 | goto end; |
| 3653 | |
| 3654 | for (i = 0; i < package->loaded_components; i++) |
| 3655 | { |
| 3656 | if (package->components[i].ComponentId[0]!=0) |
| 3657 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3658 | WCHAR *keypath = NULL; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3659 | MSIRECORD * uirow; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3660 | |
| 3661 | squash_guid(package->components[i].ComponentId,squished_cc); |
| 3662 | rc = RegCreateKeyW(hkey2,squished_cc,&hkey3); |
| 3663 | if (rc != ERROR_SUCCESS) |
| 3664 | continue; |
| 3665 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3666 | keypath = resolve_keypath(package,i); |
| 3667 | if (keypath) |
| 3668 | { |
| 3669 | RegSetValueExW(hkey3,squished_pc,0,REG_SZ,(LPVOID)keypath, |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3670 | (strlenW(keypath)+1)*sizeof(WCHAR)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3671 | RegCloseKey(hkey3); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3672 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 3673 | /* UI stuff */ |
| 3674 | uirow = MSI_CreateRecord(3); |
| 3675 | MSI_RecordSetStringW(uirow,1,productcode); |
| 3676 | MSI_RecordSetStringW(uirow,2,package->components[i]. |
| 3677 | ComponentId); |
| 3678 | MSI_RecordSetStringW(uirow,3,keypath); |
| 3679 | ui_actiondata(package,szProcessComponents,uirow); |
| 3680 | msiobj_release( &uirow->hdr ); |
| 3681 | HeapFree(GetProcessHeap(),0,keypath); |
| 3682 | } |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3683 | } |
| 3684 | } |
| 3685 | end: |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3686 | HeapFree(GetProcessHeap(), 0, productcode); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3687 | RegCloseKey(hkey2); |
| 3688 | RegCloseKey(hkey); |
| 3689 | return rc; |
| 3690 | } |
| 3691 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3692 | static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package) |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3693 | { |
| 3694 | /* |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3695 | * OK this is a bit confusing.. I am given a _Component key and I believe |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3696 | * that the file that is being registered as a type library is the "key file |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3697 | * of that component" which I interpret to mean "The file in the KeyPath of |
| 3698 | * that component". |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3699 | */ |
| 3700 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3701 | MSIQUERY * view; |
| 3702 | MSIRECORD * row = 0; |
| 3703 | static const WCHAR Query[] = { |
| 3704 | 'S','E','L','E','C','T',' ','*',' ', |
| 3705 | 'f','r','o','m',' ','T','y','p','e','L','i','b',0}; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3706 | ITypeLib *ptLib; |
| 3707 | HRESULT res; |
| 3708 | |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3709 | if (!package) |
| 3710 | return ERROR_INVALID_HANDLE; |
| 3711 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3712 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3713 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3714 | return ERROR_SUCCESS; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3715 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3716 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3717 | if (rc != ERROR_SUCCESS) |
| 3718 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3719 | MSI_ViewClose(view); |
| 3720 | msiobj_release(&view->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3721 | return rc; |
| 3722 | } |
| 3723 | |
| 3724 | while (1) |
| 3725 | { |
| 3726 | WCHAR component[0x100]; |
| 3727 | DWORD sz; |
| 3728 | INT index; |
| 3729 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3730 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3731 | if (rc != ERROR_SUCCESS) |
| 3732 | { |
| 3733 | rc = ERROR_SUCCESS; |
| 3734 | break; |
| 3735 | } |
| 3736 | |
| 3737 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3738 | MSI_RecordGetStringW(row,3,component,&sz); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3739 | |
| 3740 | index = get_loaded_component(package,component); |
| 3741 | if (index < 0) |
| 3742 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3743 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3744 | continue; |
| 3745 | } |
| 3746 | |
| 3747 | if (!package->components[index].Enabled || |
| 3748 | !package->components[index].FeatureState) |
| 3749 | { |
| 3750 | TRACE("Skipping typelib reg due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3751 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3752 | continue; |
| 3753 | } |
| 3754 | |
| 3755 | index = get_loaded_file(package,package->components[index].KeyPath); |
| 3756 | |
| 3757 | if (index < 0) |
| 3758 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3759 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3760 | continue; |
| 3761 | } |
| 3762 | |
| 3763 | res = LoadTypeLib(package->files[index].TargetPath,&ptLib); |
| 3764 | if (SUCCEEDED(res)) |
| 3765 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3766 | LPWSTR help; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3767 | WCHAR helpid[0x100]; |
| 3768 | |
| 3769 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3770 | MSI_RecordGetStringW(row,6,helpid,&sz); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3771 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3772 | help = resolve_folder(package,helpid,FALSE,FALSE,NULL); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3773 | res = RegisterTypeLib(ptLib,package->files[index].TargetPath,help); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3774 | HeapFree(GetProcessHeap(),0,help); |
| 3775 | |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3776 | if (!SUCCEEDED(res)) |
| 3777 | ERR("Failed to register type library %s\n", |
| 3778 | debugstr_w(package->files[index].TargetPath)); |
| 3779 | else |
| 3780 | { |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3781 | /* Yes the row has more fields than I need, but #1 is |
| 3782 | correct and the only one I need. Why make a new row? */ |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3783 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3784 | ui_actiondata(package,szRegisterTypeLibraries,row); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3785 | |
| 3786 | TRACE("Registered %s\n", |
| 3787 | debugstr_w(package->files[index].TargetPath)); |
| 3788 | } |
| 3789 | |
| 3790 | if (ptLib) |
| 3791 | ITypeLib_Release(ptLib); |
| 3792 | } |
| 3793 | else |
| 3794 | ERR("Failed to load type library %s\n", |
| 3795 | debugstr_w(package->files[index].TargetPath)); |
| 3796 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3797 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3798 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3799 | MSI_ViewClose(view); |
| 3800 | msiobj_release(&view->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3801 | return rc; |
| 3802 | |
| 3803 | } |
| 3804 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3805 | static UINT register_appid(MSIPACKAGE *package, LPCWSTR clsid, LPCWSTR app ) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3806 | { |
| 3807 | static const WCHAR szAppID[] = { 'A','p','p','I','D',0 }; |
| 3808 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3809 | MSIQUERY * view; |
| 3810 | MSIRECORD * row = 0; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3811 | static const WCHAR ExecSeqQuery[] = |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3812 | {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','p','p','I' |
| 3813 | ,'d',' ','w','h','e','r','e',' ','A','p','p','I','d','=','`','%','s','`',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3814 | HKEY hkey2,hkey3; |
| 3815 | LPWSTR buffer=0; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3816 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3817 | if (!package) |
| 3818 | return ERROR_INVALID_HANDLE; |
| 3819 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3820 | rc = ACTION_OpenQuery(package->db, &view, ExecSeqQuery, clsid); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3821 | if (rc != ERROR_SUCCESS) |
| 3822 | return rc; |
| 3823 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3824 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3825 | if (rc != ERROR_SUCCESS) |
| 3826 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3827 | MSI_ViewClose(view); |
| 3828 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3829 | return rc; |
| 3830 | } |
| 3831 | |
| 3832 | RegCreateKeyW(HKEY_CLASSES_ROOT,szAppID,&hkey2); |
| 3833 | RegCreateKeyW(hkey2,clsid,&hkey3); |
| 3834 | RegSetValueExW(hkey3,NULL,0,REG_SZ,(LPVOID)app, |
| 3835 | (strlenW(app)+1)*sizeof(WCHAR)); |
| 3836 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3837 | rc = MSI_ViewFetch(view,&row); |
| 3838 | if (rc != ERROR_SUCCESS) |
| 3839 | { |
| 3840 | MSI_ViewClose(view); |
| 3841 | msiobj_release(&view->hdr); |
| 3842 | return rc; |
| 3843 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3844 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3845 | if (!MSI_RecordIsNull(row,2)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3846 | { |
| 3847 | LPWSTR deformated=0; |
| 3848 | UINT size; |
| 3849 | static const WCHAR szRemoteServerName[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3850 | {'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',0}; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3851 | buffer = load_dynamic_stringW(row,2); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3852 | size = deformat_string(package,buffer,&deformated); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3853 | RegSetValueExW(hkey3,szRemoteServerName,0,REG_SZ,(LPVOID)deformated, |
| 3854 | size); |
| 3855 | HeapFree(GetProcessHeap(),0,deformated); |
| 3856 | HeapFree(GetProcessHeap(),0,buffer); |
| 3857 | } |
| 3858 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3859 | if (!MSI_RecordIsNull(row,3)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3860 | { |
| 3861 | static const WCHAR szLocalService[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3862 | {'L','o','c','a','l','S','e','r','v','i','c','e',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3863 | UINT size; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3864 | buffer = load_dynamic_stringW(row,3); |
| 3865 | size = (strlenW(buffer)+1) * sizeof(WCHAR); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3866 | RegSetValueExW(hkey3,szLocalService,0,REG_SZ,(LPVOID)buffer,size); |
| 3867 | HeapFree(GetProcessHeap(),0,buffer); |
| 3868 | } |
| 3869 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3870 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3871 | { |
| 3872 | static const WCHAR szService[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3873 | {'S','e','r','v','i','c','e','P','a','r','a','m','e','t','e','r','s',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3874 | UINT size; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3875 | buffer = load_dynamic_stringW(row,4); |
| 3876 | size = (strlenW(buffer)+1) * sizeof(WCHAR); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3877 | RegSetValueExW(hkey3,szService,0,REG_SZ,(LPVOID)buffer,size); |
| 3878 | HeapFree(GetProcessHeap(),0,buffer); |
| 3879 | } |
| 3880 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3881 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3882 | { |
| 3883 | static const WCHAR szDLL[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3884 | {'D','l','l','S','u','r','r','o','g','a','t','e',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3885 | UINT size; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3886 | buffer = load_dynamic_stringW(row,5); |
| 3887 | size = (strlenW(buffer)+1) * sizeof(WCHAR); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3888 | RegSetValueExW(hkey3,szDLL,0,REG_SZ,(LPVOID)buffer,size); |
| 3889 | HeapFree(GetProcessHeap(),0,buffer); |
| 3890 | } |
| 3891 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3892 | if (!MSI_RecordIsNull(row,6)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3893 | { |
| 3894 | static const WCHAR szActivate[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3895 | {'A','c','t','i','v','a','t','e','A','s','S','t','o','r','a','g','e',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3896 | static const WCHAR szY[] = {'Y',0}; |
| 3897 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3898 | if (MSI_RecordGetInteger(row,6)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3899 | RegSetValueExW(hkey3,szActivate,0,REG_SZ,(LPVOID)szY,4); |
| 3900 | } |
| 3901 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3902 | if (!MSI_RecordIsNull(row,7)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3903 | { |
| 3904 | static const WCHAR szRunAs[] = {'R','u','n','A','s',0}; |
| 3905 | static const WCHAR szUser[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3906 | {'I','n','t','e','r','a','c','t','i','v','e',' ','U','s','e','r',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3907 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3908 | if (MSI_RecordGetInteger(row,7)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3909 | RegSetValueExW(hkey3,szRunAs,0,REG_SZ,(LPVOID)szUser,34); |
| 3910 | } |
| 3911 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3912 | msiobj_release(&row->hdr); |
| 3913 | MSI_ViewClose(view); |
| 3914 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3915 | RegCloseKey(hkey3); |
| 3916 | RegCloseKey(hkey2); |
| 3917 | return rc; |
| 3918 | } |
| 3919 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3920 | static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3921 | { |
| 3922 | /* |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 3923 | * Again I am assuming the words, "Whose key file represents" when referring |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3924 | * to a Component as to meaning that Components KeyPath file |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3925 | * |
| 3926 | * Also there is a very strong connection between ClassInfo and ProgID |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 3927 | * that I am mostly glossing over. |
| 3928 | * What would be more propper is to load the ClassInfo and the ProgID info |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3929 | * into memory data structures and then be able to enable and disable them |
| 3930 | * based on component. |
| 3931 | */ |
| 3932 | |
| 3933 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3934 | MSIQUERY * view; |
| 3935 | MSIRECORD * row = 0; |
| 3936 | static const WCHAR ExecSeqQuery[] = { |
| 3937 | 'S','E','L','E','C','T',' ','*',' ', |
| 3938 | 'f','r','o','m',' ','C','l','a','s','s',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3939 | static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; |
| 3940 | static const WCHAR szProgID[] = { 'P','r','o','g','I','D',0 }; |
| 3941 | static const WCHAR szAppID[] = { 'A','p','p','I','D',0 }; |
| 3942 | HKEY hkey,hkey2,hkey3; |
| 3943 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3944 | if (!package) |
| 3945 | return ERROR_INVALID_HANDLE; |
| 3946 | |
| 3947 | rc = RegCreateKeyW(HKEY_CLASSES_ROOT,szCLSID,&hkey); |
| 3948 | if (rc != ERROR_SUCCESS) |
| 3949 | return ERROR_FUNCTION_FAILED; |
| 3950 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3951 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3952 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3953 | { |
| 3954 | rc = ERROR_SUCCESS; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3955 | goto end; |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3956 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3957 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3958 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3959 | if (rc != ERROR_SUCCESS) |
| 3960 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3961 | MSI_ViewClose(view); |
| 3962 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3963 | goto end; |
| 3964 | } |
| 3965 | |
| 3966 | while (1) |
| 3967 | { |
| 3968 | WCHAR clsid[0x100]; |
| 3969 | WCHAR buffer[0x100]; |
| 3970 | WCHAR desc[0x100]; |
| 3971 | DWORD sz; |
| 3972 | INT index; |
| 3973 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3974 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3975 | if (rc != ERROR_SUCCESS) |
| 3976 | { |
| 3977 | rc = ERROR_SUCCESS; |
| 3978 | break; |
| 3979 | } |
| 3980 | |
| 3981 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3982 | MSI_RecordGetStringW(row,3,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3983 | |
| 3984 | index = get_loaded_component(package,buffer); |
| 3985 | |
| 3986 | if (index < 0) |
| 3987 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3988 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3989 | continue; |
| 3990 | } |
| 3991 | |
| 3992 | if (!package->components[index].Enabled || |
| 3993 | !package->components[index].FeatureState) |
| 3994 | { |
| 3995 | TRACE("Skipping class reg due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3996 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3997 | continue; |
| 3998 | } |
| 3999 | |
| 4000 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4001 | MSI_RecordGetStringW(row,1,clsid,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4002 | RegCreateKeyW(hkey,clsid,&hkey2); |
| 4003 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4004 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4005 | { |
| 4006 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4007 | MSI_RecordGetStringW(row,5,desc,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4008 | |
| 4009 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)desc, |
| 4010 | (strlenW(desc)+1)*sizeof(WCHAR)); |
| 4011 | } |
| 4012 | else |
| 4013 | desc[0]=0; |
| 4014 | |
| 4015 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4016 | MSI_RecordGetStringW(row,2,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4017 | |
| 4018 | RegCreateKeyW(hkey2,buffer,&hkey3); |
| 4019 | |
| 4020 | index = get_loaded_file(package,package->components[index].KeyPath); |
| 4021 | RegSetValueExW(hkey3,NULL,0,REG_SZ, |
| 4022 | (LPVOID)package->files[index].TargetPath, |
| 4023 | (strlenW(package->files[index].TargetPath)+1) |
| 4024 | *sizeof(WCHAR)); |
| 4025 | |
| 4026 | RegCloseKey(hkey3); |
| 4027 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4028 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4029 | { |
| 4030 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4031 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4032 | |
| 4033 | RegCreateKeyW(hkey2,szProgID,&hkey3); |
| 4034 | |
| 4035 | RegSetValueExW(hkey3,NULL,0,REG_SZ,(LPVOID)buffer, |
| 4036 | (strlenW(buffer)+1)*sizeof(WCHAR)); |
| 4037 | |
| 4038 | RegCloseKey(hkey3); |
| 4039 | } |
| 4040 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4041 | if (!MSI_RecordIsNull(row,6)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4042 | { |
| 4043 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4044 | MSI_RecordGetStringW(row,6,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4045 | |
| 4046 | RegSetValueExW(hkey2,szAppID,0,REG_SZ,(LPVOID)buffer, |
| 4047 | (strlenW(buffer)+1)*sizeof(WCHAR)); |
| 4048 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4049 | register_appid(package,buffer,desc); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | RegCloseKey(hkey2); |
| 4053 | |
| 4054 | FIXME("Process the rest of the fields >7\n"); |
| 4055 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4056 | ui_actiondata(package,szRegisterClassInfo,row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4057 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4058 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4059 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4060 | MSI_ViewClose(view); |
| 4061 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4062 | |
| 4063 | end: |
| 4064 | RegCloseKey(hkey); |
| 4065 | return rc; |
| 4066 | } |
| 4067 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4068 | static UINT register_progid_base(MSIRECORD * row, LPWSTR clsid) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4069 | { |
| 4070 | static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; |
| 4071 | HKEY hkey,hkey2; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4072 | WCHAR buffer[0x100]; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4073 | DWORD sz; |
| 4074 | |
| 4075 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4076 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4077 | MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4078 | RegCreateKeyW(HKEY_CLASSES_ROOT,buffer,&hkey); |
| 4079 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4080 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4081 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4082 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4083 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4084 | RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) * |
| 4085 | sizeof(WCHAR)); |
| 4086 | } |
| 4087 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4088 | if (!MSI_RecordIsNull(row,3)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4089 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4090 | sz = 0x100; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4091 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4092 | MSI_RecordGetStringW(row,3,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4093 | RegCreateKeyW(hkey,szCLSID,&hkey2); |
| 4094 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) * |
| 4095 | sizeof(WCHAR)); |
| 4096 | |
| 4097 | if (clsid) |
| 4098 | strcpyW(clsid,buffer); |
| 4099 | |
| 4100 | RegCloseKey(hkey2); |
| 4101 | } |
| 4102 | else |
| 4103 | { |
| 4104 | FIXME("UNHANDLED case, Parent progid but classid is NULL\n"); |
| 4105 | return ERROR_FUNCTION_FAILED; |
| 4106 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4107 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4108 | FIXME ("UNHANDLED icon in Progid\n"); |
| 4109 | return ERROR_SUCCESS; |
| 4110 | } |
| 4111 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4112 | static UINT register_progid(MSIPACKAGE *package, MSIRECORD * row, LPWSTR clsid); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4113 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4114 | static UINT register_parent_progid(MSIPACKAGE *package, LPCWSTR parent, |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4115 | LPWSTR clsid) |
| 4116 | { |
| 4117 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4118 | MSIQUERY * view; |
| 4119 | MSIRECORD * row = 0; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4120 | static const WCHAR Query_t[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4121 | {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','P','r','o','g' |
| 4122 | ,'I','d',' ','w','h','e','r','e',' ','P','r','o','g','I','d',' ','=',' ','`' |
| 4123 | ,'%','s','`',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4124 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4125 | if (!package) |
| 4126 | return ERROR_INVALID_HANDLE; |
| 4127 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4128 | rc = ACTION_OpenQuery(package->db, &view, Query_t, parent); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4129 | if (rc != ERROR_SUCCESS) |
| 4130 | return rc; |
| 4131 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4132 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4133 | if (rc != ERROR_SUCCESS) |
| 4134 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4135 | MSI_ViewClose(view); |
| 4136 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4137 | return rc; |
| 4138 | } |
| 4139 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4140 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4141 | if (rc != ERROR_SUCCESS) |
| 4142 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4143 | MSI_ViewClose(view); |
| 4144 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4145 | return rc; |
| 4146 | } |
| 4147 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4148 | register_progid(package,row,clsid); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4149 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4150 | msiobj_release(&row->hdr); |
| 4151 | MSI_ViewClose(view); |
| 4152 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4153 | return rc; |
| 4154 | } |
| 4155 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4156 | static UINT register_progid(MSIPACKAGE *package, MSIRECORD * row, LPWSTR clsid) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4157 | { |
| 4158 | UINT rc = ERROR_SUCCESS; |
| 4159 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4160 | if (MSI_RecordIsNull(row,2)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4161 | rc = register_progid_base(row,clsid); |
| 4162 | else |
| 4163 | { |
| 4164 | WCHAR buffer[0x1000]; |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 4165 | DWORD sz, disp; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4166 | HKEY hkey,hkey2; |
| 4167 | static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; |
| 4168 | |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 4169 | /* check if already registered */ |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4170 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4171 | MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 4172 | RegCreateKeyExW(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, |
| 4173 | KEY_ALL_ACCESS, NULL, &hkey, &disp ); |
| 4174 | if (disp == REG_OPENED_EXISTING_KEY) |
| 4175 | { |
| 4176 | TRACE("Key already registered\n"); |
| 4177 | RegCloseKey(hkey); |
| 4178 | return rc; |
| 4179 | } |
| 4180 | /* clsid is same as parent */ |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4181 | RegCreateKeyW(hkey,szCLSID,&hkey2); |
| 4182 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)clsid, (strlenW(clsid)+1) * |
| 4183 | sizeof(WCHAR)); |
| 4184 | |
| 4185 | RegCloseKey(hkey2); |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 4186 | |
| 4187 | sz = 0x100; |
| 4188 | MSI_RecordGetStringW(row,2,buffer,&sz); |
| 4189 | rc = register_parent_progid(package,buffer,clsid); |
| 4190 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4191 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4192 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4193 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4194 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4195 | RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, |
| 4196 | (strlenW(buffer)+1) * sizeof(WCHAR)); |
| 4197 | } |
| 4198 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4199 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4200 | FIXME ("UNHANDLED icon in Progid\n"); |
| 4201 | |
| 4202 | RegCloseKey(hkey); |
| 4203 | } |
| 4204 | return rc; |
| 4205 | } |
| 4206 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4207 | static UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4208 | { |
| 4209 | /* |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 4210 | * Sigh, here I am just brute force registering all progids |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 4211 | * this needs to be linked to the Classes that have been registered |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4212 | * but the easiest way to do that is to load all these stuff into |
| 4213 | * memory for easy checking. |
| 4214 | * |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 4215 | * Gives me something to continue to work toward. |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4216 | */ |
| 4217 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4218 | MSIQUERY * view; |
| 4219 | MSIRECORD * row = 0; |
| 4220 | static const WCHAR Query[] = { |
| 4221 | 'S','E','L','E','C','T',' ','*',' ', |
| 4222 | 'F','R','O','M',' ','P','r','o','g','I','d',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4223 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4224 | if (!package) |
| 4225 | return ERROR_INVALID_HANDLE; |
| 4226 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4227 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4228 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 4229 | return ERROR_SUCCESS; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4230 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4231 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4232 | if (rc != ERROR_SUCCESS) |
| 4233 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4234 | MSI_ViewClose(view); |
| 4235 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4236 | return rc; |
| 4237 | } |
| 4238 | |
| 4239 | while (1) |
| 4240 | { |
| 4241 | WCHAR clsid[0x1000]; |
| 4242 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4243 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4244 | if (rc != ERROR_SUCCESS) |
| 4245 | { |
| 4246 | rc = ERROR_SUCCESS; |
| 4247 | break; |
| 4248 | } |
| 4249 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4250 | register_progid(package,row,clsid); |
| 4251 | ui_actiondata(package,szRegisterProgIdInfo,row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4252 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4253 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4254 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4255 | MSI_ViewClose(view); |
| 4256 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 4257 | return rc; |
| 4258 | } |
| 4259 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4260 | static UINT build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name, |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4261 | LPWSTR *FilePath) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4262 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4263 | LPWSTR ProductCode; |
| 4264 | LPWSTR SystemFolder; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4265 | LPWSTR dest; |
| 4266 | UINT rc; |
| 4267 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4268 | static const WCHAR szInstaller[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4269 | {'I','n','s','t','a','l','l','e','r','\\',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4270 | static const WCHAR szProductCode[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4271 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4272 | static const WCHAR szFolder[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4273 | {'W','i','n','d','o','w','s','F','o','l','d','e','r',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4274 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4275 | ProductCode = load_dynamic_property(package,szProductCode,&rc); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4276 | if (!ProductCode) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4277 | return rc; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4278 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4279 | SystemFolder = load_dynamic_property(package,szFolder,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4280 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4281 | dest = build_directory_name(3, SystemFolder, szInstaller, ProductCode); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4282 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4283 | create_full_pathW(dest); |
| 4284 | |
| 4285 | *FilePath = build_directory_name(2, dest, icon_name); |
| 4286 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4287 | HeapFree(GetProcessHeap(),0,SystemFolder); |
| 4288 | HeapFree(GetProcessHeap(),0,ProductCode); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4289 | HeapFree(GetProcessHeap(),0,dest); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4290 | return ERROR_SUCCESS; |
| 4291 | } |
| 4292 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4293 | static UINT ACTION_CreateShortcuts(MSIPACKAGE *package) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4294 | { |
| 4295 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4296 | MSIQUERY * view; |
| 4297 | MSIRECORD * row = 0; |
| 4298 | static const WCHAR Query[] = { |
| 4299 | 'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ', |
| 4300 | 'S','h','o','r','t','c','u','t',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4301 | IShellLinkW *sl; |
| 4302 | IPersistFile *pf; |
| 4303 | HRESULT res; |
| 4304 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4305 | if (!package) |
| 4306 | return ERROR_INVALID_HANDLE; |
| 4307 | |
| 4308 | res = CoInitialize( NULL ); |
| 4309 | if (FAILED (res)) |
| 4310 | { |
| 4311 | ERR("CoInitialize failed\n"); |
| 4312 | return ERROR_FUNCTION_FAILED; |
| 4313 | } |
| 4314 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4315 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4316 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 4317 | return ERROR_SUCCESS; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4318 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4319 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4320 | if (rc != ERROR_SUCCESS) |
| 4321 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4322 | MSI_ViewClose(view); |
| 4323 | msiobj_release(&view->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4324 | return rc; |
| 4325 | } |
| 4326 | |
| 4327 | while (1) |
| 4328 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4329 | LPWSTR target_file, target_folder; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4330 | WCHAR buffer[0x100]; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4331 | DWORD sz; |
| 4332 | DWORD index; |
| 4333 | static const WCHAR szlnk[]={'.','l','n','k',0}; |
| 4334 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4335 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4336 | if (rc != ERROR_SUCCESS) |
| 4337 | { |
| 4338 | rc = ERROR_SUCCESS; |
| 4339 | break; |
| 4340 | } |
| 4341 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4342 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4343 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4344 | |
| 4345 | index = get_loaded_component(package,buffer); |
| 4346 | |
| 4347 | if (index < 0) |
| 4348 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4349 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4350 | continue; |
| 4351 | } |
| 4352 | |
| 4353 | if (!package->components[index].Enabled || |
| 4354 | !package->components[index].FeatureState) |
| 4355 | { |
| 4356 | TRACE("Skipping shortcut creation due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4357 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4358 | continue; |
| 4359 | } |
| 4360 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4361 | ui_actiondata(package,szCreateShortcuts,row); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4362 | |
| 4363 | res = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, |
| 4364 | &IID_IShellLinkW, (LPVOID *) &sl ); |
| 4365 | |
| 4366 | if (FAILED(res)) |
| 4367 | { |
| 4368 | ERR("Is IID_IShellLink\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4369 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4370 | continue; |
| 4371 | } |
| 4372 | |
| 4373 | res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf ); |
| 4374 | if( FAILED( res ) ) |
| 4375 | { |
| 4376 | ERR("Is IID_IPersistFile\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4377 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4378 | continue; |
| 4379 | } |
| 4380 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4381 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4382 | MSI_RecordGetStringW(row,2,buffer,&sz); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4383 | target_folder = resolve_folder(package, buffer,FALSE,FALSE,NULL); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4384 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4385 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4386 | MSI_RecordGetStringW(row,3,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4387 | reduce_to_longfilename(buffer); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4388 | if (!strchrW(buffer,'.')) |
| 4389 | strcatW(buffer,szlnk); |
| 4390 | target_file = build_directory_name(2, target_folder, buffer); |
| 4391 | HeapFree(GetProcessHeap(),0,target_folder); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4392 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4393 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4394 | MSI_RecordGetStringW(row,5,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4395 | if (strchrW(buffer,'[')) |
| 4396 | { |
| 4397 | LPWSTR deformated; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4398 | deformat_string(package,buffer,&deformated); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4399 | IShellLinkW_SetPath(sl,deformated); |
| 4400 | HeapFree(GetProcessHeap(),0,deformated); |
| 4401 | } |
| 4402 | else |
| 4403 | { |
| 4404 | FIXME("UNHANDLED shortcut format, advertised shortcut\n"); |
| 4405 | IPersistFile_Release( pf ); |
| 4406 | IShellLinkW_Release( sl ); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4407 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4408 | continue; |
| 4409 | } |
| 4410 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4411 | if (!MSI_RecordIsNull(row,6)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4412 | { |
| 4413 | LPWSTR deformated; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4414 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4415 | MSI_RecordGetStringW(row,6,buffer,&sz); |
| 4416 | deformat_string(package,buffer,&deformated); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4417 | IShellLinkW_SetArguments(sl,deformated); |
| 4418 | HeapFree(GetProcessHeap(),0,deformated); |
| 4419 | } |
| 4420 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4421 | if (!MSI_RecordIsNull(row,7)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4422 | { |
| 4423 | LPWSTR deformated; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4424 | deformated = load_dynamic_stringW(row,7); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4425 | IShellLinkW_SetDescription(sl,deformated); |
| 4426 | HeapFree(GetProcessHeap(),0,deformated); |
| 4427 | } |
| 4428 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4429 | if (!MSI_RecordIsNull(row,8)) |
| 4430 | IShellLinkW_SetHotkey(sl,MSI_RecordGetInteger(row,8)); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4431 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4432 | if (!MSI_RecordIsNull(row,9)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4433 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4434 | WCHAR *Path = NULL; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4435 | INT index; |
| 4436 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4437 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4438 | MSI_RecordGetStringW(row,9,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4439 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4440 | build_icon_path(package,buffer,&Path); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4441 | index = MSI_RecordGetInteger(row,10); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4442 | |
| 4443 | IShellLinkW_SetIconLocation(sl,Path,index); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4444 | HeapFree(GetProcessHeap(),0,Path); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4445 | } |
| 4446 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4447 | if (!MSI_RecordIsNull(row,11)) |
| 4448 | IShellLinkW_SetShowCmd(sl,MSI_RecordGetInteger(row,11)); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4449 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4450 | if (!MSI_RecordIsNull(row,12)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4451 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4452 | LPWSTR Path; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4453 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4454 | MSI_RecordGetStringW(row,12,buffer,&sz); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4455 | Path = resolve_folder(package, buffer, FALSE, FALSE, NULL); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4456 | IShellLinkW_SetWorkingDirectory(sl,Path); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4457 | HeapFree(GetProcessHeap(), 0, Path); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4458 | } |
| 4459 | |
| 4460 | TRACE("Writing shortcut to %s\n",debugstr_w(target_file)); |
| 4461 | IPersistFile_Save(pf,target_file,FALSE); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4462 | |
| 4463 | HeapFree(GetProcessHeap(),0,target_file); |
| 4464 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4465 | IPersistFile_Release( pf ); |
| 4466 | IShellLinkW_Release( sl ); |
| 4467 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4468 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4469 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4470 | MSI_ViewClose(view); |
| 4471 | msiobj_release(&view->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4472 | |
| 4473 | |
| 4474 | CoUninitialize(); |
| 4475 | |
| 4476 | return rc; |
| 4477 | } |
| 4478 | |
| 4479 | |
| 4480 | /* |
| 4481 | * 99% of the work done here is only done for |
| 4482 | * advertised installs. However this is where the |
| 4483 | * Icon table is processed and written out |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 4484 | * so that is what I am going to do here. |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4485 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4486 | static UINT ACTION_PublishProduct(MSIPACKAGE *package) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4487 | { |
| 4488 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4489 | MSIQUERY * view; |
| 4490 | MSIRECORD * row = 0; |
| 4491 | static const WCHAR Query[]={ |
| 4492 | 'S','E','L','E','C','T',' ','*',' ', |
| 4493 | 'f','r','o','m',' ','I','c','o','n',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4494 | DWORD sz; |
| 4495 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4496 | if (!package) |
| 4497 | return ERROR_INVALID_HANDLE; |
| 4498 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4499 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4500 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 4501 | return ERROR_SUCCESS; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4502 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4503 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4504 | if (rc != ERROR_SUCCESS) |
| 4505 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4506 | MSI_ViewClose(view); |
| 4507 | msiobj_release(&view->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4508 | return rc; |
| 4509 | } |
| 4510 | |
| 4511 | while (1) |
| 4512 | { |
| 4513 | HANDLE the_file; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4514 | WCHAR *FilePath=NULL; |
| 4515 | WCHAR *FileName=NULL; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4516 | CHAR buffer[1024]; |
| 4517 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4518 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4519 | if (rc != ERROR_SUCCESS) |
| 4520 | { |
| 4521 | rc = ERROR_SUCCESS; |
| 4522 | break; |
| 4523 | } |
| 4524 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4525 | FileName = load_dynamic_stringW(row,1); |
| 4526 | if (!FileName) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4527 | { |
| 4528 | ERR("Unable to get FileName\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4529 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4530 | continue; |
| 4531 | } |
| 4532 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4533 | build_icon_path(package,FileName,&FilePath); |
| 4534 | |
| 4535 | HeapFree(GetProcessHeap(),0,FileName); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4536 | |
| 4537 | TRACE("Creating icon file at %s\n",debugstr_w(FilePath)); |
| 4538 | |
| 4539 | the_file = CreateFileW(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, |
| 4540 | FILE_ATTRIBUTE_NORMAL, NULL); |
| 4541 | |
| 4542 | if (the_file == INVALID_HANDLE_VALUE) |
| 4543 | { |
| 4544 | ERR("Unable to create file %s\n",debugstr_w(FilePath)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4545 | msiobj_release(&row->hdr); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4546 | HeapFree(GetProcessHeap(),0,FilePath); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4547 | continue; |
| 4548 | } |
| 4549 | |
| 4550 | do |
| 4551 | { |
| 4552 | DWORD write; |
| 4553 | sz = 1024; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4554 | rc = MSI_RecordReadStream(row,2,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4555 | if (rc != ERROR_SUCCESS) |
| 4556 | { |
| 4557 | ERR("Failed to get stream\n"); |
| 4558 | CloseHandle(the_file); |
| 4559 | DeleteFileW(FilePath); |
| 4560 | break; |
| 4561 | } |
| 4562 | WriteFile(the_file,buffer,sz,&write,NULL); |
| 4563 | } while (sz == 1024); |
| 4564 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4565 | HeapFree(GetProcessHeap(),0,FilePath); |
| 4566 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4567 | CloseHandle(the_file); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4568 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4569 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4570 | MSI_ViewClose(view); |
| 4571 | msiobj_release(&view->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4572 | return rc; |
| 4573 | |
| 4574 | } |
| 4575 | |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 4576 | /* Msi functions that seem appropriate here */ |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4577 | UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction ) |
| 4578 | { |
| 4579 | LPWSTR szwAction; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4580 | UINT rc; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4581 | |
| 4582 | TRACE(" exteral attempt at action %s\n",szAction); |
| 4583 | |
| 4584 | if (!szAction) |
| 4585 | return ERROR_FUNCTION_FAILED; |
| 4586 | if (hInstall == 0) |
| 4587 | return ERROR_FUNCTION_FAILED; |
| 4588 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4589 | szwAction = strdupAtoW(szAction); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4590 | |
| 4591 | if (!szwAction) |
| 4592 | return ERROR_FUNCTION_FAILED; |
| 4593 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4594 | |
| 4595 | rc = MsiDoActionW(hInstall, szwAction); |
| 4596 | HeapFree(GetProcessHeap(),0,szwAction); |
| 4597 | return rc; |
| 4598 | } |
| 4599 | |
| 4600 | UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction ) |
| 4601 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4602 | MSIPACKAGE *package; |
| 4603 | UINT ret = ERROR_INVALID_HANDLE; |
| 4604 | |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 4605 | TRACE(" external attempt at action %s \n",debugstr_w(szAction)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4606 | |
| 4607 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 4608 | if( package ) |
| 4609 | { |
| 4610 | ret = ACTION_PerformAction(package,szAction); |
| 4611 | msiobj_release( &package->hdr ); |
| 4612 | } |
| 4613 | return ret; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4614 | } |
| 4615 | |
| 4616 | UINT WINAPI MsiGetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder, |
| 4617 | LPSTR szPathBuf, DWORD* pcchPathBuf) |
| 4618 | { |
| 4619 | LPWSTR szwFolder; |
| 4620 | LPWSTR szwPathBuf; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4621 | UINT rc; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4622 | |
| 4623 | TRACE("getting folder %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf); |
| 4624 | |
| 4625 | if (!szFolder) |
| 4626 | return ERROR_FUNCTION_FAILED; |
| 4627 | if (hInstall == 0) |
| 4628 | return ERROR_FUNCTION_FAILED; |
| 4629 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4630 | szwFolder = strdupAtoW(szFolder); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4631 | |
| 4632 | if (!szwFolder) |
| 4633 | return ERROR_FUNCTION_FAILED; |
| 4634 | |
| 4635 | szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR)); |
| 4636 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4637 | rc = MsiGetTargetPathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf); |
| 4638 | |
| 4639 | WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf, |
| 4640 | *pcchPathBuf, NULL, NULL ); |
| 4641 | |
| 4642 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 4643 | HeapFree(GetProcessHeap(),0,szwPathBuf); |
| 4644 | |
| 4645 | return rc; |
| 4646 | } |
| 4647 | |
| 4648 | UINT WINAPI MsiGetTargetPathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR |
| 4649 | szPathBuf, DWORD* pcchPathBuf) |
| 4650 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4651 | LPWSTR path; |
| 4652 | UINT rc = ERROR_FUNCTION_FAILED; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4653 | MSIPACKAGE *package; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4654 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4655 | TRACE("(%s %p %li)\n",debugstr_w(szFolder),szPathBuf,*pcchPathBuf); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4656 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4657 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4658 | if (!package) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4659 | return ERROR_INVALID_HANDLE; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4660 | path = resolve_folder(package, szFolder, FALSE, FALSE, NULL); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4661 | msiobj_release( &package->hdr ); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4662 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4663 | if (path && (strlenW(path) > *pcchPathBuf)) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4664 | { |
| 4665 | *pcchPathBuf = strlenW(path)+1; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4666 | rc = ERROR_MORE_DATA; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4667 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4668 | else if (path) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4669 | { |
| 4670 | *pcchPathBuf = strlenW(path)+1; |
| 4671 | strcpyW(szPathBuf,path); |
| 4672 | TRACE("Returning Path %s\n",debugstr_w(path)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4673 | rc = ERROR_SUCCESS; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4674 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4675 | HeapFree(GetProcessHeap(),0,path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4676 | |
| 4677 | return rc; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4678 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 4679 | |
| 4680 | |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4681 | UINT WINAPI MsiGetSourcePathA( MSIHANDLE hInstall, LPCSTR szFolder, |
| 4682 | LPSTR szPathBuf, DWORD* pcchPathBuf) |
| 4683 | { |
| 4684 | LPWSTR szwFolder; |
| 4685 | LPWSTR szwPathBuf; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4686 | UINT rc; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4687 | |
| 4688 | TRACE("getting source %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf); |
| 4689 | |
| 4690 | if (!szFolder) |
| 4691 | return ERROR_FUNCTION_FAILED; |
| 4692 | if (hInstall == 0) |
| 4693 | return ERROR_FUNCTION_FAILED; |
| 4694 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4695 | szwFolder = strdupAtoW(szFolder); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4696 | if (!szwFolder) |
| 4697 | return ERROR_FUNCTION_FAILED; |
| 4698 | |
| 4699 | szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR)); |
| 4700 | |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4701 | rc = MsiGetSourcePathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf); |
| 4702 | |
| 4703 | WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf, |
| 4704 | *pcchPathBuf, NULL, NULL ); |
| 4705 | |
| 4706 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 4707 | HeapFree(GetProcessHeap(),0,szwPathBuf); |
| 4708 | |
| 4709 | return rc; |
| 4710 | } |
| 4711 | |
| 4712 | UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR |
| 4713 | szPathBuf, DWORD* pcchPathBuf) |
| 4714 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4715 | LPWSTR path; |
| 4716 | UINT rc = ERROR_FUNCTION_FAILED; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4717 | MSIPACKAGE *package; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4718 | |
| 4719 | TRACE("(%s %p %li)\n",debugstr_w(szFolder),szPathBuf,*pcchPathBuf); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4720 | |
| 4721 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 4722 | if( !package ) |
| 4723 | return ERROR_INVALID_HANDLE; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4724 | path = resolve_folder(package, szFolder, TRUE, FALSE, NULL); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4725 | msiobj_release( &package->hdr ); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4726 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4727 | if (path && strlenW(path) > *pcchPathBuf) |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4728 | { |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4729 | *pcchPathBuf = strlenW(path)+1; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4730 | rc = ERROR_MORE_DATA; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4731 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4732 | else if (path) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4733 | { |
| 4734 | *pcchPathBuf = strlenW(path)+1; |
| 4735 | strcpyW(szPathBuf,path); |
| 4736 | TRACE("Returning Path %s\n",debugstr_w(path)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4737 | rc = ERROR_SUCCESS; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4738 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame^] | 4739 | HeapFree(GetProcessHeap(),0,path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4740 | |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4741 | return rc; |
| 4742 | } |
| 4743 | |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4744 | |
| 4745 | UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, |
| 4746 | LPCSTR szFolderPath) |
| 4747 | { |
| 4748 | LPWSTR szwFolder; |
| 4749 | LPWSTR szwFolderPath; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4750 | UINT rc; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4751 | |
| 4752 | if (!szFolder) |
| 4753 | return ERROR_FUNCTION_FAILED; |
| 4754 | if (hInstall == 0) |
| 4755 | return ERROR_FUNCTION_FAILED; |
| 4756 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4757 | szwFolder = strdupAtoW(szFolder); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4758 | if (!szwFolder) |
| 4759 | return ERROR_FUNCTION_FAILED; |
| 4760 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4761 | szwFolderPath = strdupAtoW(szFolderPath); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4762 | if (!szwFolderPath) |
| 4763 | { |
| 4764 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 4765 | return ERROR_FUNCTION_FAILED; |
| 4766 | } |
| 4767 | |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4768 | rc = MsiSetTargetPathW(hInstall, szwFolder, szwFolderPath); |
| 4769 | |
| 4770 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 4771 | HeapFree(GetProcessHeap(),0,szwFolderPath); |
| 4772 | |
| 4773 | return rc; |
| 4774 | } |
| 4775 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4776 | UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder, |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4777 | LPCWSTR szFolderPath) |
| 4778 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 4779 | DWORD i; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4780 | LPWSTR path = NULL; |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 4781 | MSIFOLDER *folder; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4782 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4783 | TRACE("(%p %s %s)\n",package, debugstr_w(szFolder),debugstr_w(szFolderPath)); |
| 4784 | |
| 4785 | if (package==NULL) |
| 4786 | return ERROR_INVALID_HANDLE; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4787 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4788 | if (szFolderPath[0]==0) |
| 4789 | return ERROR_FUNCTION_FAILED; |
| 4790 | |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 4791 | if (GetFileAttributesW(szFolderPath) == INVALID_FILE_ATTRIBUTES) |
| 4792 | return ERROR_FUNCTION_FAILED; |
| 4793 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4794 | path = resolve_folder(package,szFolder,FALSE,FALSE,&folder); |
| 4795 | if (!path) |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 4796 | return ERROR_INVALID_PARAMETER; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4797 | HeapFree(GetProcessHeap(),0,path); |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 4798 | |
| 4799 | strcpyW(folder->Property,szFolderPath); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4800 | |
| 4801 | for (i = 0; i < package->loaded_folders; i++) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4802 | package->folders[i].ResolvedTarget=NULL; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4803 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4804 | for (i = 0; i < package->loaded_folders; i++) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4805 | { |
| 4806 | path = resolve_folder(package, package->folders[i].Directory, FALSE, |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4807 | TRUE, NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4808 | HeapFree(GetProcessHeap(),0,path); |
| 4809 | } |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4810 | |
| 4811 | return ERROR_SUCCESS; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 4812 | } |
| 4813 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4814 | UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder, |
| 4815 | LPCWSTR szFolderPath) |
| 4816 | { |
| 4817 | MSIPACKAGE *package; |
| 4818 | UINT ret; |
| 4819 | |
| 4820 | TRACE("(%s %s)\n",debugstr_w(szFolder),debugstr_w(szFolderPath)); |
| 4821 | |
| 4822 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 4823 | ret = MSI_SetTargetPathW( package, szFolder, szFolderPath ); |
| 4824 | msiobj_release( &package->hdr ); |
| 4825 | return ret; |
| 4826 | } |
| 4827 | |
Vitaly Lipatov | 5c4116b | 2004-12-16 14:29:25 +0000 | [diff] [blame] | 4828 | /*********************************************************************** |
| 4829 | * MsiGetMode (MSI.@) |
| 4830 | * |
| 4831 | * Returns an internal installer state (if it is running in a mode iRunMode) |
| 4832 | * |
| 4833 | * PARAMS |
| 4834 | * hInstall [I] Handle to the installation |
| 4835 | * hRunMode [I] Checking run mode |
| 4836 | * MSIRUNMODE_ADMIN Administrative mode |
| 4837 | * MSIRUNMODE_ADVERTISE Advertisement mode |
| 4838 | * MSIRUNMODE_MAINTENANCE Maintenance mode |
| 4839 | * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled |
| 4840 | * MSIRUNMODE_LOGENABLED Log file is writing |
| 4841 | * MSIRUNMODE_OPERATIONS Operations in progress?? |
| 4842 | * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed |
| 4843 | * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation |
| 4844 | * MSIRUNMODE_CABINET Files from cabinet are installed |
| 4845 | * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is supressed |
| 4846 | * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is supressed |
| 4847 | * MSIRUNMODE_RESERVED11 Reserved |
| 4848 | * MSIRUNMODE_WINDOWS9X Running under Windows95/98 |
| 4849 | * MSIRUNMODE_ZAWENABLED Demand installation is supported |
| 4850 | * MSIRUNMODE_RESERVED14 Reserved |
| 4851 | * MSIRUNMODE_RESERVED15 Reserved |
| 4852 | * MSIRUNMODE_SCHEDULED called from install script |
| 4853 | * MSIRUNMODE_ROLLBACK called from rollback script |
| 4854 | * MSIRUNMODE_COMMIT called from commit script |
| 4855 | * |
| 4856 | * RETURNS |
| 4857 | * In the state: TRUE |
| 4858 | * Not in the state: FALSE |
| 4859 | * |
| 4860 | */ |
| 4861 | |
| 4862 | BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4863 | { |
Vitaly Lipatov | 5c4116b | 2004-12-16 14:29:25 +0000 | [diff] [blame] | 4864 | FIXME("STUB (iRunMode=%i)\n",iRunMode); |
| 4865 | return TRUE; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 4866 | } |
| 4867 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4868 | /* |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 4869 | * According to the docs, when this is called it immediately recalculates |
| 4870 | * all the component states as well |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4871 | */ |
| 4872 | UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature, |
| 4873 | INSTALLSTATE iState) |
| 4874 | { |
| 4875 | LPWSTR szwFeature = NULL; |
| 4876 | UINT rc; |
| 4877 | |
| 4878 | szwFeature = strdupAtoW(szFeature); |
| 4879 | |
| 4880 | if (!szwFeature) |
| 4881 | return ERROR_FUNCTION_FAILED; |
| 4882 | |
| 4883 | rc = MsiSetFeatureStateW(hInstall,szwFeature, iState); |
| 4884 | |
| 4885 | HeapFree(GetProcessHeap(),0,szwFeature); |
| 4886 | |
| 4887 | return rc; |
| 4888 | } |
| 4889 | |
| 4890 | UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature, |
| 4891 | INSTALLSTATE iState) |
| 4892 | { |
| 4893 | MSIPACKAGE* package; |
| 4894 | INT index; |
| 4895 | |
| 4896 | TRACE(" %s to %i\n",debugstr_w(szFeature), iState); |
| 4897 | |
| 4898 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 4899 | if (!package) |
| 4900 | return ERROR_INVALID_HANDLE; |
| 4901 | |
| 4902 | index = get_loaded_feature(package,szFeature); |
| 4903 | if (index < 0) |
| 4904 | return ERROR_UNKNOWN_FEATURE; |
| 4905 | |
| 4906 | package->features[index].State = iState; |
| 4907 | |
| 4908 | return ERROR_SUCCESS; |
| 4909 | } |
| 4910 | |
| 4911 | UINT WINAPI MsiGetFeatureStateA(MSIHANDLE hInstall, LPSTR szFeature, |
| 4912 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 4913 | { |
| 4914 | LPWSTR szwFeature = NULL; |
| 4915 | UINT rc; |
| 4916 | |
| 4917 | szwFeature = strdupAtoW(szFeature); |
| 4918 | |
| 4919 | rc = MsiGetFeatureStateW(hInstall,szwFeature,piInstalled, piAction); |
| 4920 | |
| 4921 | HeapFree( GetProcessHeap(), 0 , szwFeature); |
| 4922 | |
| 4923 | return rc; |
| 4924 | } |
| 4925 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4926 | UINT MSI_GetFeatureStateW(MSIPACKAGE *package, LPWSTR szFeature, |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4927 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 4928 | { |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4929 | INT index; |
| 4930 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4931 | index = get_loaded_feature(package,szFeature); |
| 4932 | if (index < 0) |
| 4933 | return ERROR_UNKNOWN_FEATURE; |
| 4934 | |
| 4935 | if (piInstalled) |
| 4936 | *piInstalled = package->features[index].State; |
| 4937 | |
| 4938 | if (piAction) |
| 4939 | { |
| 4940 | if (package->features[index].Enabled) |
| 4941 | *piAction = INSTALLSTATE_LOCAL; |
| 4942 | else |
| 4943 | *piAction = INSTALLSTATE_UNKNOWN; |
| 4944 | } |
| 4945 | |
| 4946 | return ERROR_SUCCESS; |
| 4947 | } |
| 4948 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4949 | UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPWSTR szFeature, |
| 4950 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 4951 | { |
| 4952 | MSIPACKAGE* package; |
| 4953 | UINT ret; |
| 4954 | |
| 4955 | TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled, |
| 4956 | piAction); |
| 4957 | |
| 4958 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 4959 | if (!package) |
| 4960 | return ERROR_INVALID_HANDLE; |
| 4961 | ret = MSI_GetFeatureStateW(package, szFeature, piInstalled, piAction); |
| 4962 | msiobj_release( &package->hdr ); |
| 4963 | return ret; |
| 4964 | } |
| 4965 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4966 | UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szComponent, |
| 4967 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 4968 | { |
| 4969 | LPWSTR szwComponent= NULL; |
| 4970 | UINT rc; |
| 4971 | |
| 4972 | szwComponent= strdupAtoW(szComponent); |
| 4973 | |
| 4974 | rc = MsiGetComponentStateW(hInstall,szwComponent,piInstalled, piAction); |
| 4975 | |
| 4976 | HeapFree( GetProcessHeap(), 0 , szwComponent); |
| 4977 | |
| 4978 | return rc; |
| 4979 | } |
| 4980 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4981 | UINT MSI_GetComponentStateW(MSIPACKAGE *package, LPWSTR szComponent, |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4982 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 4983 | { |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4984 | INT index; |
| 4985 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4986 | TRACE("%p %s %p %p\n", package, debugstr_w(szComponent), piInstalled, |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4987 | piAction); |
| 4988 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4989 | index = get_loaded_component(package,szComponent); |
| 4990 | if (index < 0) |
| 4991 | return ERROR_UNKNOWN_COMPONENT; |
| 4992 | |
| 4993 | if (piInstalled) |
| 4994 | *piInstalled = package->components[index].State; |
| 4995 | |
| 4996 | if (piAction) |
| 4997 | { |
| 4998 | if (package->components[index].Enabled && |
| 4999 | package->components[index].FeatureState) |
| 5000 | *piAction = INSTALLSTATE_LOCAL; |
| 5001 | else |
| 5002 | *piAction = INSTALLSTATE_UNKNOWN; |
| 5003 | } |
| 5004 | |
| 5005 | return ERROR_SUCCESS; |
| 5006 | } |
| 5007 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5008 | UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPWSTR szComponent, |
| 5009 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5010 | { |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 5011 | MSIPACKAGE* package; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5012 | UINT ret; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5013 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5014 | TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szComponent), |
| 5015 | piInstalled, piAction); |
| 5016 | |
| 5017 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 5018 | if (!package) |
| 5019 | return ERROR_INVALID_HANDLE; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5020 | ret = MSI_GetComponentStateW( package, szComponent, piInstalled, piAction); |
| 5021 | msiobj_release( &package->hdr ); |
| 5022 | return ret; |
| 5023 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 5024 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5025 | #if 0 |
| 5026 | static UINT ACTION_Template(MSIPACKAGE *package) |
| 5027 | { |
| 5028 | UINT rc; |
| 5029 | MSIQUERY * view; |
| 5030 | MSIRECORD * row = 0; |
| 5031 | static const WCHAR ExecSeqQuery[] = {0}; |
Aric Stewart | eb0e0df | 2004-06-30 19:38:36 +0000 | [diff] [blame] | 5032 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5033 | rc = MsiDatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5034 | if (rc != ERROR_SUCCESS) |
| 5035 | return rc; |
| 5036 | |
| 5037 | rc = MsiViewExecute(view, 0); |
| 5038 | if (rc != ERROR_SUCCESS) |
| 5039 | { |
| 5040 | MsiViewClose(view); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5041 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5042 | return rc; |
| 5043 | } |
| 5044 | |
| 5045 | while (1) |
| 5046 | { |
| 5047 | rc = MsiViewFetch(view,&row); |
| 5048 | if (rc != ERROR_SUCCESS) |
| 5049 | { |
| 5050 | rc = ERROR_SUCCESS; |
| 5051 | break; |
| 5052 | } |
| 5053 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5054 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5055 | } |
| 5056 | MsiViewClose(view); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5057 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5058 | return rc; |
| 5059 | } |
| 5060 | #endif |