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 | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 51 | #include "action.h" |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 52 | |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 53 | #define REG_PROGRESS_VALUE 13200 |
| 54 | #define COMPONENT_PROGRESS_VALUE 24000 |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 55 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 56 | WINE_DEFAULT_DEBUG_CHANNEL(msi); |
| 57 | |
| 58 | /* |
| 59 | * Prototypes |
| 60 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 61 | static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran); |
| 62 | static UINT ACTION_ProcessUISequence(MSIPACKAGE *package); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 63 | |
Aric Stewart | 09d35c3 | 2004-12-27 19:00:26 +0000 | [diff] [blame] | 64 | static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 65 | UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 66 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 67 | static UINT ACTION_LaunchConditions(MSIPACKAGE *package); |
| 68 | static UINT ACTION_CostInitialize(MSIPACKAGE *package); |
| 69 | static UINT ACTION_CreateFolders(MSIPACKAGE *package); |
| 70 | static UINT ACTION_CostFinalize(MSIPACKAGE *package); |
| 71 | static UINT ACTION_FileCost(MSIPACKAGE *package); |
| 72 | static UINT ACTION_InstallFiles(MSIPACKAGE *package); |
| 73 | static UINT ACTION_DuplicateFiles(MSIPACKAGE *package); |
| 74 | static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 75 | static UINT ACTION_InstallInitialize(MSIPACKAGE *package); |
| 76 | static UINT ACTION_InstallValidate(MSIPACKAGE *package); |
| 77 | static UINT ACTION_ProcessComponents(MSIPACKAGE *package); |
| 78 | static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package); |
| 79 | static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package); |
| 80 | static UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package); |
| 81 | static UINT ACTION_CreateShortcuts(MSIPACKAGE *package); |
| 82 | static UINT ACTION_PublishProduct(MSIPACKAGE *package); |
Aric Stewart | 516a9c7 | 2005-01-14 15:59:26 +0000 | [diff] [blame] | 83 | static UINT ACTION_WriteIniValues(MSIPACKAGE *package); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 84 | static UINT ACTION_SelfRegModules(MSIPACKAGE *package); |
| 85 | static UINT ACTION_PublishFeatures(MSIPACKAGE *package); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 86 | static UINT ACTION_RegisterProduct(MSIPACKAGE *package); |
| 87 | static UINT ACTION_InstallExecute(MSIPACKAGE *package); |
| 88 | static UINT ACTION_InstallFinalize(MSIPACKAGE *package); |
| 89 | static UINT ACTION_ForceReboot(MSIPACKAGE *package); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 90 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 91 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 92 | static UINT build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name, |
| 93 | LPWSTR *FilePath); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 94 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 95 | /* |
| 96 | * consts and values used |
| 97 | */ |
| 98 | static const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0}; |
| 99 | static const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0}; |
| 100 | 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] | 101 | static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0}; |
| 102 | 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] | 103 | static const WCHAR c_collen[] = {'C',':','\\',0}; |
| 104 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 105 | static const WCHAR cszbs[]={'\\',0}; |
| 106 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 107 | const static WCHAR szCreateFolders[] = |
| 108 | {'C','r','e','a','t','e','F','o','l','d','e','r','s',0}; |
| 109 | const static WCHAR szCostFinalize[] = |
| 110 | {'C','o','s','t','F','i','n','a','l','i','z','e',0}; |
| 111 | const static WCHAR szInstallFiles[] = |
| 112 | {'I','n','s','t','a','l','l','F','i','l','e','s',0}; |
| 113 | const static WCHAR szDuplicateFiles[] = |
| 114 | {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; |
| 115 | const static WCHAR szWriteRegistryValues[] = |
| 116 | {'W','r','i','t','e','R','e','g','i','s','t','r','y','V','a','l','u','e','s',0}; |
| 117 | const static WCHAR szCostInitialize[] = |
| 118 | {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0}; |
| 119 | const static WCHAR szFileCost[] = {'F','i','l','e','C','o','s','t',0}; |
| 120 | const static WCHAR szInstallInitialize[] = |
| 121 | {'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0}; |
| 122 | const static WCHAR szInstallValidate[] = |
| 123 | {'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0}; |
| 124 | const static WCHAR szLaunchConditions[] = |
| 125 | {'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] | 126 | const static WCHAR szProcessComponents[] = |
| 127 | {'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] | 128 | const static WCHAR szRegisterTypeLibraries[] = |
| 129 | {'R','e','g','i','s','t','e','r','T','y','p','e','L','i','b','r','a','r', |
| 130 | 'i','e','s',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 131 | const static WCHAR szRegisterClassInfo[] = |
| 132 | {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0}; |
| 133 | const static WCHAR szRegisterProgIdInfo[] = |
| 134 | {'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] | 135 | const static WCHAR szCreateShortcuts[] = |
| 136 | {'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0}; |
| 137 | const static WCHAR szPublishProduct[] = |
| 138 | {'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0}; |
Aric Stewart | 516a9c7 | 2005-01-14 15:59:26 +0000 | [diff] [blame] | 139 | const static WCHAR szWriteIniValues[] = |
| 140 | {'W','r','i','t','e','I','n','i','V','a','l','u','e','s',0}; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 141 | const static WCHAR szSelfRegModules[] = |
| 142 | {'S','e','l','f','R','e','g','M','o','d','u','l','e','s',0}; |
| 143 | const static WCHAR szPublishFeatures[] = |
| 144 | {'P','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0}; |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 145 | const static WCHAR szRegisterProduct[] = |
| 146 | {'R','e','g','i','s','t','e','r','P','r','o','d','u','c','t',0}; |
| 147 | const static WCHAR szInstallExecute[] = |
| 148 | {'I','n','s','t','a','l','l','E','x','e','c','u','t','e',0}; |
| 149 | const static WCHAR szInstallExecuteAgain[] = |
| 150 | {'I','n','s','t','a','l','l','E','x','e','c','u','t','e','A','g','a','i','n',0}; |
| 151 | const static WCHAR szInstallFinalize[] = |
| 152 | {'I','n','s','t','a','l','l','F','i','n','a','l','i','z','e',0}; |
| 153 | const static WCHAR szForceReboot[] = |
| 154 | {'F','o','r','c','e','R','e','b','o','o','t',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 155 | |
| 156 | /******************************************************** |
| 157 | * helper functions to get around current HACKS and such |
| 158 | ********************************************************/ |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 159 | inline static void reduce_to_longfilename(WCHAR* filename) |
| 160 | { |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 161 | LPWSTR p = strchrW(filename,'|'); |
| 162 | if (p) |
| 163 | memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR)); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 166 | WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index) |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 167 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 168 | UINT rc; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 169 | DWORD sz; |
| 170 | LPWSTR ret; |
| 171 | |
| 172 | sz = 0; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 173 | if (MSI_RecordIsNull(row,index)) |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 174 | return NULL; |
| 175 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 176 | rc = MSI_RecordGetStringW(row,index,NULL,&sz); |
| 177 | |
| 178 | /* having an empty string is different than NULL */ |
| 179 | if (sz == 0) |
| 180 | { |
| 181 | ret = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)); |
| 182 | ret[0] = 0; |
| 183 | return ret; |
| 184 | } |
| 185 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 186 | sz ++; |
| 187 | ret = HeapAlloc(GetProcessHeap(),0,sz * sizeof (WCHAR)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 188 | rc = MSI_RecordGetStringW(row,index,ret,&sz); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 189 | if (rc!=ERROR_SUCCESS) |
| 190 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 191 | ERR("Unable to load dynamic string\n"); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 192 | HeapFree(GetProcessHeap(), 0, ret); |
| 193 | ret = NULL; |
| 194 | } |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 195 | return ret; |
| 196 | } |
| 197 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 198 | LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop, UINT* rc) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 199 | { |
| 200 | DWORD sz = 0; |
| 201 | LPWSTR str; |
| 202 | UINT r; |
| 203 | |
| 204 | r = MSI_GetPropertyW(package, prop, NULL, &sz); |
Aric Stewart | 2595570 | 2004-12-22 17:13:26 +0000 | [diff] [blame] | 205 | if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 206 | { |
| 207 | if (rc) |
| 208 | *rc = r; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 209 | return NULL; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 210 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 211 | sz++; |
| 212 | str = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR)); |
| 213 | r = MSI_GetPropertyW(package, prop, str, &sz); |
| 214 | if (r != ERROR_SUCCESS) |
| 215 | { |
| 216 | HeapFree(GetProcessHeap(),0,str); |
| 217 | str = NULL; |
| 218 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 219 | if (rc) |
| 220 | *rc = r; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 221 | return str; |
| 222 | } |
| 223 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 224 | int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component ) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 225 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 226 | int rc = -1; |
| 227 | DWORD i; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 228 | |
| 229 | for (i = 0; i < package->loaded_components; i++) |
| 230 | { |
| 231 | if (strcmpW(Component,package->components[i].Component)==0) |
| 232 | { |
| 233 | rc = i; |
| 234 | break; |
| 235 | } |
| 236 | } |
| 237 | return rc; |
| 238 | } |
| 239 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 240 | int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature ) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 241 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 242 | int rc = -1; |
| 243 | DWORD i; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 244 | |
| 245 | for (i = 0; i < package->loaded_features; i++) |
| 246 | { |
| 247 | if (strcmpW(Feature,package->features[i].Feature)==0) |
| 248 | { |
| 249 | rc = i; |
| 250 | break; |
| 251 | } |
| 252 | } |
| 253 | return rc; |
| 254 | } |
| 255 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 256 | int get_loaded_file(MSIPACKAGE* package, LPCWSTR file) |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 257 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 258 | int rc = -1; |
| 259 | DWORD i; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 260 | |
| 261 | for (i = 0; i < package->loaded_files; i++) |
| 262 | { |
| 263 | if (strcmpW(file,package->files[i].File)==0) |
| 264 | { |
| 265 | rc = i; |
| 266 | break; |
| 267 | } |
| 268 | } |
| 269 | return rc; |
| 270 | } |
| 271 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 272 | int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 273 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 274 | DWORD i; |
| 275 | DWORD index; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 276 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 277 | if (!package) |
| 278 | return -2; |
| 279 | |
| 280 | for (i=0; i < package->loaded_files; i++) |
| 281 | if (strcmpW(package->files[i].File,name)==0) |
| 282 | return -1; |
| 283 | |
| 284 | index = package->loaded_files; |
| 285 | package->loaded_files++; |
| 286 | if (package->loaded_files== 1) |
| 287 | package->files = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE)); |
| 288 | else |
| 289 | package->files = HeapReAlloc(GetProcessHeap(),0, |
| 290 | package->files , package->loaded_files * sizeof(MSIFILE)); |
| 291 | |
| 292 | memset(&package->files[index],0,sizeof(MSIFILE)); |
| 293 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 294 | package->files[index].File = dupstrW(name); |
| 295 | package->files[index].TargetPath = dupstrW(path); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 296 | package->files[index].Temporary = TRUE; |
| 297 | |
| 298 | TRACE("Tracking tempfile (%s)\n",debugstr_w(package->files[index].File)); |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 303 | static void remove_tracked_tempfiles(MSIPACKAGE* package) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 304 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 305 | DWORD i; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 306 | |
| 307 | if (!package) |
| 308 | return; |
| 309 | |
| 310 | for (i = 0; i < package->loaded_files; i++) |
| 311 | { |
| 312 | if (package->files[i].Temporary) |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 313 | { |
| 314 | TRACE("Cleaning up %s\n",debugstr_w(package->files[i].TargetPath)); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 315 | DeleteFileW(package->files[i].TargetPath); |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 316 | } |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 317 | |
| 318 | } |
| 319 | } |
| 320 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 321 | /* wrapper to resist a need for a full rewrite right now */ |
| 322 | DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data ) |
| 323 | { |
| 324 | if (ptr) |
| 325 | { |
| 326 | MSIRECORD *rec = MSI_CreateRecord(1); |
| 327 | DWORD size = 0; |
| 328 | WCHAR size_buf[2] = {' ',0}; |
| 329 | |
| 330 | MSI_RecordSetStringW(rec,0,ptr); |
| 331 | MSI_FormatRecordW(package,rec,size_buf,&size); |
| 332 | if (size > 0) |
| 333 | { |
| 334 | size++; |
| 335 | *data = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR)); |
| 336 | MSI_FormatRecordW(package,rec,*data,&size); |
| 337 | return sizeof(WCHAR)*size; |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | *data = NULL; |
| 342 | return 0; |
| 343 | } |
| 344 | |
Aric Stewart | 51cf7d1 | 2005-01-03 14:29:09 +0000 | [diff] [blame] | 345 | /* Called when the package is being closed */ |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 346 | void ACTION_free_package_structures( MSIPACKAGE* package) |
Aric Stewart | 51cf7d1 | 2005-01-03 14:29:09 +0000 | [diff] [blame] | 347 | { |
| 348 | INT i; |
| 349 | |
| 350 | TRACE("Freeing package action data\n"); |
| 351 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 352 | remove_tracked_tempfiles(package); |
| 353 | |
Aric Stewart | 51cf7d1 | 2005-01-03 14:29:09 +0000 | [diff] [blame] | 354 | /* No dynamic buffers in features */ |
| 355 | if (package->features && package->loaded_features > 0) |
| 356 | HeapFree(GetProcessHeap(),0,package->features); |
| 357 | |
| 358 | for (i = 0; i < package->loaded_folders; i++) |
| 359 | { |
| 360 | HeapFree(GetProcessHeap(),0,package->folders[i].Directory); |
| 361 | HeapFree(GetProcessHeap(),0,package->folders[i].TargetDefault); |
| 362 | HeapFree(GetProcessHeap(),0,package->folders[i].SourceDefault); |
| 363 | HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedTarget); |
| 364 | HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedSource); |
| 365 | HeapFree(GetProcessHeap(),0,package->folders[i].Property); |
| 366 | } |
| 367 | if (package->folders && package->loaded_folders > 0) |
| 368 | HeapFree(GetProcessHeap(),0,package->folders); |
| 369 | |
| 370 | /* no dynamic buffers in components */ |
| 371 | if (package->components && package->loaded_components > 0) |
| 372 | HeapFree(GetProcessHeap(),0,package->components); |
| 373 | |
| 374 | for (i = 0; i < package->loaded_files; i++) |
| 375 | { |
| 376 | HeapFree(GetProcessHeap(),0,package->files[i].File); |
| 377 | HeapFree(GetProcessHeap(),0,package->files[i].FileName); |
| 378 | HeapFree(GetProcessHeap(),0,package->files[i].Version); |
| 379 | HeapFree(GetProcessHeap(),0,package->files[i].Language); |
| 380 | HeapFree(GetProcessHeap(),0,package->files[i].SourcePath); |
| 381 | HeapFree(GetProcessHeap(),0,package->files[i].TargetPath); |
| 382 | } |
| 383 | |
| 384 | if (package->files && package->loaded_files > 0) |
| 385 | HeapFree(GetProcessHeap(),0,package->files); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 386 | |
| 387 | for (i = 0; i < package->DeferredActionCount; i++) |
| 388 | HeapFree(GetProcessHeap(),0,package->DeferredAction[i]); |
| 389 | HeapFree(GetProcessHeap(),0,package->DeferredAction); |
| 390 | |
| 391 | for (i = 0; i < package->CommitActionCount; i++) |
| 392 | HeapFree(GetProcessHeap(),0,package->CommitAction[i]); |
| 393 | HeapFree(GetProcessHeap(),0,package->CommitAction); |
| 394 | |
| 395 | HeapFree(GetProcessHeap(),0,package->PackagePath); |
Aric Stewart | 51cf7d1 | 2005-01-03 14:29:09 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 398 | static void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d ) |
| 399 | { |
| 400 | MSIRECORD * row; |
| 401 | |
| 402 | row = MSI_CreateRecord(4); |
| 403 | MSI_RecordSetInteger(row,1,a); |
| 404 | MSI_RecordSetInteger(row,2,b); |
| 405 | MSI_RecordSetInteger(row,3,c); |
| 406 | MSI_RecordSetInteger(row,4,d); |
| 407 | MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row); |
| 408 | msiobj_release(&row->hdr); |
| 409 | } |
| 410 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 411 | static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 412 | { |
| 413 | static const WCHAR Query_t[] = |
| 414 | {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','c','t','i','o', |
| 415 | 'n','T','e','x','t',' ','w','h','e','r','e',' ','A','c','t','i','o','n',' ','=', |
| 416 | ' ','\'','%','s','\'',0}; |
| 417 | WCHAR message[1024]; |
| 418 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 419 | MSIQUERY * view; |
| 420 | MSIRECORD * row = 0; |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 421 | DWORD size; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 422 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 423 | if (!package->LastAction || strcmpW(package->LastAction,action)) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 424 | { |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 425 | rc = MSI_OpenQuery(package->db, &view, Query_t, action); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 426 | if (rc != ERROR_SUCCESS) |
| 427 | return; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 428 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 429 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 430 | if (rc != ERROR_SUCCESS) |
| 431 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 432 | MSI_ViewClose(view); |
| 433 | return; |
| 434 | } |
| 435 | rc = MSI_ViewFetch(view,&row); |
| 436 | if (rc != ERROR_SUCCESS) |
| 437 | { |
| 438 | MSI_ViewClose(view); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 439 | return; |
| 440 | } |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 441 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 442 | if (MSI_RecordIsNull(row,3)) |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 443 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 444 | msiobj_release(&row->hdr); |
| 445 | MSI_ViewClose(view); |
| 446 | msiobj_release(&view->hdr); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 447 | return; |
| 448 | } |
| 449 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 450 | /* update the cached actionformat */ |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 451 | HeapFree(GetProcessHeap(),0,package->ActionFormat); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 452 | package->ActionFormat = load_dynamic_stringW(row,3); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 453 | |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 454 | HeapFree(GetProcessHeap(),0,package->LastAction); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 455 | package->LastAction = dupstrW(action); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 456 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 457 | msiobj_release(&row->hdr); |
| 458 | MSI_ViewClose(view); |
| 459 | msiobj_release(&view->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 460 | } |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 461 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 462 | MSI_RecordSetStringW(record,0,package->ActionFormat); |
| 463 | size = 1024; |
| 464 | MSI_FormatRecordW(package,record,message,&size); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 465 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 466 | row = MSI_CreateRecord(1); |
| 467 | MSI_RecordSetStringW(row,1,message); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 468 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 469 | MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row); |
| 470 | msiobj_release(&row->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 474 | static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 475 | { |
| 476 | static const WCHAR template_s[]= |
| 477 | {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ','%','s','.',0}; |
| 478 | static const WCHAR format[] = |
| 479 | {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0}; |
| 480 | static const WCHAR Query_t[] = |
| 481 | {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','c','t','i','o', |
| 482 | 'n','T','e','x','t',' ','w','h','e','r','e',' ','A','c','t','i','o','n',' ','=', |
| 483 | ' ','\'','%','s','\'',0}; |
| 484 | WCHAR message[1024]; |
| 485 | WCHAR timet[0x100]; |
| 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 | WCHAR *ActionText=NULL; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 490 | |
| 491 | GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100); |
| 492 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 493 | rc = MSI_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; |
| 496 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 497 | if (rc != ERROR_SUCCESS) |
| 498 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 499 | MSI_ViewClose(view); |
| 500 | msiobj_release(&view->hdr); |
| 501 | return; |
| 502 | } |
| 503 | rc = MSI_ViewFetch(view,&row); |
| 504 | if (rc != ERROR_SUCCESS) |
| 505 | { |
| 506 | MSI_ViewClose(view); |
| 507 | msiobj_release(&view->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 508 | return; |
| 509 | } |
| 510 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 511 | ActionText = load_dynamic_stringW(row,2); |
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 | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 515 | |
| 516 | sprintfW(message,template_s,timet,action,ActionText); |
| 517 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 518 | row = MSI_CreateRecord(1); |
| 519 | MSI_RecordSetStringW(row,1,message); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 520 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 521 | MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row); |
| 522 | msiobj_release(&row->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 523 | HeapFree(GetProcessHeap(),0,ActionText); |
| 524 | } |
| 525 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 526 | static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start, |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 527 | UINT rc) |
| 528 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 529 | MSIRECORD * row; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 530 | static const WCHAR template_s[]= |
| 531 | {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ','%','s', |
| 532 | '.',0}; |
| 533 | static const WCHAR template_e[]= |
| 534 | {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ','%','s', |
| 535 | '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ','%','i','.',0}; |
| 536 | static const WCHAR format[] = |
| 537 | {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0}; |
| 538 | WCHAR message[1024]; |
| 539 | WCHAR timet[0x100]; |
| 540 | |
| 541 | GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100); |
| 542 | if (start) |
| 543 | sprintfW(message,template_s,timet,action); |
| 544 | else |
| 545 | sprintfW(message,template_e,timet,action,rc); |
| 546 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 547 | row = MSI_CreateRecord(1); |
| 548 | MSI_RecordSetStringW(row,1,message); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 549 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 550 | MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row); |
| 551 | msiobj_release(&row->hdr); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 552 | } |
| 553 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 554 | /* |
| 555 | * build_directory_name() |
| 556 | * |
| 557 | * This function is to save messing round with directory names |
| 558 | * It handles adding backslashes between path segments, |
| 559 | * and can add \ at the end of the directory name if told to. |
| 560 | * |
| 561 | * It takes a variable number of arguments. |
| 562 | * It always allocates a new string for the result, so make sure |
| 563 | * to free the return value when finished with it. |
| 564 | * |
| 565 | * The first arg is the number of path segments that follow. |
| 566 | * The arguments following count are a list of path segments. |
| 567 | * A path segment may be NULL. |
| 568 | * |
Francois Gouget | 87b0906 | 2005-01-10 13:29:24 +0000 | [diff] [blame] | 569 | * Path segments will be added with a \ separating them. |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 570 | * A \ will not be added after the last segment, however if the |
| 571 | * last segment is NULL, then the last character will be a \ |
| 572 | * |
| 573 | */ |
| 574 | static LPWSTR build_directory_name(DWORD count, ...) |
| 575 | { |
| 576 | DWORD sz = 1, i; |
| 577 | LPWSTR dir; |
| 578 | va_list va; |
| 579 | |
| 580 | va_start(va,count); |
| 581 | for(i=0; i<count; i++) |
| 582 | { |
| 583 | LPCWSTR str = va_arg(va,LPCWSTR); |
| 584 | if (str) |
| 585 | sz += strlenW(str) + 1; |
| 586 | } |
| 587 | va_end(va); |
| 588 | |
| 589 | dir = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR)); |
| 590 | dir[0]=0; |
| 591 | |
| 592 | va_start(va,count); |
| 593 | for(i=0; i<count; i++) |
| 594 | { |
| 595 | LPCWSTR str = va_arg(va,LPCWSTR); |
| 596 | if (!str) |
| 597 | continue; |
| 598 | strcatW(dir, str); |
| 599 | if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\') |
| 600 | strcatW(dir, cszbs); |
| 601 | } |
| 602 | return dir; |
| 603 | } |
| 604 | |
| 605 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 606 | /**************************************************** |
| 607 | * TOP level entry points |
| 608 | *****************************************************/ |
| 609 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 610 | UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath, |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 611 | LPCWSTR szCommandLine) |
| 612 | { |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 613 | DWORD sz; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 614 | WCHAR buffer[10]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 615 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 616 | static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0}; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 617 | static const WCHAR szAction[] = {'A','C','T','I','O','N',0}; |
| 618 | static const WCHAR szInstall[] = {'I','N','S','T','A','L','L',0}; |
| 619 | |
| 620 | MSI_SetPropertyW(package, szAction, szInstall); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 621 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 622 | if (szPackagePath) |
| 623 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 624 | LPWSTR p, check, path; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 625 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 626 | package->PackagePath = dupstrW(szPackagePath); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 627 | path = dupstrW(szPackagePath); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 628 | p = strrchrW(path,'\\'); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 629 | if (p) |
| 630 | { |
| 631 | p++; |
| 632 | *p=0; |
| 633 | } |
| 634 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 635 | check = load_dynamic_property(package, cszSourceDir,NULL); |
Aric Stewart | d0c971a | 2004-12-22 18:15:50 +0000 | [diff] [blame] | 636 | if (!check) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 637 | MSI_SetPropertyW(package, cszSourceDir, path); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 638 | else |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 639 | HeapFree(GetProcessHeap(), 0, check); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 640 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 641 | HeapFree(GetProcessHeap(), 0, path); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 642 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 643 | |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 644 | if (szCommandLine) |
| 645 | { |
| 646 | LPWSTR ptr,ptr2; |
| 647 | ptr = (LPWSTR)szCommandLine; |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 648 | |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 649 | while (*ptr) |
| 650 | { |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 651 | WCHAR *prop = NULL; |
| 652 | WCHAR *val = NULL; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 653 | |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 654 | TRACE("Looking at %s\n",debugstr_w(ptr)); |
| 655 | |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 656 | ptr2 = strchrW(ptr,'='); |
| 657 | if (ptr2) |
| 658 | { |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 659 | BOOL quote=FALSE; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 660 | DWORD len = 0; |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 661 | |
| 662 | while (*ptr == ' ') ptr++; |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 663 | len = ptr2-ptr; |
| 664 | prop = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR)); |
| 665 | strncpyW(prop,ptr,len); |
| 666 | prop[len]=0; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 667 | ptr2++; |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 668 | |
| 669 | len = 0; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 670 | ptr = ptr2; |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 671 | while (*ptr && (quote || (!quote && *ptr!=' '))) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 672 | { |
| 673 | if (*ptr == '"') |
| 674 | quote = !quote; |
| 675 | ptr++; |
| 676 | len++; |
| 677 | } |
| 678 | |
| 679 | if (*ptr2=='"') |
| 680 | { |
| 681 | ptr2++; |
| 682 | len -= 2; |
| 683 | } |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 684 | val = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR)); |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 685 | strncpyW(val,ptr2,len); |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 686 | val[len] = 0; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 687 | |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 688 | if (strlenW(prop) > 0) |
| 689 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 690 | TRACE("Found commandline property (%s) = (%s)\n", |
| 691 | debugstr_w(prop), debugstr_w(val)); |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 692 | MSI_SetPropertyW(package,prop,val); |
| 693 | } |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 694 | HeapFree(GetProcessHeap(),0,val); |
| 695 | HeapFree(GetProcessHeap(),0,prop); |
Hans Leidekker | ba848ac | 2004-07-12 20:43:09 +0000 | [diff] [blame] | 696 | } |
| 697 | ptr++; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 698 | } |
| 699 | } |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 700 | |
| 701 | sz = 10; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 702 | if (MSI_GetPropertyW(package,szUILevel,buffer,&sz) == ERROR_SUCCESS) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 703 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 704 | if (atoiW(buffer) >= INSTALLUILEVEL_REDUCED) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 705 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 706 | rc = ACTION_ProcessUISequence(package); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 707 | if (rc == ERROR_SUCCESS) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 708 | rc = ACTION_ProcessExecSequence(package,TRUE); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 709 | } |
| 710 | else |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 711 | rc = ACTION_ProcessExecSequence(package,FALSE); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 712 | } |
| 713 | else |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 714 | rc = ACTION_ProcessExecSequence(package,FALSE); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 715 | |
Aric Stewart | 09d35c3 | 2004-12-27 19:00:26 +0000 | [diff] [blame] | 716 | /* process the ending type action */ |
| 717 | if (rc == ERROR_SUCCESS) |
| 718 | rc = ACTION_PerformActionSequence(package,-1); |
| 719 | else if (rc == ERROR_FUNCTION_FAILED) |
| 720 | rc = ACTION_PerformActionSequence(package,-3); |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 721 | |
| 722 | /* finish up running custom actions */ |
| 723 | ACTION_FinishCustomActions(package); |
Aric Stewart | 09d35c3 | 2004-12-27 19:00:26 +0000 | [diff] [blame] | 724 | |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 725 | return rc; |
| 726 | } |
| 727 | |
Aric Stewart | 09d35c3 | 2004-12-27 19:00:26 +0000 | [diff] [blame] | 728 | static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq) |
| 729 | { |
| 730 | MSIQUERY * view; |
| 731 | UINT rc; |
| 732 | WCHAR buffer[0x100]; |
| 733 | DWORD sz = 0x100; |
| 734 | MSIRECORD * row = 0; |
| 735 | static const WCHAR ExecSeqQuery[] = { |
| 736 | 's','e','l','e','c','t',' ','*',' ', |
| 737 | 'f','r','o','m',' ', |
| 738 | 'I','n','s','t','a','l','l','E','x','e','c','u','t','e', |
| 739 | 'S','e','q','u','e','n','c','e',' ', |
| 740 | 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ', |
| 741 | '=',' ','%','i',0}; |
| 742 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 743 | rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq); |
Aric Stewart | 09d35c3 | 2004-12-27 19:00:26 +0000 | [diff] [blame] | 744 | |
| 745 | if (rc == ERROR_SUCCESS) |
| 746 | { |
| 747 | rc = MSI_ViewExecute(view, 0); |
| 748 | |
| 749 | if (rc != ERROR_SUCCESS) |
| 750 | { |
| 751 | MSI_ViewClose(view); |
| 752 | msiobj_release(&view->hdr); |
| 753 | goto end; |
| 754 | } |
| 755 | |
| 756 | TRACE("Running the actions\n"); |
| 757 | |
| 758 | rc = MSI_ViewFetch(view,&row); |
| 759 | if (rc != ERROR_SUCCESS) |
| 760 | { |
| 761 | rc = ERROR_SUCCESS; |
| 762 | goto end; |
| 763 | } |
| 764 | |
| 765 | /* check conditions */ |
| 766 | if (!MSI_RecordIsNull(row,2)) |
| 767 | { |
| 768 | LPWSTR cond = NULL; |
| 769 | cond = load_dynamic_stringW(row,2); |
| 770 | |
| 771 | if (cond) |
| 772 | { |
| 773 | /* this is a hack to skip errors in the condition code */ |
| 774 | if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE) |
| 775 | { |
| 776 | HeapFree(GetProcessHeap(),0,cond); |
| 777 | msiobj_release(&row->hdr); |
| 778 | goto end; |
| 779 | } |
| 780 | else |
| 781 | HeapFree(GetProcessHeap(),0,cond); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | sz=0x100; |
| 786 | rc = MSI_RecordGetStringW(row,1,buffer,&sz); |
| 787 | if (rc != ERROR_SUCCESS) |
| 788 | { |
| 789 | ERR("Error is %x\n",rc); |
| 790 | msiobj_release(&row->hdr); |
| 791 | goto end; |
| 792 | } |
| 793 | |
| 794 | rc = ACTION_PerformAction(package,buffer); |
| 795 | msiobj_release(&row->hdr); |
| 796 | end: |
| 797 | MSI_ViewClose(view); |
| 798 | msiobj_release(&view->hdr); |
| 799 | } |
| 800 | else |
| 801 | rc = ERROR_SUCCESS; |
| 802 | |
| 803 | return rc; |
| 804 | } |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 805 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 806 | static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 807 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 808 | MSIQUERY * view; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 809 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 810 | static const WCHAR ExecSeqQuery[] = { |
| 811 | 's','e','l','e','c','t',' ','*',' ', |
| 812 | 'f','r','o','m',' ', |
| 813 | 'I','n','s','t','a','l','l','E','x','e','c','u','t','e', |
| 814 | 'S','e','q','u','e','n','c','e',' ', |
| 815 | 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ', |
| 816 | '>',' ','%','i',' ','o','r','d','e','r',' ', |
| 817 | 'b','y',' ','S','e','q','u','e','n','c','e',0 }; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 818 | MSIRECORD * row = 0; |
| 819 | static const WCHAR IVQuery[] = { |
| 820 | 's','e','l','e','c','t',' ','S','e','q','u','e','n','c','e',' ', |
| 821 | 'f','r','o','m',' ','I','n','s','t','a','l','l', |
| 822 | 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e',' ', |
| 823 | 'w','h','e','r','e',' ','A','c','t','i','o','n',' ','=',' ', |
| 824 | '`','I','n','s','t','a','l','l','V','a','l','i','d','a','t','e','`', |
| 825 | 0}; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 826 | INT seq = 0; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 827 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 828 | /* get the sequence number */ |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 829 | if (UIran) |
| 830 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 831 | rc = MSI_DatabaseOpenViewW(package->db, IVQuery, &view); |
| 832 | if (rc != ERROR_SUCCESS) |
| 833 | return rc; |
| 834 | rc = MSI_ViewExecute(view, 0); |
| 835 | if (rc != ERROR_SUCCESS) |
| 836 | { |
| 837 | MSI_ViewClose(view); |
| 838 | msiobj_release(&view->hdr); |
| 839 | return rc; |
| 840 | } |
| 841 | rc = MSI_ViewFetch(view,&row); |
| 842 | if (rc != ERROR_SUCCESS) |
| 843 | { |
| 844 | MSI_ViewClose(view); |
| 845 | msiobj_release(&view->hdr); |
| 846 | return rc; |
| 847 | } |
| 848 | seq = MSI_RecordGetInteger(row,1); |
| 849 | msiobj_release(&row->hdr); |
| 850 | MSI_ViewClose(view); |
| 851 | msiobj_release(&view->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 852 | } |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 853 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 854 | rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 855 | if (rc == ERROR_SUCCESS) |
| 856 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 857 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 858 | |
| 859 | if (rc != ERROR_SUCCESS) |
| 860 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 861 | MSI_ViewClose(view); |
| 862 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 863 | goto end; |
| 864 | } |
| 865 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 866 | TRACE("Running the actions\n"); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 867 | |
| 868 | while (1) |
| 869 | { |
| 870 | WCHAR buffer[0x100]; |
| 871 | DWORD sz = 0x100; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 872 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 873 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 874 | if (rc != ERROR_SUCCESS) |
| 875 | { |
| 876 | rc = ERROR_SUCCESS; |
| 877 | break; |
| 878 | } |
| 879 | |
| 880 | /* check conditions */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 881 | if (!MSI_RecordIsNull(row,2)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 882 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 883 | LPWSTR cond = NULL; |
| 884 | cond = load_dynamic_stringW(row,2); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 885 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 886 | if (cond) |
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 | /* this is a hack to skip errors in the condition code */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 889 | if (MSI_EvaluateConditionW(package, cond) == |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 890 | MSICONDITION_FALSE) |
| 891 | { |
| 892 | HeapFree(GetProcessHeap(),0,cond); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 893 | msiobj_release(&row->hdr); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 894 | continue; |
| 895 | } |
| 896 | else |
| 897 | HeapFree(GetProcessHeap(),0,cond); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 898 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 902 | rc = MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 903 | if (rc != ERROR_SUCCESS) |
| 904 | { |
| 905 | ERR("Error is %x\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 906 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 907 | break; |
| 908 | } |
| 909 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 910 | rc = ACTION_PerformAction(package,buffer); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 911 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 912 | if (rc == ERROR_FUNCTION_NOT_CALLED) |
| 913 | rc = ERROR_SUCCESS; |
| 914 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 915 | if (rc != ERROR_SUCCESS) |
| 916 | { |
| 917 | ERR("Execution halted due to error (%i)\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 918 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 919 | break; |
| 920 | } |
| 921 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 922 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 923 | } |
| 924 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 925 | MSI_ViewClose(view); |
| 926 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 927 | } |
| 928 | |
| 929 | end: |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 930 | return rc; |
| 931 | } |
| 932 | |
| 933 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 934 | static UINT ACTION_ProcessUISequence(MSIPACKAGE *package) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 935 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 936 | MSIQUERY * view; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 937 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 938 | static const WCHAR ExecSeqQuery [] = { |
| 939 | 's','e','l','e','c','t',' ','*',' ', |
| 940 | 'f','r','o','m',' ','I','n','s','t','a','l','l', |
| 941 | 'U','I','S','e','q','u','e','n','c','e',' ', |
| 942 | 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ', '>',' ','0',' ', |
| 943 | '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] | 944 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 945 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 946 | |
| 947 | if (rc == ERROR_SUCCESS) |
| 948 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 949 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 950 | |
| 951 | if (rc != ERROR_SUCCESS) |
| 952 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 953 | MSI_ViewClose(view); |
| 954 | msiobj_release(&view->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 955 | goto end; |
| 956 | } |
| 957 | |
| 958 | TRACE("Running the actions \n"); |
| 959 | |
| 960 | while (1) |
| 961 | { |
| 962 | WCHAR buffer[0x100]; |
| 963 | DWORD sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 964 | MSIRECORD * row = 0; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 965 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 966 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 967 | if (rc != ERROR_SUCCESS) |
| 968 | { |
| 969 | rc = ERROR_SUCCESS; |
| 970 | break; |
| 971 | } |
| 972 | |
| 973 | /* check conditions */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 974 | if (!MSI_RecordIsNull(row,2)) |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 975 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 976 | LPWSTR cond = NULL; |
| 977 | cond = load_dynamic_stringW(row,2); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 978 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 979 | if (cond) |
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 | /* this is a hack to skip errors in the condition code */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 982 | if (MSI_EvaluateConditionW(package, cond) == |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 983 | MSICONDITION_FALSE) |
| 984 | { |
| 985 | HeapFree(GetProcessHeap(),0,cond); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 986 | msiobj_release(&row->hdr); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 987 | continue; |
| 988 | } |
| 989 | else |
| 990 | HeapFree(GetProcessHeap(),0,cond); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 991 | } |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 992 | } |
| 993 | |
| 994 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 995 | rc = MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 996 | if (rc != ERROR_SUCCESS) |
| 997 | { |
| 998 | ERR("Error is %x\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 999 | msiobj_release(&row->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1000 | break; |
| 1001 | } |
| 1002 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1003 | rc = ACTION_PerformAction(package,buffer); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1004 | |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1005 | if (rc == ERROR_FUNCTION_NOT_CALLED) |
| 1006 | rc = ERROR_SUCCESS; |
| 1007 | |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1008 | if (rc != ERROR_SUCCESS) |
| 1009 | { |
| 1010 | ERR("Execution halted due to error (%i)\n",rc); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1011 | msiobj_release(&row->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1012 | break; |
| 1013 | } |
| 1014 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1015 | msiobj_release(&row->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1016 | } |
| 1017 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1018 | MSI_ViewClose(view); |
| 1019 | msiobj_release(&view->hdr); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | end: |
| 1023 | return rc; |
| 1024 | } |
| 1025 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1026 | /******************************************************** |
| 1027 | * ACTION helper functions and functions that perform the actions |
| 1028 | *******************************************************/ |
| 1029 | |
| 1030 | /* |
| 1031 | * Alot of actions are really important even if they don't do anything |
| 1032 | * explicit.. Lots of properties are set at the beginning of the installation |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 1033 | * CostFinalize does a bunch of work to translated the directories and such |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1034 | * |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 1035 | * 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] | 1036 | * hack it to see if I can get something to run. |
| 1037 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1038 | UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1039 | { |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1040 | UINT rc = ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1041 | |
| 1042 | TRACE("Performing action (%s)\n",debugstr_w(action)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1043 | ui_actioninfo(package, action, TRUE, 0); |
| 1044 | ui_actionstart(package, action); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1045 | |
Mike McCormack | 24e9a34 | 2004-07-06 18:56:12 +0000 | [diff] [blame] | 1046 | /* pre install, setup and configuration block */ |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 1047 | if (strcmpW(action,szLaunchConditions)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1048 | rc = ACTION_LaunchConditions(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1049 | else if (strcmpW(action,szCostInitialize)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1050 | rc = ACTION_CostInitialize(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1051 | else if (strcmpW(action,szFileCost)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1052 | rc = ACTION_FileCost(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1053 | else if (strcmpW(action,szCostFinalize)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1054 | rc = ACTION_CostFinalize(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1055 | else if (strcmpW(action,szInstallValidate)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1056 | rc = ACTION_InstallValidate(package); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1057 | |
| 1058 | /* install block */ |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 1059 | else if (strcmpW(action,szProcessComponents)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1060 | rc = ACTION_ProcessComponents(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1061 | else if (strcmpW(action,szInstallInitialize)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1062 | rc = ACTION_InstallInitialize(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1063 | else if (strcmpW(action,szCreateFolders)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1064 | rc = ACTION_CreateFolders(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1065 | else if (strcmpW(action,szInstallFiles)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1066 | rc = ACTION_InstallFiles(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1067 | else if (strcmpW(action,szDuplicateFiles)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1068 | rc = ACTION_DuplicateFiles(package); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1069 | else if (strcmpW(action,szWriteRegistryValues)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1070 | rc = ACTION_WriteRegistryValues(package); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 1071 | else if (strcmpW(action,szRegisterTypeLibraries)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1072 | rc = ACTION_RegisterTypeLibraries(package); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 1073 | else if (strcmpW(action,szRegisterClassInfo)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1074 | rc = ACTION_RegisterClassInfo(package); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 1075 | else if (strcmpW(action,szRegisterProgIdInfo)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1076 | rc = ACTION_RegisterProgIdInfo(package); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 1077 | else if (strcmpW(action,szCreateShortcuts)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1078 | rc = ACTION_CreateShortcuts(package); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 1079 | else if (strcmpW(action,szPublishProduct)==0) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1080 | rc = ACTION_PublishProduct(package); |
Aric Stewart | 516a9c7 | 2005-01-14 15:59:26 +0000 | [diff] [blame] | 1081 | else if (strcmpW(action,szWriteIniValues)==0) |
| 1082 | rc = ACTION_WriteIniValues(package); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 1083 | else if (strcmpW(action,szSelfRegModules)==0) |
| 1084 | rc = ACTION_SelfRegModules(package); |
| 1085 | else if (strcmpW(action,szPublishFeatures)==0) |
| 1086 | rc = ACTION_PublishFeatures(package); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 1087 | else if (strcmpW(action,szRegisterProduct)==0) |
| 1088 | rc = ACTION_RegisterProduct(package); |
| 1089 | else if (strcmpW(action,szInstallExecute)==0) |
| 1090 | rc = ACTION_InstallExecute(package); |
| 1091 | else if (strcmpW(action,szInstallExecuteAgain)==0) |
| 1092 | rc = ACTION_InstallExecute(package); |
| 1093 | else if (strcmpW(action,szInstallFinalize)==0) |
| 1094 | rc = ACTION_InstallFinalize(package); |
| 1095 | else if (strcmpW(action,szForceReboot)==0) |
| 1096 | rc = ACTION_ForceReboot(package); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1097 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1098 | /* |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 1099 | Called during iTunes but unimplemented and seem important |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1100 | |
Aric Stewart | c75201f | 2004-06-29 04:04:13 +0000 | [diff] [blame] | 1101 | ResolveSource (sets SourceDir) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1102 | */ |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 1103 | else if ((rc = ACTION_CustomAction(package,action,FALSE)) != ERROR_SUCCESS) |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1104 | { |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1105 | FIXME("UNHANDLED MSI ACTION %s\n",debugstr_w(action)); |
Aric Stewart | 1282d7a | 2004-11-03 22:16:53 +0000 | [diff] [blame] | 1106 | rc = ERROR_FUNCTION_NOT_CALLED; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1107 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1108 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1109 | ui_actioninfo(package, action, FALSE, rc); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1110 | return rc; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1111 | } |
| 1112 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1113 | /*********************************************************************** |
| 1114 | * create_full_pathW |
| 1115 | * |
| 1116 | * Recursively create all directories in the path. |
| 1117 | * |
| 1118 | * shamelessly stolen from setupapi/queue.c |
| 1119 | */ |
| 1120 | static BOOL create_full_pathW(const WCHAR *path) |
| 1121 | { |
| 1122 | BOOL ret = TRUE; |
| 1123 | int len; |
| 1124 | WCHAR *new_path; |
| 1125 | |
| 1126 | new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) * |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1127 | sizeof(WCHAR)); |
| 1128 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1129 | strcpyW(new_path, path); |
| 1130 | |
| 1131 | while((len = strlenW(new_path)) && new_path[len - 1] == '\\') |
| 1132 | new_path[len - 1] = 0; |
| 1133 | |
| 1134 | while(!CreateDirectoryW(new_path, NULL)) |
| 1135 | { |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 1136 | WCHAR *slash; |
| 1137 | DWORD last_error = GetLastError(); |
| 1138 | if(last_error == ERROR_ALREADY_EXISTS) |
| 1139 | break; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1140 | |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 1141 | if(last_error != ERROR_PATH_NOT_FOUND) |
| 1142 | { |
| 1143 | ret = FALSE; |
| 1144 | break; |
| 1145 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1146 | |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 1147 | if(!(slash = strrchrW(new_path, '\\'))) |
| 1148 | { |
| 1149 | ret = FALSE; |
| 1150 | break; |
| 1151 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1152 | |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 1153 | len = slash - new_path; |
| 1154 | new_path[len] = 0; |
| 1155 | if(!create_full_pathW(new_path)) |
| 1156 | { |
| 1157 | ret = FALSE; |
| 1158 | break; |
| 1159 | } |
| 1160 | new_path[len] = '\\'; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | HeapFree(GetProcessHeap(), 0, new_path); |
| 1164 | return ret; |
| 1165 | } |
| 1166 | |
| 1167 | /* |
| 1168 | * 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] | 1169 | * to do all the directories for all the components. |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1170 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1171 | static UINT ACTION_CreateFolders(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1172 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1173 | static const WCHAR ExecSeqQuery[] = { |
| 1174 | 's','e','l','e','c','t',' ','D','i','r','e','c','t','o','r','y','_',' ', |
| 1175 | '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] | 1176 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1177 | MSIQUERY *view; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1178 | MSIFOLDER *folder; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1179 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1180 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view ); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1181 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1182 | return ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1183 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1184 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1185 | if (rc != ERROR_SUCCESS) |
| 1186 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1187 | MSI_ViewClose(view); |
| 1188 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1189 | return rc; |
| 1190 | } |
| 1191 | |
| 1192 | while (1) |
| 1193 | { |
| 1194 | WCHAR dir[0x100]; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1195 | LPWSTR full_path; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1196 | DWORD sz; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1197 | MSIRECORD *row = NULL, *uirow; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1198 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1199 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1200 | if (rc != ERROR_SUCCESS) |
| 1201 | { |
| 1202 | rc = ERROR_SUCCESS; |
| 1203 | break; |
| 1204 | } |
| 1205 | |
| 1206 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1207 | rc = MSI_RecordGetStringW(row,1,dir,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1208 | |
| 1209 | if (rc!= ERROR_SUCCESS) |
| 1210 | { |
| 1211 | ERR("Unable to get folder id \n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1212 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1213 | continue; |
| 1214 | } |
| 1215 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 1216 | sz = MAX_PATH; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1217 | full_path = resolve_folder(package,dir,FALSE,FALSE,&folder); |
| 1218 | if (!full_path) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1219 | { |
| 1220 | ERR("Unable to resolve folder id %s\n",debugstr_w(dir)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1221 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1222 | continue; |
| 1223 | } |
| 1224 | |
| 1225 | TRACE("Folder is %s\n",debugstr_w(full_path)); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1226 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1227 | /* UI stuff */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1228 | uirow = MSI_CreateRecord(1); |
| 1229 | MSI_RecordSetStringW(uirow,1,full_path); |
| 1230 | ui_actiondata(package,szCreateFolders,uirow); |
| 1231 | msiobj_release( &uirow->hdr ); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 1232 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1233 | if (folder->State == 0) |
| 1234 | create_full_pathW(full_path); |
| 1235 | |
| 1236 | folder->State = 3; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1237 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1238 | msiobj_release(&row->hdr); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1239 | HeapFree(GetProcessHeap(),0,full_path); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1240 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1241 | MSI_ViewClose(view); |
| 1242 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1243 | |
| 1244 | return rc; |
| 1245 | } |
| 1246 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1247 | static int load_component(MSIPACKAGE* package, MSIRECORD * row) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1248 | { |
| 1249 | int index = package->loaded_components; |
| 1250 | DWORD sz; |
| 1251 | |
| 1252 | /* fill in the data */ |
| 1253 | |
| 1254 | package->loaded_components++; |
| 1255 | if (package->loaded_components == 1) |
| 1256 | package->components = HeapAlloc(GetProcessHeap(),0, |
| 1257 | sizeof(MSICOMPONENT)); |
| 1258 | else |
| 1259 | package->components = HeapReAlloc(GetProcessHeap(),0, |
| 1260 | package->components, package->loaded_components * |
| 1261 | sizeof(MSICOMPONENT)); |
| 1262 | |
| 1263 | memset(&package->components[index],0,sizeof(MSICOMPONENT)); |
| 1264 | |
| 1265 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1266 | MSI_RecordGetStringW(row,1,package->components[index].Component,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1267 | |
| 1268 | TRACE("Loading Component %s\n", |
| 1269 | debugstr_w(package->components[index].Component)); |
| 1270 | |
| 1271 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1272 | if (!MSI_RecordIsNull(row,2)) |
| 1273 | MSI_RecordGetStringW(row,2,package->components[index].ComponentId,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1274 | |
| 1275 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1276 | MSI_RecordGetStringW(row,3,package->components[index].Directory,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1277 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1278 | package->components[index].Attributes = MSI_RecordGetInteger(row,4); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1279 | |
| 1280 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1281 | MSI_RecordGetStringW(row,5,package->components[index].Condition,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1282 | |
| 1283 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1284 | MSI_RecordGetStringW(row,6,package->components[index].KeyPath,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1285 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1286 | package->components[index].Installed = INSTALLSTATE_ABSENT; |
| 1287 | package->components[index].Action = INSTALLSTATE_UNKNOWN; |
| 1288 | package->components[index].ActionRequest = INSTALLSTATE_UNKNOWN; |
| 1289 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1290 | package->components[index].Enabled = TRUE; |
| 1291 | |
| 1292 | return index; |
| 1293 | } |
| 1294 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1295 | static void load_feature(MSIPACKAGE* package, MSIRECORD * row) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1296 | { |
| 1297 | int index = package->loaded_features; |
| 1298 | DWORD sz; |
| 1299 | 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] | 1300 | 'o','n','e','n','t','_',' ','F','R','O','M',' ','F','e','a','t','u','r','e', |
| 1301 | 'C','o','m','p','o','n','e','n','t','s',' ','W','H','E','R','E',' ','F','e', |
| 1302 | 'a','t','u','r','e','_','=','\'','%','s','\'',0}; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1303 | static const WCHAR Query2[] = {'S','E','L','E','C','T',' ','*',' ','F','R', |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1304 | 'O','M',' ','C','o','m','p','o','n','e','n','t',' ','W','H','E','R','E',' ','C', |
| 1305 | 'o','m','p','o','n','e','n','t','=','\'','%','s','\'',0}; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1306 | MSIQUERY * view; |
| 1307 | MSIQUERY * view2; |
| 1308 | MSIRECORD * row2; |
| 1309 | MSIRECORD * row3; |
| 1310 | UINT rc; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1311 | |
| 1312 | /* fill in the data */ |
| 1313 | |
| 1314 | package->loaded_features ++; |
| 1315 | if (package->loaded_features == 1) |
| 1316 | package->features = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFEATURE)); |
| 1317 | else |
| 1318 | package->features = HeapReAlloc(GetProcessHeap(),0,package->features, |
| 1319 | package->loaded_features * sizeof(MSIFEATURE)); |
| 1320 | |
| 1321 | memset(&package->features[index],0,sizeof(MSIFEATURE)); |
| 1322 | |
| 1323 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1324 | MSI_RecordGetStringW(row,1,package->features[index].Feature,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1325 | |
| 1326 | TRACE("Loading feature %s\n",debugstr_w(package->features[index].Feature)); |
| 1327 | |
| 1328 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1329 | if (!MSI_RecordIsNull(row,2)) |
| 1330 | MSI_RecordGetStringW(row,2,package->features[index].Feature_Parent,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1331 | |
| 1332 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1333 | if (!MSI_RecordIsNull(row,3)) |
| 1334 | MSI_RecordGetStringW(row,3,package->features[index].Title,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1335 | |
| 1336 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1337 | if (!MSI_RecordIsNull(row,4)) |
| 1338 | MSI_RecordGetStringW(row,4,package->features[index].Description,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1339 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1340 | if (!MSI_RecordIsNull(row,5)) |
| 1341 | package->features[index].Display = MSI_RecordGetInteger(row,5); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1342 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1343 | package->features[index].Level= MSI_RecordGetInteger(row,6); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1344 | |
| 1345 | sz = 96; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1346 | if (!MSI_RecordIsNull(row,7)) |
| 1347 | MSI_RecordGetStringW(row,7,package->features[index].Directory,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1348 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1349 | package->features[index].Attributes= MSI_RecordGetInteger(row,8); |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1350 | |
| 1351 | package->features[index].Installed = INSTALLSTATE_ABSENT; |
| 1352 | package->features[index].Action = INSTALLSTATE_UNKNOWN; |
| 1353 | package->features[index].ActionRequest = INSTALLSTATE_UNKNOWN; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1354 | |
| 1355 | /* load feature components */ |
| 1356 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 1357 | rc = MSI_OpenQuery(package->db, &view, Query1, package->features[index].Feature); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1358 | if (rc != ERROR_SUCCESS) |
| 1359 | return; |
| 1360 | rc = MSI_ViewExecute(view,0); |
| 1361 | if (rc != ERROR_SUCCESS) |
| 1362 | { |
| 1363 | MSI_ViewClose(view); |
| 1364 | msiobj_release(&view->hdr); |
| 1365 | return; |
| 1366 | } |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1367 | while (1) |
| 1368 | { |
| 1369 | DWORD sz = 0x100; |
| 1370 | WCHAR buffer[0x100]; |
| 1371 | DWORD rc; |
| 1372 | INT c_indx; |
| 1373 | INT cnt = package->features[index].ComponentCount; |
| 1374 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1375 | rc = MSI_ViewFetch(view,&row2); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1376 | if (rc != ERROR_SUCCESS) |
| 1377 | break; |
| 1378 | |
| 1379 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1380 | MSI_RecordGetStringW(row2,1,buffer,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1381 | |
| 1382 | /* check to see if the component is already loaded */ |
| 1383 | c_indx = get_loaded_component(package,buffer); |
| 1384 | if (c_indx != -1) |
| 1385 | { |
| 1386 | TRACE("Component %s already loaded at %i\n", debugstr_w(buffer), |
| 1387 | c_indx); |
| 1388 | package->features[index].Components[cnt] = c_indx; |
| 1389 | package->features[index].ComponentCount ++; |
Aric Stewart | ea32fb9 | 2004-12-27 19:09:16 +0000 | [diff] [blame] | 1390 | continue; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1391 | } |
| 1392 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 1393 | rc = MSI_OpenQuery(package->db, &view2, Query2, buffer); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1394 | if (rc != ERROR_SUCCESS) |
| 1395 | { |
| 1396 | msiobj_release( &row2->hdr ); |
| 1397 | continue; |
| 1398 | } |
| 1399 | rc = MSI_ViewExecute(view2,0); |
| 1400 | if (rc != ERROR_SUCCESS) |
| 1401 | { |
| 1402 | msiobj_release( &row2->hdr ); |
| 1403 | MSI_ViewClose(view2); |
| 1404 | msiobj_release( &view2->hdr ); |
| 1405 | continue; |
| 1406 | } |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1407 | while (1) |
| 1408 | { |
| 1409 | DWORD rc; |
| 1410 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1411 | rc = MSI_ViewFetch(view2,&row3); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1412 | if (rc != ERROR_SUCCESS) |
| 1413 | break; |
| 1414 | c_indx = load_component(package,row3); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1415 | msiobj_release( &row3->hdr ); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1416 | |
| 1417 | package->features[index].Components[cnt] = c_indx; |
| 1418 | package->features[index].ComponentCount ++; |
Aric Stewart | ea32fb9 | 2004-12-27 19:09:16 +0000 | [diff] [blame] | 1419 | TRACE("Loaded new component to index %i\n",c_indx); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1420 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1421 | MSI_ViewClose(view2); |
| 1422 | msiobj_release( &view2->hdr ); |
| 1423 | msiobj_release( &row2->hdr ); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1424 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1425 | MSI_ViewClose(view); |
| 1426 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1427 | } |
| 1428 | |
| 1429 | /* |
| 1430 | * I am not doing any of the costing functionality yet. |
| 1431 | * Mostly looking at doing the Component and Feature loading |
| 1432 | * |
| 1433 | * The native MSI does ALOT of modification to tables here. Mostly adding alot |
| 1434 | * of temporary columns to the Feature and Component tables. |
| 1435 | * |
Mike McCormack | 24e9a34 | 2004-07-06 18:56:12 +0000 | [diff] [blame] | 1436 | * 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] | 1437 | * track the long ones. Also looking at this directory table |
| 1438 | * it appears that the directory table does not get the parents |
| 1439 | * resolved base on property only based on their entrys in the |
| 1440 | * directory table. |
| 1441 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1442 | static UINT ACTION_CostInitialize(MSIPACKAGE *package) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1443 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1444 | MSIQUERY * view; |
| 1445 | MSIRECORD * row; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1446 | UINT rc; |
| 1447 | static const WCHAR Query_all[] = { |
| 1448 | 'S','E','L','E','C','T',' ','*',' ', |
| 1449 | 'F','R','O','M',' ','F','e','a','t','u','r','e',0}; |
| 1450 | static const WCHAR szCosting[] = { |
| 1451 | 'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 }; |
| 1452 | static const WCHAR szZero[] = { '0', 0 }; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1453 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1454 | MSI_SetPropertyW(package, szCosting, szZero); |
| 1455 | MSI_SetPropertyW(package, cszRootDrive , c_collen); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1456 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1457 | rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view); |
| 1458 | if (rc != ERROR_SUCCESS) |
| 1459 | return rc; |
| 1460 | rc = MSI_ViewExecute(view,0); |
| 1461 | if (rc != ERROR_SUCCESS) |
| 1462 | { |
| 1463 | MSI_ViewClose(view); |
| 1464 | msiobj_release(&view->hdr); |
| 1465 | return rc; |
| 1466 | } |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1467 | while (1) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1468 | { |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1469 | DWORD rc; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1470 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1471 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1472 | if (rc != ERROR_SUCCESS) |
| 1473 | break; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1474 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1475 | load_feature(package,row); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1476 | msiobj_release(&row->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1477 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1478 | MSI_ViewClose(view); |
| 1479 | msiobj_release(&view->hdr); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1480 | |
| 1481 | return ERROR_SUCCESS; |
| 1482 | } |
| 1483 | |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1484 | static UINT load_file(MSIPACKAGE* package, MSIRECORD * row) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1485 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1486 | DWORD index = package->loaded_files; |
| 1487 | DWORD i; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1488 | LPWSTR buffer; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1489 | |
| 1490 | /* fill in the data */ |
| 1491 | |
| 1492 | package->loaded_files++; |
| 1493 | if (package->loaded_files== 1) |
| 1494 | package->files = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE)); |
| 1495 | else |
| 1496 | package->files = HeapReAlloc(GetProcessHeap(),0, |
| 1497 | package->files , package->loaded_files * sizeof(MSIFILE)); |
| 1498 | |
| 1499 | memset(&package->files[index],0,sizeof(MSIFILE)); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1500 | |
| 1501 | package->files[index].File = load_dynamic_stringW(row, 1); |
| 1502 | buffer = load_dynamic_stringW(row, 2); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1503 | |
| 1504 | package->files[index].ComponentIndex = -1; |
| 1505 | for (i = 0; i < package->loaded_components; i++) |
| 1506 | if (strcmpW(package->components[i].Component,buffer)==0) |
| 1507 | { |
| 1508 | package->files[index].ComponentIndex = i; |
| 1509 | break; |
| 1510 | } |
| 1511 | if (package->files[index].ComponentIndex == -1) |
| 1512 | ERR("Unfound Component %s\n",debugstr_w(buffer)); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1513 | HeapFree(GetProcessHeap(), 0, buffer); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1514 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1515 | package->files[index].FileName = load_dynamic_stringW(row,3); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1516 | |
| 1517 | reduce_to_longfilename(package->files[index].FileName); |
| 1518 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1519 | package->files[index].FileSize = MSI_RecordGetInteger(row,4); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 1520 | package->files[index].Version = load_dynamic_stringW(row, 5); |
| 1521 | package->files[index].Language = load_dynamic_stringW(row, 6); |
| 1522 | package->files[index].Attributes= MSI_RecordGetInteger(row,7); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1523 | package->files[index].Sequence= MSI_RecordGetInteger(row,8); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1524 | |
| 1525 | package->files[index].Temporary = FALSE; |
| 1526 | package->files[index].State = 0; |
| 1527 | |
| 1528 | TRACE("File Loaded (%s)\n",debugstr_w(package->files[index].File)); |
| 1529 | |
| 1530 | return ERROR_SUCCESS; |
| 1531 | } |
| 1532 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1533 | static UINT ACTION_FileCost(MSIPACKAGE *package) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1534 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1535 | MSIQUERY * view; |
| 1536 | MSIRECORD * row; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1537 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1538 | static const WCHAR Query[] = { |
| 1539 | 'S','E','L','E','C','T',' ','*',' ', |
| 1540 | 'F','R','O','M',' ','F','i','l','e',' ', |
| 1541 | '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] | 1542 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1543 | if (!package) |
| 1544 | return ERROR_INVALID_HANDLE; |
| 1545 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1546 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1547 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1548 | return ERROR_SUCCESS; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1549 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1550 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1551 | if (rc != ERROR_SUCCESS) |
| 1552 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1553 | MSI_ViewClose(view); |
| 1554 | msiobj_release(&view->hdr); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1555 | return ERROR_SUCCESS; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1556 | } |
| 1557 | |
| 1558 | while (1) |
| 1559 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1560 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1561 | if (rc != ERROR_SUCCESS) |
| 1562 | { |
| 1563 | rc = ERROR_SUCCESS; |
| 1564 | break; |
| 1565 | } |
| 1566 | load_file(package,row); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1567 | msiobj_release(&row->hdr); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 1568 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1569 | MSI_ViewClose(view); |
| 1570 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1571 | |
| 1572 | return ERROR_SUCCESS; |
| 1573 | } |
| 1574 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1575 | static INT load_folder(MSIPACKAGE *package, const WCHAR* dir) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1576 | |
| 1577 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1578 | static const WCHAR Query[] = |
| 1579 | {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','D','i','r','e','c', |
| 1580 | 't','o','r','y',' ','w','h','e','r','e',' ','`','D','i','r','e','c','t', |
| 1581 | 'o','r','y','`',' ','=',' ','`','%','s','`',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1582 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1583 | MSIQUERY * view; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1584 | LPWSTR targetdir, parent, srcdir; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1585 | MSIRECORD * row = 0; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1586 | INT index = -1; |
| 1587 | DWORD i; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 1588 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1589 | TRACE("Looking for dir %s\n",debugstr_w(dir)); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1590 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1591 | for (i = 0; i < package->loaded_folders; i++) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1592 | { |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1593 | if (strcmpW(package->folders[i].Directory,dir)==0) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1594 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1595 | TRACE(" %s retuning on index %lu\n",debugstr_w(dir),i); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1596 | return i; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1597 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1598 | } |
| 1599 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1600 | TRACE("Working to load %s\n",debugstr_w(dir)); |
| 1601 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1602 | index = package->loaded_folders++; |
| 1603 | if (package->loaded_folders==1) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1604 | package->folders = HeapAlloc(GetProcessHeap(),0, |
| 1605 | sizeof(MSIFOLDER)); |
| 1606 | else |
| 1607 | package->folders= HeapReAlloc(GetProcessHeap(),0, |
| 1608 | package->folders, package->loaded_folders* |
| 1609 | sizeof(MSIFOLDER)); |
| 1610 | |
| 1611 | memset(&package->folders[index],0,sizeof(MSIFOLDER)); |
| 1612 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1613 | package->folders[index].Directory = dupstrW(dir); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1614 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 1615 | rc = MSI_OpenQuery(package->db, &view, Query, dir); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1616 | if (rc != ERROR_SUCCESS) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1617 | return -1; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1618 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1619 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1620 | if (rc != ERROR_SUCCESS) |
| 1621 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1622 | MSI_ViewClose(view); |
| 1623 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1624 | return -1; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1625 | } |
| 1626 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1627 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1628 | if (rc != ERROR_SUCCESS) |
| 1629 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1630 | MSI_ViewClose(view); |
| 1631 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1632 | return -1; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1633 | } |
| 1634 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1635 | targetdir = load_dynamic_stringW(row,3); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1636 | |
| 1637 | /* split src and target dir */ |
| 1638 | if (strchrW(targetdir,':')) |
| 1639 | { |
| 1640 | srcdir=strchrW(targetdir,':'); |
| 1641 | *srcdir=0; |
| 1642 | srcdir ++; |
| 1643 | } |
| 1644 | else |
| 1645 | srcdir=NULL; |
| 1646 | |
| 1647 | /* for now only pick long filename versions */ |
| 1648 | if (strchrW(targetdir,'|')) |
| 1649 | { |
| 1650 | targetdir = strchrW(targetdir,'|'); |
| 1651 | *targetdir = 0; |
| 1652 | targetdir ++; |
| 1653 | } |
| 1654 | if (srcdir && strchrW(srcdir,'|')) |
| 1655 | { |
| 1656 | srcdir= strchrW(srcdir,'|'); |
| 1657 | *srcdir= 0; |
| 1658 | srcdir ++; |
| 1659 | } |
| 1660 | |
| 1661 | /* now check for root dirs */ |
| 1662 | if (targetdir[0] == '.' && targetdir[1] == 0) |
| 1663 | targetdir = NULL; |
| 1664 | |
| 1665 | if (srcdir && srcdir[0] == '.' && srcdir[1] == 0) |
| 1666 | srcdir = NULL; |
| 1667 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1668 | if (targetdir) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1669 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1670 | TRACE(" TargetDefault = %s\n",debugstr_w(targetdir)); |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 1671 | HeapFree(GetProcessHeap(),0, package->folders[index].TargetDefault); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1672 | package->folders[index].TargetDefault = dupstrW(targetdir); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1673 | } |
| 1674 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1675 | if (srcdir) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1676 | package->folders[index].SourceDefault = dupstrW(srcdir); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1677 | else if (targetdir) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1678 | package->folders[index].SourceDefault = dupstrW(targetdir); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1679 | HeapFree(GetProcessHeap(), 0, targetdir); |
| 1680 | |
| 1681 | parent = load_dynamic_stringW(row,2); |
| 1682 | if (parent) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1683 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1684 | i = load_folder(package,parent); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1685 | package->folders[index].ParentIndex = i; |
| 1686 | TRACE("Parent is index %i... %s %s\n", |
| 1687 | package->folders[index].ParentIndex, |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1688 | debugstr_w(package->folders[package->folders[index].ParentIndex].Directory), |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1689 | debugstr_w(parent)); |
| 1690 | } |
| 1691 | else |
| 1692 | package->folders[index].ParentIndex = -2; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1693 | HeapFree(GetProcessHeap(), 0, parent); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1694 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1695 | package->folders[index].Property = load_dynamic_property(package, dir,NULL); |
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); |
| 1698 | MSI_ViewClose(view); |
| 1699 | msiobj_release(&view->hdr); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1700 | TRACE(" %s retuning on index %i\n",debugstr_w(dir),index); |
| 1701 | return index; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1702 | } |
| 1703 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1704 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 1705 | LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, |
| 1706 | BOOL set_prop, MSIFOLDER **folder) |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 1707 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1708 | DWORD i; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1709 | LPWSTR p, path = NULL; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1710 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1711 | TRACE("Working to resolve %s\n",debugstr_w(name)); |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1712 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1713 | /* special resolving for Target and Source root dir */ |
| 1714 | if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1715 | { |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1716 | if (!source) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1717 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1718 | path = load_dynamic_property(package,cszTargetDir,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1719 | if (!path) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1720 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1721 | path = load_dynamic_property(package,cszRootDrive,NULL); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1722 | if (set_prop) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1723 | MSI_SetPropertyW(package,cszTargetDir,path); |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1724 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1725 | if (folder) |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 1726 | { |
| 1727 | for (i = 0; i < package->loaded_folders; i++) |
| 1728 | { |
| 1729 | if (strcmpW(package->folders[i].Directory,name)==0) |
| 1730 | break; |
| 1731 | } |
| 1732 | *folder = &(package->folders[i]); |
| 1733 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1734 | return path; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1735 | } |
| 1736 | else |
| 1737 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1738 | path = load_dynamic_property(package,cszSourceDir,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1739 | if (!path) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1740 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1741 | path = load_dynamic_property(package,cszDatabase,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1742 | if (path) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1743 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1744 | p = strrchrW(path,'\\'); |
| 1745 | if (p) |
Aric Stewart | 454422d | 2004-12-23 11:20:50 +0000 | [diff] [blame] | 1746 | *(p+1) = 0; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1747 | } |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1748 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1749 | if (folder) |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 1750 | { |
| 1751 | for (i = 0; i < package->loaded_folders; i++) |
| 1752 | { |
| 1753 | if (strcmpW(package->folders[i].Directory,name)==0) |
| 1754 | break; |
| 1755 | } |
| 1756 | *folder = &(package->folders[i]); |
| 1757 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1758 | return path; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 1759 | } |
| 1760 | } |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1761 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1762 | for (i = 0; i < package->loaded_folders; i++) |
| 1763 | { |
| 1764 | if (strcmpW(package->folders[i].Directory,name)==0) |
| 1765 | break; |
| 1766 | } |
| 1767 | |
| 1768 | if (i >= package->loaded_folders) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1769 | return NULL; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 1770 | |
| 1771 | if (folder) |
| 1772 | *folder = &(package->folders[i]); |
| 1773 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1774 | if (!source && package->folders[i].ResolvedTarget) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1775 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1776 | path = dupstrW(package->folders[i].ResolvedTarget); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1777 | TRACE(" already resolved to %s\n",debugstr_w(path)); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1778 | return path; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1779 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1780 | else if (source && package->folders[i].ResolvedSource) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1781 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1782 | path = dupstrW(package->folders[i].ResolvedSource); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1783 | return path; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1784 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1785 | else if (!source && package->folders[i].Property) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1786 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1787 | path = dupstrW(package->folders[i].Property); |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 1788 | TRACE(" internally set to %s\n",debugstr_w(path)); |
| 1789 | if (set_prop) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1790 | MSI_SetPropertyW(package,name,path); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1791 | return path; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1792 | } |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 1793 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1794 | if (package->folders[i].ParentIndex >= 0) |
| 1795 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1796 | LPWSTR parent = package->folders[package->folders[i].ParentIndex].Directory; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1797 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1798 | TRACE(" ! Parent is %s\n", debugstr_w(parent)); |
Robert Shearman | dce07c4 | 2004-09-17 18:11:14 +0000 | [diff] [blame] | 1799 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1800 | p = resolve_folder(package, parent, source, set_prop, NULL); |
Aric Stewart | 1ab0e41 | 2004-07-06 18:42:56 +0000 | [diff] [blame] | 1801 | if (!source) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1802 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1803 | TRACE(" TargetDefault = %s\n",debugstr_w(package->folders[i].TargetDefault)); |
| 1804 | path = build_directory_name(3, p, package->folders[i].TargetDefault, NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1805 | package->folders[i].ResolvedTarget = dupstrW(path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1806 | TRACE(" resolved into %s\n",debugstr_w(path)); |
| 1807 | if (set_prop) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1808 | MSI_SetPropertyW(package,name,path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1809 | } |
Aric Stewart | 1ab0e41 | 2004-07-06 18:42:56 +0000 | [diff] [blame] | 1810 | else |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1811 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1812 | path = build_directory_name(3, p, package->folders[i].SourceDefault, NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 1813 | package->folders[i].ResolvedSource = dupstrW(path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1814 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1815 | HeapFree(GetProcessHeap(),0,p); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 1816 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1817 | return path; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 1818 | } |
| 1819 | |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1820 | static UINT SetFeatureStates(MSIPACKAGE *package) |
| 1821 | { |
| 1822 | LPWSTR level; |
| 1823 | INT install_level; |
| 1824 | DWORD i; |
| 1825 | INT j; |
| 1826 | LPWSTR override = NULL; |
| 1827 | static const WCHAR all[]={'A','L','L',0}; |
| 1828 | static const WCHAR szlevel[] = { |
| 1829 | 'I','N','S','T','A','L','L','L','E','V','E','L',0}; |
| 1830 | static const WCHAR szAddLocal[] = { |
| 1831 | 'A','D','D','L','O','C','A','L',0}; |
| 1832 | |
| 1833 | /* I do not know if this is where it should happen.. but */ |
| 1834 | |
| 1835 | TRACE("Checking Install Level\n"); |
| 1836 | |
| 1837 | level = load_dynamic_property(package,szlevel,NULL); |
| 1838 | if (level) |
| 1839 | { |
| 1840 | install_level = atoiW(level); |
| 1841 | HeapFree(GetProcessHeap(), 0, level); |
| 1842 | } |
| 1843 | else |
| 1844 | install_level = 1; |
| 1845 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1846 | /* ok hereis the rub |
| 1847 | * ADDLOCAL and its friend OVERRIDE INSTALLLEVLE |
| 1848 | * I have confirmed this if ADDLOCALis stated then the INSTALLLEVEL is |
| 1849 | * itnored for all the features. seems strange, epsecially since it is not |
| 1850 | * documented anywhere, but it is how it works. |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1851 | */ |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1852 | |
| 1853 | override = load_dynamic_property(package,szAddLocal,NULL); |
| 1854 | |
| 1855 | if (override) |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1856 | { |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1857 | for(i = 0; i < package->loaded_features; i++) |
| 1858 | { |
Aric Stewart | d900b53 | 2004-12-27 19:12:35 +0000 | [diff] [blame] | 1859 | if (strcmpiW(override,all)==0) |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1860 | { |
| 1861 | package->features[i].ActionRequest= INSTALLSTATE_LOCAL; |
| 1862 | package->features[i].Action = INSTALLSTATE_LOCAL; |
| 1863 | } |
Aric Stewart | d900b53 | 2004-12-27 19:12:35 +0000 | [diff] [blame] | 1864 | else |
| 1865 | { |
| 1866 | LPWSTR ptr = override; |
| 1867 | LPWSTR ptr2 = strchrW(override,','); |
| 1868 | |
| 1869 | while (ptr) |
| 1870 | { |
| 1871 | if ((ptr2 && |
| 1872 | strncmpW(ptr,package->features[i].Feature, ptr2-ptr)==0) |
| 1873 | || (!ptr2 && |
| 1874 | strcmpW(ptr,package->features[i].Feature)==0)) |
| 1875 | { |
| 1876 | package->features[i].ActionRequest= INSTALLSTATE_LOCAL; |
| 1877 | package->features[i].Action = INSTALLSTATE_LOCAL; |
| 1878 | break; |
| 1879 | } |
| 1880 | if (ptr2) |
| 1881 | { |
| 1882 | ptr=ptr2+1; |
| 1883 | ptr2 = strchrW(ptr,','); |
| 1884 | } |
| 1885 | else |
| 1886 | break; |
| 1887 | } |
| 1888 | } |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1889 | } |
| 1890 | HeapFree(GetProcessHeap(),0,override); |
| 1891 | } |
| 1892 | else |
| 1893 | { |
| 1894 | for(i = 0; i < package->loaded_features; i++) |
| 1895 | { |
| 1896 | BOOL feature_state= ((package->features[i].Level > 0) && |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1897 | (package->features[i].Level <= install_level)); |
| 1898 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1899 | if (feature_state) |
| 1900 | { |
| 1901 | package->features[i].ActionRequest= INSTALLSTATE_LOCAL; |
| 1902 | package->features[i].Action = INSTALLSTATE_LOCAL; |
| 1903 | } |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1904 | } |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1905 | } |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1906 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1907 | /* |
| 1908 | * now we want to enable or disable components base on feature |
| 1909 | */ |
| 1910 | |
| 1911 | for(i = 0; i < package->loaded_features; i++) |
| 1912 | { |
| 1913 | MSIFEATURE* feature = &package->features[i]; |
| 1914 | TRACE("Examining Feature %s (Installed %i, Action %i, Request %i)\n", |
| 1915 | debugstr_w(feature->Feature), feature->Installed, feature->Action, |
| 1916 | feature->ActionRequest); |
| 1917 | |
| 1918 | for( j = 0; j < feature->ComponentCount; j++) |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1919 | { |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1920 | MSICOMPONENT* component = &package->components[ |
| 1921 | feature->Components[j]]; |
| 1922 | |
| 1923 | if (!component->Enabled) |
| 1924 | { |
| 1925 | component->Action = INSTALLSTATE_ABSENT; |
| 1926 | component->ActionRequest = INSTALLSTATE_ABSENT; |
| 1927 | } |
| 1928 | else |
| 1929 | { |
| 1930 | if (feature->Action == INSTALLSTATE_LOCAL) |
| 1931 | component->Action = INSTALLSTATE_LOCAL; |
| 1932 | if (feature->ActionRequest == INSTALLSTATE_LOCAL) |
| 1933 | component->ActionRequest = INSTALLSTATE_LOCAL; |
| 1934 | } |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1935 | } |
| 1936 | } |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 1937 | |
| 1938 | for(i = 0; i < package->loaded_components; i++) |
| 1939 | { |
| 1940 | MSICOMPONENT* component= &package->components[i]; |
| 1941 | |
| 1942 | TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n", |
| 1943 | debugstr_w(component->Component), component->Installed, |
| 1944 | component->Action, component->ActionRequest); |
| 1945 | } |
| 1946 | |
| 1947 | |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 1948 | return ERROR_SUCCESS; |
| 1949 | } |
| 1950 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1951 | /* |
| 1952 | * Alot is done in this function aside from just the costing. |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 1953 | * 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] | 1954 | * to focus on the directory building |
| 1955 | * |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1956 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1957 | static UINT ACTION_CostFinalize(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1958 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1959 | static const WCHAR ExecSeqQuery[] = { |
| 1960 | 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ', |
| 1961 | 'D','i','r','e','c','t','o','r','y',0}; |
| 1962 | static const WCHAR ConditionQuery[] = { |
| 1963 | 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ', |
| 1964 | 'C','o','n','d','i','t','i','o','n',0}; |
| 1965 | static const WCHAR szCosting[] = { |
| 1966 | 'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 }; |
Aric Stewart | 8cc14a9 | 2004-12-27 18:56:30 +0000 | [diff] [blame] | 1967 | static const WCHAR szlevel[] = { |
| 1968 | 'I','N','S','T','A','L','L','L','E','V','E','L',0}; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1969 | static const WCHAR szOne[] = { '1', 0 }; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1970 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1971 | MSIQUERY * view; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 1972 | DWORD i; |
Aric Stewart | 8cc14a9 | 2004-12-27 18:56:30 +0000 | [diff] [blame] | 1973 | LPWSTR level; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 1974 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1975 | TRACE("Building Directory properties\n"); |
| 1976 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 1977 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1978 | if (rc == ERROR_SUCCESS) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1979 | { |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1980 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1981 | if (rc != ERROR_SUCCESS) |
| 1982 | { |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1983 | MSI_ViewClose(view); |
| 1984 | msiobj_release(&view->hdr); |
| 1985 | return rc; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1986 | } |
| 1987 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1988 | while (1) |
| 1989 | { |
| 1990 | WCHAR name[0x100]; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 1991 | LPWSTR path; |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1992 | MSIRECORD * row = 0; |
| 1993 | DWORD sz; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 1994 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 1995 | rc = MSI_ViewFetch(view,&row); |
| 1996 | if (rc != ERROR_SUCCESS) |
| 1997 | { |
| 1998 | rc = ERROR_SUCCESS; |
| 1999 | break; |
| 2000 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2001 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2002 | sz=0x100; |
| 2003 | MSI_RecordGetStringW(row,1,name,&sz); |
| 2004 | |
| 2005 | /* This helper function now does ALL the work */ |
| 2006 | TRACE("Dir %s ...\n",debugstr_w(name)); |
| 2007 | load_folder(package,name); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2008 | path = resolve_folder(package,name,FALSE,TRUE,NULL); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2009 | TRACE("resolves to %s\n",debugstr_w(path)); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2010 | HeapFree( GetProcessHeap(), 0, path); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2011 | |
| 2012 | msiobj_release(&row->hdr); |
| 2013 | } |
| 2014 | MSI_ViewClose(view); |
| 2015 | msiobj_release(&view->hdr); |
| 2016 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2017 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2018 | TRACE("File calculations %i files\n",package->loaded_files); |
| 2019 | |
| 2020 | for (i = 0; i < package->loaded_files; i++) |
| 2021 | { |
| 2022 | MSICOMPONENT* comp = NULL; |
| 2023 | MSIFILE* file= NULL; |
| 2024 | |
| 2025 | file = &package->files[i]; |
| 2026 | if (file->ComponentIndex >= 0) |
| 2027 | comp = &package->components[file->ComponentIndex]; |
| 2028 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2029 | if (file->Temporary == TRUE) |
| 2030 | continue; |
| 2031 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2032 | if (comp) |
| 2033 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2034 | LPWSTR p; |
| 2035 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2036 | /* calculate target */ |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2037 | p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2038 | |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 2039 | HeapFree(GetProcessHeap(),0,file->TargetPath); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2040 | |
| 2041 | TRACE("file %s is named %s\n", |
| 2042 | debugstr_w(file->File),debugstr_w(file->FileName)); |
| 2043 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2044 | file->TargetPath = build_directory_name(2, p, file->FileName); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2045 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2046 | HeapFree(GetProcessHeap(),0,p); |
| 2047 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2048 | TRACE("file %s resolves to %s\n", |
| 2049 | debugstr_w(file->File),debugstr_w(file->TargetPath)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2050 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2051 | if (GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES) |
| 2052 | { |
| 2053 | file->State = 1; |
| 2054 | comp->Cost += file->FileSize; |
| 2055 | } |
| 2056 | else |
| 2057 | { |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 2058 | if (file->Version) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2059 | { |
| 2060 | DWORD handle; |
| 2061 | DWORD versize; |
| 2062 | UINT sz; |
| 2063 | LPVOID version; |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2064 | static const WCHAR name[] = |
| 2065 | {'\\',0}; |
| 2066 | static const WCHAR name_fmt[] = |
| 2067 | {'%','u','.','%','u','.','%','u','.','%','u',0}; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2068 | WCHAR filever[0x100]; |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2069 | VS_FIXEDFILEINFO *lpVer; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2070 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 2071 | TRACE("Version comparison.. \n"); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2072 | versize = GetFileVersionInfoSizeW(file->TargetPath,&handle); |
| 2073 | version = HeapAlloc(GetProcessHeap(),0,versize); |
| 2074 | GetFileVersionInfoW(file->TargetPath, 0, versize, version); |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2075 | |
| 2076 | VerQueryValueW(version, name, (LPVOID*)&lpVer, &sz); |
| 2077 | |
| 2078 | sprintfW(filever,name_fmt, |
| 2079 | HIWORD(lpVer->dwFileVersionMS), |
| 2080 | LOWORD(lpVer->dwFileVersionMS), |
| 2081 | HIWORD(lpVer->dwFileVersionLS), |
| 2082 | LOWORD(lpVer->dwFileVersionLS)); |
| 2083 | |
| 2084 | TRACE("new %s old %s\n", debugstr_w(file->Version), |
| 2085 | debugstr_w(filever)); |
| 2086 | if (strcmpiW(filever,file->Version)<0) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2087 | { |
| 2088 | file->State = 2; |
| 2089 | FIXME("cost should be diff in size\n"); |
| 2090 | comp->Cost += file->FileSize; |
| 2091 | } |
| 2092 | else |
| 2093 | file->State = 3; |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2094 | HeapFree(GetProcessHeap(),0,version); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2095 | } |
| 2096 | else |
| 2097 | file->State = 3; |
| 2098 | } |
| 2099 | } |
| 2100 | } |
| 2101 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2102 | TRACE("Evaluating Condition Table\n"); |
Aric Stewart | 2e9b5f7 | 2004-07-04 00:31:17 +0000 | [diff] [blame] | 2103 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2104 | rc = MSI_DatabaseOpenViewW(package->db, ConditionQuery, &view); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2105 | if (rc == ERROR_SUCCESS) |
| 2106 | { |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 2107 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2108 | if (rc != ERROR_SUCCESS) |
| 2109 | { |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 2110 | MSI_ViewClose(view); |
| 2111 | msiobj_release(&view->hdr); |
| 2112 | return rc; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2113 | } |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 2114 | |
| 2115 | while (1) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2116 | { |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 2117 | WCHAR Feature[0x100]; |
| 2118 | MSIRECORD * row = 0; |
| 2119 | DWORD sz; |
| 2120 | int feature_index; |
| 2121 | |
| 2122 | rc = MSI_ViewFetch(view,&row); |
| 2123 | |
| 2124 | if (rc != ERROR_SUCCESS) |
| 2125 | { |
| 2126 | rc = ERROR_SUCCESS; |
| 2127 | break; |
| 2128 | } |
| 2129 | |
| 2130 | sz = 0x100; |
| 2131 | MSI_RecordGetStringW(row,1,Feature,&sz); |
| 2132 | |
| 2133 | feature_index = get_loaded_feature(package,Feature); |
| 2134 | if (feature_index < 0) |
| 2135 | ERR("FAILED to find loaded feature %s\n",debugstr_w(Feature)); |
| 2136 | else |
| 2137 | { |
| 2138 | LPWSTR Condition; |
| 2139 | Condition = load_dynamic_stringW(row,3); |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 2140 | |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2141 | if (MSI_EvaluateConditionW(package,Condition) == |
| 2142 | MSICONDITION_TRUE) |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 2143 | { |
| 2144 | int level = MSI_RecordGetInteger(row,2); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2145 | TRACE("Reseting feature %s to level %i\n", |
| 2146 | debugstr_w(Feature), level); |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 2147 | package->features[feature_index].Level = level; |
| 2148 | } |
| 2149 | HeapFree(GetProcessHeap(),0,Condition); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2150 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2151 | |
Mike McCormack | ac6a413 | 2005-01-04 20:36:12 +0000 | [diff] [blame] | 2152 | msiobj_release(&row->hdr); |
| 2153 | } |
| 2154 | MSI_ViewClose(view); |
| 2155 | msiobj_release(&view->hdr); |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2156 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2157 | |
| 2158 | TRACE("Enabling or Disabling Components\n"); |
| 2159 | for (i = 0; i < package->loaded_components; i++) |
| 2160 | { |
| 2161 | if (package->components[i].Condition[0]) |
| 2162 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2163 | if (MSI_EvaluateConditionW(package, |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2164 | package->components[i].Condition) == MSICONDITION_FALSE) |
| 2165 | { |
| 2166 | TRACE("Disabling component %s\n", |
| 2167 | debugstr_w(package->components[i].Component)); |
| 2168 | package->components[i].Enabled = FALSE; |
| 2169 | } |
| 2170 | } |
| 2171 | } |
| 2172 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2173 | MSI_SetPropertyW(package,szCosting,szOne); |
Aric Stewart | 8cc14a9 | 2004-12-27 18:56:30 +0000 | [diff] [blame] | 2174 | /* set default run level if not set */ |
| 2175 | level = load_dynamic_property(package,szlevel,NULL); |
| 2176 | if (!level) |
| 2177 | MSI_SetPropertyW(package,szlevel, szOne); |
| 2178 | else |
| 2179 | HeapFree(GetProcessHeap(),0,level); |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 2180 | |
| 2181 | return SetFeatureStates(package); |
| 2182 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2183 | } |
| 2184 | |
| 2185 | /* |
| 2186 | * This is a helper function for handling embedded cabinet media |
| 2187 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2188 | static UINT writeout_cabinet_stream(MSIPACKAGE *package, WCHAR* stream_name, |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2189 | WCHAR* source) |
| 2190 | { |
| 2191 | UINT rc; |
| 2192 | USHORT* data; |
| 2193 | UINT size; |
| 2194 | DWORD write; |
| 2195 | HANDLE the_file; |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2196 | WCHAR tmp[MAX_PATH]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2197 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2198 | rc = read_raw_stream_data(package->db,stream_name,&data,&size); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2199 | if (rc != ERROR_SUCCESS) |
| 2200 | return rc; |
| 2201 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2202 | write = MAX_PATH; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2203 | if (MSI_GetPropertyW(package, cszTempFolder, tmp, &write)) |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2204 | GetTempPathW(MAX_PATH,tmp); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2205 | |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 2206 | GetTempFileNameW(tmp,stream_name,0,source); |
| 2207 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2208 | track_tempfile(package,strrchrW(source,'\\'), source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2209 | the_file = CreateFileW(source, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, |
| 2210 | FILE_ATTRIBUTE_NORMAL, NULL); |
| 2211 | |
| 2212 | if (the_file == INVALID_HANDLE_VALUE) |
| 2213 | { |
| 2214 | rc = ERROR_FUNCTION_FAILED; |
| 2215 | goto end; |
| 2216 | } |
| 2217 | |
| 2218 | WriteFile(the_file,data,size,&write,NULL); |
| 2219 | CloseHandle(the_file); |
| 2220 | TRACE("wrote %li bytes to %s\n",write,debugstr_w(source)); |
| 2221 | end: |
| 2222 | HeapFree(GetProcessHeap(),0,data); |
| 2223 | return rc; |
| 2224 | } |
| 2225 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2226 | |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2227 | /* Support functions for FDI functions */ |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2228 | typedef struct |
| 2229 | { |
| 2230 | MSIPACKAGE* package; |
| 2231 | LPCSTR cab_path; |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2232 | LPCSTR file_name; |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2233 | } CabData; |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2234 | |
| 2235 | static void * cabinet_alloc(ULONG cb) |
| 2236 | { |
| 2237 | return HeapAlloc(GetProcessHeap(), 0, cb); |
| 2238 | } |
| 2239 | |
| 2240 | static void cabinet_free(void *pv) |
| 2241 | { |
| 2242 | HeapFree(GetProcessHeap(), 0, pv); |
| 2243 | } |
| 2244 | |
| 2245 | static INT_PTR cabinet_open(char *pszFile, int oflag, int pmode) |
| 2246 | { |
| 2247 | DWORD dwAccess = 0; |
| 2248 | DWORD dwShareMode = 0; |
| 2249 | DWORD dwCreateDisposition = OPEN_EXISTING; |
| 2250 | switch (oflag & _O_ACCMODE) |
| 2251 | { |
| 2252 | case _O_RDONLY: |
| 2253 | dwAccess = GENERIC_READ; |
| 2254 | dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE; |
| 2255 | break; |
| 2256 | case _O_WRONLY: |
| 2257 | dwAccess = GENERIC_WRITE; |
| 2258 | dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; |
| 2259 | break; |
| 2260 | case _O_RDWR: |
| 2261 | dwAccess = GENERIC_READ | GENERIC_WRITE; |
| 2262 | dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; |
| 2263 | break; |
| 2264 | } |
| 2265 | if ((oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) |
| 2266 | dwCreateDisposition = CREATE_NEW; |
| 2267 | else if (oflag & _O_CREAT) |
| 2268 | dwCreateDisposition = CREATE_ALWAYS; |
| 2269 | return (INT_PTR)CreateFileA(pszFile, dwAccess, dwShareMode, NULL, dwCreateDisposition, 0, NULL); |
| 2270 | } |
| 2271 | |
| 2272 | static UINT cabinet_read(INT_PTR hf, void *pv, UINT cb) |
| 2273 | { |
| 2274 | DWORD dwRead; |
| 2275 | if (ReadFile((HANDLE)hf, pv, cb, &dwRead, NULL)) |
| 2276 | return dwRead; |
| 2277 | return 0; |
| 2278 | } |
| 2279 | |
| 2280 | static UINT cabinet_write(INT_PTR hf, void *pv, UINT cb) |
| 2281 | { |
| 2282 | DWORD dwWritten; |
| 2283 | if (WriteFile((HANDLE)hf, pv, cb, &dwWritten, NULL)) |
| 2284 | return dwWritten; |
| 2285 | return 0; |
| 2286 | } |
| 2287 | |
| 2288 | static int cabinet_close(INT_PTR hf) |
| 2289 | { |
| 2290 | return CloseHandle((HANDLE)hf) ? 0 : -1; |
| 2291 | } |
| 2292 | |
| 2293 | static long cabinet_seek(INT_PTR hf, long dist, int seektype) |
| 2294 | { |
| 2295 | /* flags are compatible and so are passed straight through */ |
| 2296 | return SetFilePointer((HANDLE)hf, dist, NULL, seektype); |
| 2297 | } |
| 2298 | |
| 2299 | static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin) |
| 2300 | { |
| 2301 | /* FIXME: try to do more processing in this function */ |
| 2302 | switch (fdint) |
| 2303 | { |
| 2304 | case fdintCOPY_FILE: |
| 2305 | { |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2306 | CabData *data = (CabData*) pfdin->pv; |
| 2307 | ULONG len = strlen(data->cab_path) + strlen(pfdin->psz1); |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2308 | char *file; |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2309 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2310 | LPWSTR trackname; |
| 2311 | LPWSTR trackpath; |
| 2312 | LPWSTR tracknametmp; |
| 2313 | static const WCHAR tmpprefix[] = {'C','A','B','T','M','P','_',0}; |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2314 | |
| 2315 | if (data->file_name && strcmp(data->file_name,pfdin->psz1)) |
| 2316 | return 0; |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2317 | |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2318 | file = cabinet_alloc((len+1)*sizeof(char)); |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2319 | strcpy(file, data->cab_path); |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2320 | strcat(file, pfdin->psz1); |
| 2321 | |
| 2322 | TRACE("file: %s\n", debugstr_a(file)); |
| 2323 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2324 | /* track this file so it can be deleted if not installed */ |
| 2325 | trackpath=strdupAtoW(file); |
| 2326 | tracknametmp=strdupAtoW(strrchr(file,'\\')+1); |
| 2327 | trackname = HeapAlloc(GetProcessHeap(),0,(strlenW(tracknametmp) + |
| 2328 | strlenW(tmpprefix)+1) * sizeof(WCHAR)); |
| 2329 | |
| 2330 | strcpyW(trackname,tmpprefix); |
| 2331 | strcatW(trackname,tracknametmp); |
| 2332 | |
| 2333 | track_tempfile(data->package, trackname, trackpath); |
| 2334 | |
| 2335 | HeapFree(GetProcessHeap(),0,trackpath); |
| 2336 | HeapFree(GetProcessHeap(),0,trackname); |
| 2337 | HeapFree(GetProcessHeap(),0,tracknametmp); |
| 2338 | |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2339 | return cabinet_open(file, _O_WRONLY | _O_CREAT, 0); |
| 2340 | } |
| 2341 | case fdintCLOSE_FILE_INFO: |
| 2342 | { |
| 2343 | FILETIME ft; |
| 2344 | FILETIME ftLocal; |
| 2345 | if (!DosDateTimeToFileTime(pfdin->date, pfdin->time, &ft)) |
| 2346 | return -1; |
| 2347 | if (!LocalFileTimeToFileTime(&ft, &ftLocal)) |
| 2348 | return -1; |
| 2349 | if (!SetFileTime((HANDLE)pfdin->hf, &ftLocal, 0, &ftLocal)) |
| 2350 | return -1; |
| 2351 | |
| 2352 | cabinet_close(pfdin->hf); |
| 2353 | return 1; |
| 2354 | } |
| 2355 | default: |
| 2356 | return 0; |
| 2357 | } |
| 2358 | } |
| 2359 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2360 | /*********************************************************************** |
| 2361 | * extract_cabinet_file |
| 2362 | * |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2363 | * Extract files from a cab file. |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2364 | */ |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2365 | static BOOL extract_a_cabinet_file(MSIPACKAGE* package, const WCHAR* source, |
| 2366 | const WCHAR* path, const WCHAR* file) |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2367 | { |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2368 | HFDI hfdi; |
| 2369 | ERF erf; |
| 2370 | BOOL ret; |
| 2371 | char *cabinet; |
| 2372 | char *cab_path; |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2373 | char *file_name; |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2374 | CabData data; |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2375 | |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2376 | TRACE("Extracting %s (%s) to %s\n",debugstr_w(source), |
| 2377 | debugstr_w(file), debugstr_w(path)); |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2378 | |
| 2379 | hfdi = FDICreate(cabinet_alloc, |
| 2380 | cabinet_free, |
| 2381 | cabinet_open, |
| 2382 | cabinet_read, |
| 2383 | cabinet_write, |
| 2384 | cabinet_close, |
| 2385 | cabinet_seek, |
| 2386 | 0, |
| 2387 | &erf); |
| 2388 | if (!hfdi) |
| 2389 | { |
| 2390 | ERR("FDICreate failed\n"); |
| 2391 | return FALSE; |
| 2392 | } |
| 2393 | |
| 2394 | if (!(cabinet = strdupWtoA( source ))) |
| 2395 | { |
| 2396 | FDIDestroy(hfdi); |
| 2397 | return FALSE; |
| 2398 | } |
| 2399 | if (!(cab_path = strdupWtoA( path ))) |
| 2400 | { |
| 2401 | FDIDestroy(hfdi); |
| 2402 | HeapFree(GetProcessHeap(), 0, cabinet); |
| 2403 | return FALSE; |
| 2404 | } |
| 2405 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2406 | data.package = package; |
| 2407 | data.cab_path = cab_path; |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 2408 | if (file) |
| 2409 | file_name = strdupWtoA(file); |
| 2410 | else |
| 2411 | file_name = NULL; |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2412 | data.file_name = file_name; |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2413 | |
| 2414 | ret = FDICopy(hfdi, cabinet, "", 0, cabinet_notify, NULL, &data); |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2415 | |
| 2416 | if (!ret) |
| 2417 | ERR("FDICopy failed\n"); |
| 2418 | |
| 2419 | FDIDestroy(hfdi); |
| 2420 | |
| 2421 | HeapFree(GetProcessHeap(), 0, cabinet); |
| 2422 | HeapFree(GetProcessHeap(), 0, cab_path); |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2423 | HeapFree(GetProcessHeap(), 0, file_name); |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2424 | |
| 2425 | return ret; |
Aric Stewart | 36eee23 | 2004-07-04 00:07:13 +0000 | [diff] [blame] | 2426 | } |
| 2427 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2428 | static UINT ready_media_for_file(MSIPACKAGE *package, UINT sequence, |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2429 | WCHAR* path, WCHAR* file) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2430 | { |
| 2431 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2432 | MSIQUERY * view; |
| 2433 | MSIRECORD * row = 0; |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2434 | static WCHAR source[MAX_PATH]; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2435 | static const WCHAR ExecSeqQuery[] = { |
| 2436 | 's','e','l','e','c','t',' ','*',' ', |
| 2437 | 'f','r','o','m',' ','M','e','d','i','a',' ', |
| 2438 | 'w','h','e','r','e',' ','L','a','s','t','S','e','q','u','e','n','c','e',' ','>','=',' ','%','i',' ', |
| 2439 | 'o','r','d','e','r',' ','b','y',' ','L','a','s','t','S','e','q','u','e','n','c','e',0}; |
| 2440 | WCHAR Query[1024]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2441 | WCHAR cab[0x100]; |
| 2442 | DWORD sz=0x100; |
| 2443 | INT seq; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2444 | static UINT last_sequence = 0; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2445 | |
| 2446 | if (sequence <= last_sequence) |
| 2447 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2448 | TRACE("Media already ready (%u, %u)\n",sequence,last_sequence); |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 2449 | /*extract_a_cabinet_file(package, source,path,file); */ |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2450 | return ERROR_SUCCESS; |
| 2451 | } |
| 2452 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2453 | sprintfW(Query,ExecSeqQuery,sequence); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2454 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2455 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2456 | if (rc != ERROR_SUCCESS) |
| 2457 | return rc; |
| 2458 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2459 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2460 | if (rc != ERROR_SUCCESS) |
| 2461 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2462 | MSI_ViewClose(view); |
| 2463 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2464 | return rc; |
| 2465 | } |
| 2466 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2467 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2468 | if (rc != ERROR_SUCCESS) |
| 2469 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2470 | MSI_ViewClose(view); |
| 2471 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2472 | return rc; |
| 2473 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2474 | seq = MSI_RecordGetInteger(row,2); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2475 | last_sequence = seq; |
| 2476 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2477 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2478 | { |
| 2479 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2480 | MSI_RecordGetStringW(row,4,cab,&sz); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2481 | TRACE("Source is CAB %s\n",debugstr_w(cab)); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2482 | /* the stream does not contain the # character */ |
| 2483 | if (cab[0]=='#') |
| 2484 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2485 | writeout_cabinet_stream(package,&cab[1],source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2486 | strcpyW(path,source); |
| 2487 | *(strrchrW(path,'\\')+1)=0; |
| 2488 | } |
| 2489 | else |
| 2490 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 2491 | sz = MAX_PATH; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2492 | if (MSI_GetPropertyW(package, cszSourceDir, source, &sz)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2493 | { |
| 2494 | ERR("No Source dir defined \n"); |
| 2495 | rc = ERROR_FUNCTION_FAILED; |
| 2496 | } |
| 2497 | else |
| 2498 | { |
| 2499 | strcpyW(path,source); |
| 2500 | strcatW(source,cab); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2501 | /* extract the cab file into a folder in the temp folder */ |
| 2502 | sz = MAX_PATH; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2503 | if (MSI_GetPropertyW(package, cszTempFolder,path, &sz) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2504 | != ERROR_SUCCESS) |
| 2505 | GetTempPathW(MAX_PATH,path); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2506 | } |
| 2507 | } |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 2508 | rc = !extract_a_cabinet_file(package, source,path,NULL); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2509 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2510 | msiobj_release(&row->hdr); |
| 2511 | MSI_ViewClose(view); |
| 2512 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2513 | return rc; |
| 2514 | } |
| 2515 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2516 | inline static UINT create_component_directory ( MSIPACKAGE* package, INT component) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2517 | { |
Marcus Meissner | b7f6781 | 2005-01-14 16:50:39 +0000 | [diff] [blame] | 2518 | UINT rc = ERROR_SUCCESS; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2519 | MSIFOLDER *folder; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2520 | LPWSTR install_path; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2521 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2522 | install_path = resolve_folder(package, package->components[component].Directory, |
| 2523 | FALSE, FALSE, &folder); |
| 2524 | if (!install_path) |
| 2525 | return ERROR_FUNCTION_FAILED; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2526 | |
| 2527 | /* create the path */ |
| 2528 | if (folder->State == 0) |
| 2529 | { |
| 2530 | create_full_pathW(install_path); |
| 2531 | folder->State = 2; |
| 2532 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2533 | HeapFree(GetProcessHeap(), 0, install_path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 2534 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2535 | return rc; |
| 2536 | } |
| 2537 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2538 | static UINT ACTION_InstallFiles(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2539 | { |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2540 | UINT rc = ERROR_SUCCESS; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2541 | DWORD index; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2542 | MSIRECORD * uirow; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2543 | WCHAR uipath[MAX_PATH]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2544 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2545 | if (!package) |
| 2546 | return ERROR_INVALID_HANDLE; |
| 2547 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2548 | /* increment progress bar each time action data is sent */ |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 2549 | ui_progress(package,1,1,0,0); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2550 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2551 | for (index = 0; index < package->loaded_files; index++) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2552 | { |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2553 | WCHAR path_to_source[MAX_PATH]; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2554 | MSIFILE *file; |
| 2555 | |
| 2556 | file = &package->files[index]; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2557 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2558 | if (file->Temporary) |
| 2559 | continue; |
| 2560 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2561 | if (package->components[file->ComponentIndex].ActionRequest != |
| 2562 | INSTALLSTATE_LOCAL) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2563 | { |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 2564 | ui_progress(package,2,file->FileSize,0,0); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2565 | TRACE("File %s is not scheduled for install\n", |
| 2566 | debugstr_w(file->File)); |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2567 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2568 | continue; |
| 2569 | } |
| 2570 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2571 | if ((file->State == 1) || (file->State == 2)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2572 | { |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 2573 | LPWSTR p; |
| 2574 | INT len; |
| 2575 | MSICOMPONENT* comp = NULL; |
| 2576 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2577 | TRACE("Installing %s\n",debugstr_w(file->File)); |
Aric Stewart | def5cbf | 2005-01-04 20:42:58 +0000 | [diff] [blame] | 2578 | rc = ready_media_for_file(package,file->Sequence,path_to_source, |
| 2579 | file->File); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2580 | /* |
| 2581 | * WARNING! |
| 2582 | * our file table could change here because a new temp file |
| 2583 | * may have been created |
| 2584 | */ |
| 2585 | file = &package->files[index]; |
| 2586 | if (rc != ERROR_SUCCESS) |
| 2587 | { |
| 2588 | ERR("Unable to ready media\n"); |
| 2589 | rc = ERROR_FUNCTION_FAILED; |
| 2590 | break; |
| 2591 | } |
| 2592 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2593 | create_component_directory( package, file->ComponentIndex); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2594 | |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 2595 | /* recalculate file paths because things may have changed */ |
| 2596 | |
| 2597 | if (file->ComponentIndex >= 0) |
| 2598 | comp = &package->components[file->ComponentIndex]; |
| 2599 | |
| 2600 | p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL); |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 2601 | HeapFree(GetProcessHeap(),0,file->TargetPath); |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 2602 | |
| 2603 | file->TargetPath = build_directory_name(2, p, file->FileName); |
| 2604 | |
| 2605 | len = strlenW(path_to_source) + strlenW(file->File) + 2; |
| 2606 | file->SourcePath = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2607 | strcpyW(file->SourcePath, path_to_source); |
| 2608 | strcatW(file->SourcePath, file->File); |
| 2609 | |
| 2610 | TRACE("file paths %s to %s\n",debugstr_w(file->SourcePath), |
| 2611 | debugstr_w(file->TargetPath)); |
| 2612 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2613 | /* the UI chunk */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2614 | uirow=MSI_CreateRecord(9); |
| 2615 | MSI_RecordSetStringW(uirow,1,file->File); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2616 | strcpyW(uipath,file->TargetPath); |
| 2617 | *(strrchrW(uipath,'\\')+1)=0; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2618 | MSI_RecordSetStringW(uirow,9,uipath); |
| 2619 | MSI_RecordSetInteger(uirow,6,file->FileSize); |
| 2620 | ui_actiondata(package,szInstallFiles,uirow); |
| 2621 | msiobj_release( &uirow->hdr ); |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 2622 | ui_progress(package,2,file->FileSize,0,0); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2623 | |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2624 | if (!MoveFileW(file->SourcePath,file->TargetPath)) |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 2625 | { |
Robert Shearman | 3d7299b | 2004-09-10 22:29:49 +0000 | [diff] [blame] | 2626 | rc = GetLastError(); |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2627 | ERR("Unable to move file (%s -> %s) (error %d)\n", |
| 2628 | debugstr_w(file->SourcePath), debugstr_w(file->TargetPath), |
| 2629 | rc); |
| 2630 | if (rc == ERROR_ALREADY_EXISTS && file->State == 2) |
| 2631 | { |
| 2632 | CopyFileW(file->SourcePath,file->TargetPath,FALSE); |
| 2633 | DeleteFileW(file->SourcePath); |
| 2634 | rc = 0; |
| 2635 | } |
Aric Stewart | 3c949ef | 2004-12-27 17:09:40 +0000 | [diff] [blame] | 2636 | else if (rc == ERROR_FILE_NOT_FOUND) |
| 2637 | { |
| 2638 | ERR("Source File Not Found! Continueing\n"); |
| 2639 | rc = 0; |
| 2640 | } |
Aric Stewart | 120009e | 2004-10-08 23:35:35 +0000 | [diff] [blame] | 2641 | else |
Aric Stewart | 2ad3ff8 | 2004-12-27 18:50:00 +0000 | [diff] [blame] | 2642 | { |
| 2643 | ERR("Ignoring Error and continuing...\n"); |
| 2644 | rc = 0; |
| 2645 | } |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 2646 | } |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2647 | else |
| 2648 | file->State = 4; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2649 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2650 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2651 | |
| 2652 | return rc; |
| 2653 | } |
| 2654 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2655 | inline static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key, |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2656 | LPWSTR* file_source) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2657 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 2658 | DWORD index; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2659 | |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2660 | if (!package) |
| 2661 | return ERROR_INVALID_HANDLE; |
| 2662 | |
| 2663 | for (index = 0; index < package->loaded_files; index ++) |
| 2664 | { |
| 2665 | if (strcmpW(file_key,package->files[index].File)==0) |
| 2666 | { |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 2667 | if (package->files[index].State >= 2) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2668 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2669 | *file_source = dupstrW(package->files[index].TargetPath); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2670 | return ERROR_SUCCESS; |
| 2671 | } |
| 2672 | else |
| 2673 | return ERROR_FILE_NOT_FOUND; |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2674 | } |
| 2675 | } |
| 2676 | |
| 2677 | return ERROR_FUNCTION_FAILED; |
| 2678 | } |
| 2679 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2680 | static UINT ACTION_DuplicateFiles(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2681 | { |
| 2682 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2683 | MSIQUERY * view; |
| 2684 | MSIRECORD * row = 0; |
| 2685 | static const WCHAR ExecSeqQuery[] = { |
| 2686 | 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ', |
| 2687 | '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] | 2688 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2689 | if (!package) |
| 2690 | return ERROR_INVALID_HANDLE; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2691 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2692 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2693 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2694 | return ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2695 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2696 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2697 | if (rc != ERROR_SUCCESS) |
| 2698 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2699 | MSI_ViewClose(view); |
| 2700 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2701 | return rc; |
| 2702 | } |
| 2703 | |
| 2704 | while (1) |
| 2705 | { |
| 2706 | WCHAR file_key[0x100]; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2707 | WCHAR *file_source = NULL; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2708 | WCHAR dest_name[0x100]; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2709 | LPWSTR dest_path, dest; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2710 | WCHAR component[0x100]; |
| 2711 | INT component_index; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2712 | |
| 2713 | DWORD sz=0x100; |
| 2714 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2715 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2716 | if (rc != ERROR_SUCCESS) |
| 2717 | { |
| 2718 | rc = ERROR_SUCCESS; |
| 2719 | break; |
| 2720 | } |
| 2721 | |
| 2722 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2723 | rc = MSI_RecordGetStringW(row,2,component,&sz); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2724 | if (rc != ERROR_SUCCESS) |
| 2725 | { |
| 2726 | ERR("Unable to get component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2727 | msiobj_release(&row->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2728 | break; |
| 2729 | } |
| 2730 | |
| 2731 | component_index = get_loaded_component(package,component); |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2732 | if (package->components[component_index].ActionRequest != |
| 2733 | INSTALLSTATE_LOCAL) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2734 | { |
| 2735 | TRACE("Skipping copy due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2736 | msiobj_release(&row->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2737 | continue; |
| 2738 | } |
| 2739 | |
| 2740 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2741 | rc = MSI_RecordGetStringW(row,3,file_key,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2742 | if (rc != ERROR_SUCCESS) |
| 2743 | { |
| 2744 | ERR("Unable to get file key\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2745 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2746 | break; |
| 2747 | } |
| 2748 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2749 | rc = get_file_target(package,file_key,&file_source); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2750 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2751 | if (rc != ERROR_SUCCESS) |
| 2752 | { |
| 2753 | ERR("Original file unknown %s\n",debugstr_w(file_key)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2754 | msiobj_release(&row->hdr); |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 2755 | HeapFree(GetProcessHeap(),0,file_source); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 2756 | continue; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2757 | } |
| 2758 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2759 | if (MSI_RecordIsNull(row,4)) |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2760 | { |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2761 | strcpyW(dest_name,strrchrW(file_source,'\\')+1); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2762 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2763 | else |
| 2764 | { |
| 2765 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2766 | MSI_RecordGetStringW(row,4,dest_name,&sz); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2767 | reduce_to_longfilename(dest_name); |
| 2768 | } |
| 2769 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2770 | if (MSI_RecordIsNull(row,5)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2771 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2772 | LPWSTR p; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2773 | dest_path = dupstrW(file_source); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2774 | p = strrchrW(dest_path,'\\'); |
| 2775 | if (p) |
| 2776 | *p=0; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2777 | } |
| 2778 | else |
| 2779 | { |
| 2780 | WCHAR destkey[0x100]; |
| 2781 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2782 | MSI_RecordGetStringW(row,5,destkey,&sz); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 2783 | sz = 0x100; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2784 | dest_path = resolve_folder(package, destkey, FALSE,FALSE,NULL); |
| 2785 | if (!dest_path) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2786 | { |
| 2787 | ERR("Unable to get destination folder\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2788 | msiobj_release(&row->hdr); |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 2789 | HeapFree(GetProcessHeap(),0,file_source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2790 | break; |
| 2791 | } |
| 2792 | } |
| 2793 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 2794 | dest = build_directory_name(2, dest_path, dest_name); |
| 2795 | HeapFree(GetProcessHeap(), 0, dest_path); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2796 | |
| 2797 | TRACE("Duplicating file %s to %s\n",debugstr_w(file_source), |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2798 | debugstr_w(dest)); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2799 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2800 | if (strcmpW(file_source,dest)) |
| 2801 | rc = !CopyFileW(file_source,dest,TRUE); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2802 | else |
| 2803 | rc = ERROR_SUCCESS; |
| 2804 | |
| 2805 | if (rc != ERROR_SUCCESS) |
| 2806 | ERR("Failed to copy file\n"); |
Aric Stewart | ec688fb | 2004-07-04 00:35:52 +0000 | [diff] [blame] | 2807 | |
| 2808 | FIXME("We should track these duplicate files as well\n"); |
| 2809 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2810 | msiobj_release(&row->hdr); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 2811 | HeapFree(GetProcessHeap(),0,dest); |
| 2812 | HeapFree(GetProcessHeap(),0,file_source); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2813 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2814 | MSI_ViewClose(view); |
| 2815 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2816 | return rc; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2817 | } |
| 2818 | |
| 2819 | |
Mike McCormack | 6e2bca3 | 2004-07-04 00:25:00 +0000 | [diff] [blame] | 2820 | /* OK this value is "interpretted" and then formatted based on the |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 2821 | first few characters */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2822 | static LPSTR parse_value(MSIPACKAGE *package, WCHAR *value, DWORD *type, |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2823 | DWORD *size) |
| 2824 | { |
| 2825 | LPSTR data = NULL; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 2826 | if (value[0]=='#' && value[1]!='#' && value[1]!='%') |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2827 | { |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 2828 | if (value[1]=='x') |
| 2829 | { |
| 2830 | LPWSTR ptr; |
| 2831 | CHAR byte[5]; |
| 2832 | LPWSTR deformated; |
| 2833 | int count; |
| 2834 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2835 | deformat_string(package, &value[2], &deformated); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 2836 | |
| 2837 | /* binary value type */ |
| 2838 | ptr = deformated; |
| 2839 | *type=REG_BINARY; |
| 2840 | *size = strlenW(ptr)/2; |
| 2841 | data = HeapAlloc(GetProcessHeap(),0,*size); |
| 2842 | |
| 2843 | byte[0] = '0'; |
| 2844 | byte[1] = 'x'; |
| 2845 | byte[4] = 0; |
| 2846 | count = 0; |
| 2847 | while (*ptr) |
| 2848 | { |
| 2849 | byte[2]= *ptr; |
| 2850 | ptr++; |
| 2851 | byte[3]= *ptr; |
| 2852 | ptr++; |
| 2853 | data[count] = (BYTE)strtol(byte,NULL,0); |
| 2854 | count ++; |
| 2855 | } |
| 2856 | HeapFree(GetProcessHeap(),0,deformated); |
| 2857 | |
| 2858 | TRACE("Data %li bytes(%i)\n",*size,count); |
| 2859 | } |
| 2860 | else |
| 2861 | { |
| 2862 | LPWSTR deformated; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2863 | deformat_string(package, &value[1], &deformated); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 2864 | |
| 2865 | *type=REG_DWORD; |
| 2866 | *size = sizeof(DWORD); |
| 2867 | data = HeapAlloc(GetProcessHeap(),0,*size); |
| 2868 | *(LPDWORD)data = atoiW(deformated); |
| 2869 | TRACE("DWORD %i\n",*data); |
| 2870 | |
| 2871 | HeapFree(GetProcessHeap(),0,deformated); |
| 2872 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2873 | } |
| 2874 | else |
| 2875 | { |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 2876 | static const WCHAR szMulti[] = {'[','~',']',0}; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2877 | WCHAR *ptr; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 2878 | *type=REG_SZ; |
| 2879 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2880 | if (value[0]=='#') |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 2881 | { |
| 2882 | if (value[1]=='%') |
| 2883 | { |
| 2884 | ptr = &value[2]; |
| 2885 | *type=REG_EXPAND_SZ; |
| 2886 | } |
| 2887 | else |
| 2888 | ptr = &value[1]; |
| 2889 | } |
| 2890 | else |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2891 | ptr=value; |
| 2892 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 2893 | if (strstrW(value,szMulti)) |
| 2894 | *type = REG_MULTI_SZ; |
| 2895 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2896 | *size = deformat_string(package, ptr,(LPWSTR*)&data); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2897 | } |
| 2898 | return data; |
| 2899 | } |
| 2900 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2901 | static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2902 | { |
| 2903 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2904 | MSIQUERY * view; |
| 2905 | MSIRECORD * row = 0; |
| 2906 | static const WCHAR ExecSeqQuery[] = { |
| 2907 | 's','e','l','e','c','t',' ','*',' ', |
| 2908 | '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] | 2909 | |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2910 | if (!package) |
| 2911 | return ERROR_INVALID_HANDLE; |
| 2912 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2913 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2914 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 2915 | return ERROR_SUCCESS; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2916 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2917 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2918 | if (rc != ERROR_SUCCESS) |
| 2919 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2920 | MSI_ViewClose(view); |
| 2921 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2922 | return rc; |
| 2923 | } |
| 2924 | |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2925 | /* increment progress bar each time action data is sent */ |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 2926 | ui_progress(package,1,REG_PROGRESS_VALUE,1,0); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2927 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2928 | while (1) |
| 2929 | { |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2930 | static const WCHAR szHCR[] = |
| 2931 | {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T','\\',0}; |
| 2932 | static const WCHAR szHCU[] = |
| 2933 | {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\',0}; |
| 2934 | static const WCHAR szHLM[] = |
| 2935 | {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E', |
| 2936 | '\\',0}; |
| 2937 | static const WCHAR szHU[] = |
| 2938 | {'H','K','E','Y','_','U','S','E','R','S','\\',0}; |
| 2939 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2940 | LPSTR value_data = NULL; |
| 2941 | HKEY root_key, hkey; |
| 2942 | DWORD type,size; |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 2943 | LPWSTR value, key, name, component, deformated; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2944 | LPCWSTR szRoot; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2945 | INT component_index; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2946 | MSIRECORD * uirow; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2947 | LPWSTR uikey; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2948 | INT root; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2949 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2950 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2951 | if (rc != ERROR_SUCCESS) |
| 2952 | { |
| 2953 | rc = ERROR_SUCCESS; |
| 2954 | break; |
| 2955 | } |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 2956 | ui_progress(package,2,0,0,0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2957 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2958 | value = NULL; |
| 2959 | key = NULL; |
| 2960 | uikey = NULL; |
| 2961 | name = NULL; |
| 2962 | |
| 2963 | component = load_dynamic_stringW(row, 6); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2964 | component_index = get_loaded_component(package,component); |
| 2965 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 2966 | if (package->components[component_index].ActionRequest != |
| 2967 | INSTALLSTATE_LOCAL) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2968 | { |
| 2969 | TRACE("Skipping write due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2970 | msiobj_release(&row->hdr); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2971 | goto next; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 2972 | } |
| 2973 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2974 | /* null values have special meanings during uninstalls and such */ |
| 2975 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2976 | if(MSI_RecordIsNull(row,5)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2977 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2978 | msiobj_release(&row->hdr); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2979 | goto next; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2980 | } |
| 2981 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 2982 | root = MSI_RecordGetInteger(row,2); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2983 | key = load_dynamic_stringW(row, 3); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2984 | |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2985 | name = load_dynamic_stringW(row, 4); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2986 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 2987 | /* get the root key */ |
| 2988 | switch (root) |
| 2989 | { |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2990 | case 0: root_key = HKEY_CLASSES_ROOT; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2991 | szRoot = szHCR; |
| 2992 | break; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2993 | case 1: root_key = HKEY_CURRENT_USER; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2994 | szRoot = szHCU; |
| 2995 | break; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2996 | case 2: root_key = HKEY_LOCAL_MACHINE; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 2997 | szRoot = szHLM; |
| 2998 | break; |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 2999 | case 3: root_key = HKEY_USERS; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3000 | szRoot = szHU; |
| 3001 | break; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3002 | default: |
| 3003 | ERR("Unknown root %i\n",root); |
| 3004 | root_key=NULL; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3005 | szRoot = NULL; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3006 | break; |
| 3007 | } |
| 3008 | if (!root_key) |
| 3009 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3010 | msiobj_release(&row->hdr); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3011 | goto next; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3012 | } |
| 3013 | |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3014 | deformat_string(package, key , &deformated); |
| 3015 | size = strlenW(deformated) + strlenW(szRoot) + 1; |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3016 | uikey = HeapAlloc(GetProcessHeap(), 0, size*sizeof(WCHAR)); |
| 3017 | strcpyW(uikey,szRoot); |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3018 | strcatW(uikey,deformated); |
| 3019 | |
| 3020 | if (RegCreateKeyW( root_key, deformated, &hkey)) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3021 | { |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3022 | ERR("Could not create key %s\n",debugstr_w(deformated)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3023 | msiobj_release(&row->hdr); |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3024 | HeapFree(GetProcessHeap(),0,deformated); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3025 | goto next; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3026 | } |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3027 | HeapFree(GetProcessHeap(),0,deformated); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 3028 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3029 | value = load_dynamic_stringW(row,5); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3030 | value_data = parse_value(package, value, &type, &size); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3031 | |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3032 | deformat_string(package, name, &deformated); |
| 3033 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3034 | if (value_data) |
| 3035 | { |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3036 | TRACE("Setting value %s\n",debugstr_w(deformated)); |
| 3037 | RegSetValueExW(hkey, deformated, 0, type, value_data, size); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3038 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3039 | uirow = MSI_CreateRecord(3); |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3040 | MSI_RecordSetStringW(uirow,2,deformated); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3041 | MSI_RecordSetStringW(uirow,1,uikey); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3042 | |
| 3043 | if (type == REG_SZ) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3044 | MSI_RecordSetStringW(uirow,3,(LPWSTR)value_data); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3045 | else |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3046 | MSI_RecordSetStringW(uirow,3,value); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3047 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3048 | ui_actiondata(package,szWriteRegistryValues,uirow); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3049 | msiobj_release( &uirow->hdr ); |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3050 | |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3051 | HeapFree(GetProcessHeap(),0,value_data); |
| 3052 | } |
Aric Stewart | d2c395a | 2004-07-06 18:48:15 +0000 | [diff] [blame] | 3053 | HeapFree(GetProcessHeap(),0,value); |
Aric Stewart | 1416b10 | 2005-01-06 19:34:16 +0000 | [diff] [blame] | 3054 | HeapFree(GetProcessHeap(),0,deformated); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3055 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3056 | msiobj_release(&row->hdr); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3057 | RegCloseKey(hkey); |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3058 | next: |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 3059 | HeapFree(GetProcessHeap(),0,uikey); |
| 3060 | HeapFree(GetProcessHeap(),0,key); |
| 3061 | HeapFree(GetProcessHeap(),0,name); |
| 3062 | HeapFree(GetProcessHeap(),0,component); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3063 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3064 | MSI_ViewClose(view); |
| 3065 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 3066 | return rc; |
| 3067 | } |
| 3068 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3069 | static UINT ACTION_InstallInitialize(MSIPACKAGE *package) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3070 | { |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3071 | return ERROR_SUCCESS; |
| 3072 | } |
| 3073 | |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 3074 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3075 | static UINT ACTION_InstallValidate(MSIPACKAGE *package) |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3076 | { |
| 3077 | DWORD progress = 0; |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 3078 | DWORD total = 0; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3079 | static const WCHAR q1[]={ |
| 3080 | 'S','E','L','E','C','T',' ','*',' ', |
| 3081 | '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] | 3082 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3083 | MSIQUERY * view; |
| 3084 | MSIRECORD * row = 0; |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 3085 | int i; |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3086 | |
| 3087 | TRACE(" InstallValidate \n"); |
| 3088 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3089 | rc = MSI_DatabaseOpenViewW(package->db, q1, &view); |
| 3090 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3091 | return ERROR_SUCCESS; |
| 3092 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3093 | rc = MSI_ViewExecute(view, 0); |
| 3094 | if (rc != ERROR_SUCCESS) |
| 3095 | { |
| 3096 | MSI_ViewClose(view); |
| 3097 | msiobj_release(&view->hdr); |
| 3098 | return rc; |
| 3099 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3100 | while (1) |
| 3101 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3102 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3103 | if (rc != ERROR_SUCCESS) |
| 3104 | { |
| 3105 | rc = ERROR_SUCCESS; |
| 3106 | break; |
| 3107 | } |
| 3108 | progress +=1; |
| 3109 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3110 | msiobj_release(&row->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3111 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3112 | MSI_ViewClose(view); |
| 3113 | msiobj_release(&view->hdr); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3114 | |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 3115 | total = total + progress * REG_PROGRESS_VALUE; |
| 3116 | total = total + package->loaded_components * COMPONENT_PROGRESS_VALUE; |
| 3117 | for (i=0; i < package->loaded_files; i++) |
| 3118 | total += package->files[i].FileSize; |
| 3119 | ui_progress(package,0,total,0,0); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3120 | |
| 3121 | return ERROR_SUCCESS; |
| 3122 | } |
| 3123 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3124 | static UINT ACTION_LaunchConditions(MSIPACKAGE *package) |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3125 | { |
| 3126 | UINT rc; |
Mike McCormack | f3c8b83 | 2004-07-19 19:35:05 +0000 | [diff] [blame] | 3127 | MSIQUERY * view = NULL; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3128 | MSIRECORD * row = 0; |
| 3129 | static const WCHAR ExecSeqQuery[] = { |
| 3130 | 'S','E','L','E','C','T',' ','*',' ', |
| 3131 | '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] | 3132 | static const WCHAR title[]= |
| 3133 | {'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] | 3134 | |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3135 | TRACE("Checking launch conditions\n"); |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3136 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3137 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3138 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3139 | return ERROR_SUCCESS; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3140 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3141 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3142 | if (rc != ERROR_SUCCESS) |
| 3143 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3144 | MSI_ViewClose(view); |
| 3145 | msiobj_release(&view->hdr); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3146 | return rc; |
| 3147 | } |
| 3148 | |
| 3149 | rc = ERROR_SUCCESS; |
| 3150 | while (rc == ERROR_SUCCESS) |
| 3151 | { |
| 3152 | LPWSTR cond = NULL; |
| 3153 | LPWSTR message = NULL; |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3154 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3155 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3156 | if (rc != ERROR_SUCCESS) |
| 3157 | { |
| 3158 | rc = ERROR_SUCCESS; |
| 3159 | break; |
| 3160 | } |
| 3161 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3162 | cond = load_dynamic_stringW(row,1); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3163 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3164 | if (MSI_EvaluateConditionW(package,cond) != MSICONDITION_TRUE) |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3165 | { |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3166 | LPWSTR deformated; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3167 | message = load_dynamic_stringW(row,2); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3168 | deformat_string(package,message,&deformated); |
| 3169 | MessageBoxW(NULL,deformated,title,MB_OK); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3170 | HeapFree(GetProcessHeap(),0,message); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3171 | HeapFree(GetProcessHeap(),0,deformated); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3172 | rc = ERROR_FUNCTION_FAILED; |
| 3173 | } |
| 3174 | HeapFree(GetProcessHeap(),0,cond); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3175 | msiobj_release(&row->hdr); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3176 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3177 | MSI_ViewClose(view); |
| 3178 | msiobj_release(&view->hdr); |
Aric Stewart | 5b936ca | 2004-07-06 18:47:09 +0000 | [diff] [blame] | 3179 | return rc; |
| 3180 | } |
Aric Stewart | 7d3e597 | 2004-07-04 00:36:58 +0000 | [diff] [blame] | 3181 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3182 | static LPWSTR resolve_keypath( MSIPACKAGE* package, INT |
| 3183 | component_index) |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3184 | { |
| 3185 | MSICOMPONENT* cmp = &package->components[component_index]; |
| 3186 | |
| 3187 | if (cmp->KeyPath[0]==0) |
| 3188 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3189 | LPWSTR p = resolve_folder(package,cmp->Directory,FALSE,FALSE,NULL); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3190 | return p; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3191 | } |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3192 | if (cmp->Attributes & 0x4) |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3193 | { |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3194 | MSIQUERY * view; |
| 3195 | MSIRECORD * row = 0; |
| 3196 | UINT rc,root,len; |
| 3197 | LPWSTR key,deformated,buffer,name,deformated_name; |
| 3198 | static const WCHAR ExecSeqQuery[] = { |
| 3199 | 's','e','l','e','c','t',' ','*',' ', |
| 3200 | 'f','r','o','m',' ','R','e','g','i','s','t','r','y',' ', |
| 3201 | 'w','h','e','r','e',' ','R','e','g','i','s','t','r','y',' ','=',' ' |
| 3202 | ,'`','%','s','`',0 }; |
| 3203 | static const WCHAR fmt[]={'%','0','2','i',':','%','s',0}; |
| 3204 | static const WCHAR fmt2[]={'%','0','2','i',':','%','s','\\','%','s',0}; |
| 3205 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 3206 | rc = MSI_OpenQuery(package->db,&view,ExecSeqQuery,cmp->KeyPath); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3207 | |
| 3208 | if (rc!=ERROR_SUCCESS) |
| 3209 | return NULL; |
| 3210 | |
| 3211 | rc = MSI_ViewExecute(view, 0); |
| 3212 | if (rc != ERROR_SUCCESS) |
| 3213 | { |
| 3214 | MSI_ViewClose(view); |
| 3215 | msiobj_release(&view->hdr); |
| 3216 | return NULL; |
| 3217 | } |
| 3218 | |
| 3219 | rc = MSI_ViewFetch(view,&row); |
| 3220 | if (rc != ERROR_SUCCESS) |
| 3221 | { |
| 3222 | MSI_ViewClose(view); |
| 3223 | msiobj_release(&view->hdr); |
| 3224 | return NULL; |
| 3225 | } |
| 3226 | |
| 3227 | root = MSI_RecordGetInteger(row,2); |
| 3228 | key = load_dynamic_stringW(row, 3); |
| 3229 | name = load_dynamic_stringW(row, 4); |
| 3230 | deformat_string(package, key , &deformated); |
| 3231 | deformat_string(package, name, &deformated_name); |
| 3232 | |
| 3233 | len = strlenW(deformated) + 5; |
| 3234 | if (deformated_name) |
| 3235 | len+=strlenW(deformated_name); |
| 3236 | |
| 3237 | buffer = HeapAlloc(GetProcessHeap(),0, len *sizeof(WCHAR)); |
| 3238 | |
| 3239 | if (deformated_name) |
| 3240 | sprintfW(buffer,fmt2,root,deformated,deformated_name); |
| 3241 | else |
| 3242 | sprintfW(buffer,fmt,root,deformated); |
| 3243 | |
| 3244 | HeapFree(GetProcessHeap(),0,key); |
| 3245 | HeapFree(GetProcessHeap(),0,deformated); |
| 3246 | HeapFree(GetProcessHeap(),0,name); |
| 3247 | HeapFree(GetProcessHeap(),0,deformated_name); |
| 3248 | msiobj_release(&row->hdr); |
| 3249 | MSI_ViewClose(view); |
| 3250 | msiobj_release(&view->hdr); |
| 3251 | |
| 3252 | return buffer; |
| 3253 | } |
| 3254 | else if (cmp->Attributes & 0x20) |
| 3255 | { |
| 3256 | FIXME("UNIMPLEMENTED keypath as ODBC Source\n"); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3257 | return NULL; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3258 | } |
| 3259 | else |
| 3260 | { |
| 3261 | int j; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3262 | j = get_loaded_file(package,cmp->KeyPath); |
| 3263 | |
| 3264 | if (j>=0) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3265 | { |
| 3266 | LPWSTR p = dupstrW(package->files[j].TargetPath); |
| 3267 | return p; |
| 3268 | } |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3269 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3270 | return NULL; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3271 | } |
| 3272 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3273 | /* |
| 3274 | * Ok further analysis makes me think that this work is |
| 3275 | * actually done in the PublishComponents and PublishFeatures |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 3276 | * step, and not here. It appears like the keypath and all that is |
| 3277 | * resolved in this step, however actually written in the Publish steps. |
Alexandre Julliard | 77b1276 | 2004-07-09 19:43:29 +0000 | [diff] [blame] | 3278 | * But we will leave it here for now because it is unclear |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3279 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3280 | static UINT ACTION_ProcessComponents(MSIPACKAGE *package) |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3281 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3282 | LPWSTR productcode; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 3283 | WCHAR squished_pc[GUID_SIZE]; |
| 3284 | WCHAR squished_cc[GUID_SIZE]; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3285 | UINT rc; |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 3286 | DWORD i; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 3287 | HKEY hkey=0,hkey2=0; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3288 | static const WCHAR szProductCode[]= |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3289 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3290 | |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3291 | if (!package) |
| 3292 | return ERROR_INVALID_HANDLE; |
| 3293 | |
| 3294 | /* writes the Component and Features values to the registry */ |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3295 | productcode = load_dynamic_property(package,szProductCode,&rc); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3296 | if (!productcode) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3297 | return rc; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3298 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 3299 | rc = MSIREG_OpenComponents(&hkey); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3300 | if (rc != ERROR_SUCCESS) |
| 3301 | goto end; |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 3302 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 3303 | squash_guid(productcode,squished_pc); |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 3304 | ui_progress(package,1,COMPONENT_PROGRESS_VALUE,1,0); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3305 | for (i = 0; i < package->loaded_components; i++) |
| 3306 | { |
Aric Stewart | bd1bbc1 | 2005-01-03 20:00:13 +0000 | [diff] [blame] | 3307 | ui_progress(package,2,0,0,0); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3308 | if (package->components[i].ComponentId[0]!=0) |
| 3309 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3310 | WCHAR *keypath = NULL; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3311 | MSIRECORD * uirow; |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3312 | |
| 3313 | squash_guid(package->components[i].ComponentId,squished_cc); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 3314 | rc = RegCreateKeyW(hkey,squished_cc,&hkey2); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3315 | if (rc != ERROR_SUCCESS) |
| 3316 | continue; |
| 3317 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3318 | keypath = resolve_keypath(package,i); |
| 3319 | if (keypath) |
| 3320 | { |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 3321 | RegSetValueExW(hkey2,squished_pc,0,REG_SZ,(LPVOID)keypath, |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3322 | (strlenW(keypath)+1)*sizeof(WCHAR)); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 3323 | RegCloseKey(hkey2); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3324 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3325 | /* UI stuff */ |
| 3326 | uirow = MSI_CreateRecord(3); |
| 3327 | MSI_RecordSetStringW(uirow,1,productcode); |
| 3328 | MSI_RecordSetStringW(uirow,2,package->components[i]. |
| 3329 | ComponentId); |
| 3330 | MSI_RecordSetStringW(uirow,3,keypath); |
| 3331 | ui_actiondata(package,szProcessComponents,uirow); |
| 3332 | msiobj_release( &uirow->hdr ); |
| 3333 | HeapFree(GetProcessHeap(),0,keypath); |
| 3334 | } |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3335 | } |
| 3336 | } |
| 3337 | end: |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3338 | HeapFree(GetProcessHeap(), 0, productcode); |
Aric Stewart | b942e18 | 2004-07-06 18:50:02 +0000 | [diff] [blame] | 3339 | RegCloseKey(hkey); |
| 3340 | return rc; |
| 3341 | } |
| 3342 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3343 | static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package) |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3344 | { |
| 3345 | /* |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3346 | * 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] | 3347 | * 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] | 3348 | * of that component" which I interpret to mean "The file in the KeyPath of |
| 3349 | * that component". |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3350 | */ |
| 3351 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3352 | MSIQUERY * view; |
| 3353 | MSIRECORD * row = 0; |
| 3354 | static const WCHAR Query[] = { |
| 3355 | 'S','E','L','E','C','T',' ','*',' ', |
| 3356 | 'f','r','o','m',' ','T','y','p','e','L','i','b',0}; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3357 | ITypeLib *ptLib; |
| 3358 | HRESULT res; |
| 3359 | |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3360 | if (!package) |
| 3361 | return ERROR_INVALID_HANDLE; |
| 3362 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3363 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3364 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3365 | return ERROR_SUCCESS; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3366 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3367 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3368 | if (rc != ERROR_SUCCESS) |
| 3369 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3370 | MSI_ViewClose(view); |
| 3371 | msiobj_release(&view->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3372 | return rc; |
| 3373 | } |
| 3374 | |
| 3375 | while (1) |
| 3376 | { |
| 3377 | WCHAR component[0x100]; |
| 3378 | DWORD sz; |
| 3379 | INT index; |
| 3380 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3381 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3382 | if (rc != ERROR_SUCCESS) |
| 3383 | { |
| 3384 | rc = ERROR_SUCCESS; |
| 3385 | break; |
| 3386 | } |
| 3387 | |
| 3388 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3389 | MSI_RecordGetStringW(row,3,component,&sz); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3390 | |
| 3391 | index = get_loaded_component(package,component); |
| 3392 | if (index < 0) |
| 3393 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3394 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3395 | continue; |
| 3396 | } |
| 3397 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 3398 | if (package->components[index].ActionRequest != INSTALLSTATE_LOCAL) |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3399 | { |
| 3400 | TRACE("Skipping typelib reg due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3401 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3402 | continue; |
| 3403 | } |
| 3404 | |
| 3405 | index = get_loaded_file(package,package->components[index].KeyPath); |
| 3406 | |
| 3407 | if (index < 0) |
| 3408 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3409 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3410 | continue; |
| 3411 | } |
| 3412 | |
| 3413 | res = LoadTypeLib(package->files[index].TargetPath,&ptLib); |
| 3414 | if (SUCCEEDED(res)) |
| 3415 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3416 | LPWSTR help; |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3417 | WCHAR helpid[0x100]; |
| 3418 | |
| 3419 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3420 | MSI_RecordGetStringW(row,6,helpid,&sz); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3421 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3422 | help = resolve_folder(package,helpid,FALSE,FALSE,NULL); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3423 | res = RegisterTypeLib(ptLib,package->files[index].TargetPath,help); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3424 | HeapFree(GetProcessHeap(),0,help); |
| 3425 | |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3426 | if (!SUCCEEDED(res)) |
| 3427 | ERR("Failed to register type library %s\n", |
| 3428 | debugstr_w(package->files[index].TargetPath)); |
| 3429 | else |
| 3430 | { |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3431 | /* Yes the row has more fields than I need, but #1 is |
| 3432 | correct and the only one I need. Why make a new row? */ |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3433 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3434 | ui_actiondata(package,szRegisterTypeLibraries,row); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3435 | |
| 3436 | TRACE("Registered %s\n", |
| 3437 | debugstr_w(package->files[index].TargetPath)); |
| 3438 | } |
| 3439 | |
| 3440 | if (ptLib) |
| 3441 | ITypeLib_Release(ptLib); |
| 3442 | } |
| 3443 | else |
| 3444 | ERR("Failed to load type library %s\n", |
| 3445 | debugstr_w(package->files[index].TargetPath)); |
| 3446 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3447 | msiobj_release(&row->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3448 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3449 | MSI_ViewClose(view); |
| 3450 | msiobj_release(&view->hdr); |
Aric Stewart | fcb20c5 | 2004-07-06 18:51:16 +0000 | [diff] [blame] | 3451 | return rc; |
| 3452 | |
| 3453 | } |
| 3454 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3455 | static UINT register_appid(MSIPACKAGE *package, LPCWSTR clsid, LPCWSTR app ) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3456 | { |
| 3457 | static const WCHAR szAppID[] = { 'A','p','p','I','D',0 }; |
| 3458 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3459 | MSIQUERY * view; |
| 3460 | MSIRECORD * row = 0; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3461 | static const WCHAR ExecSeqQuery[] = |
Mike McCormack | 9db0e07 | 2004-12-22 15:05:07 +0000 | [diff] [blame] | 3462 | {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','p','p','I' |
| 3463 | ,'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] | 3464 | HKEY hkey2,hkey3; |
| 3465 | LPWSTR buffer=0; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3466 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3467 | if (!package) |
| 3468 | return ERROR_INVALID_HANDLE; |
| 3469 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 3470 | rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, clsid); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3471 | if (rc != ERROR_SUCCESS) |
| 3472 | return rc; |
| 3473 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3474 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3475 | if (rc != ERROR_SUCCESS) |
| 3476 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3477 | MSI_ViewClose(view); |
| 3478 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3479 | return rc; |
| 3480 | } |
| 3481 | |
| 3482 | RegCreateKeyW(HKEY_CLASSES_ROOT,szAppID,&hkey2); |
| 3483 | RegCreateKeyW(hkey2,clsid,&hkey3); |
| 3484 | RegSetValueExW(hkey3,NULL,0,REG_SZ,(LPVOID)app, |
| 3485 | (strlenW(app)+1)*sizeof(WCHAR)); |
| 3486 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3487 | rc = MSI_ViewFetch(view,&row); |
| 3488 | if (rc != ERROR_SUCCESS) |
| 3489 | { |
| 3490 | MSI_ViewClose(view); |
| 3491 | msiobj_release(&view->hdr); |
| 3492 | return rc; |
| 3493 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3494 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3495 | if (!MSI_RecordIsNull(row,2)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3496 | { |
| 3497 | LPWSTR deformated=0; |
| 3498 | UINT size; |
| 3499 | static const WCHAR szRemoteServerName[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3500 | {'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] | 3501 | buffer = load_dynamic_stringW(row,2); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3502 | size = deformat_string(package,buffer,&deformated); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3503 | RegSetValueExW(hkey3,szRemoteServerName,0,REG_SZ,(LPVOID)deformated, |
| 3504 | size); |
| 3505 | HeapFree(GetProcessHeap(),0,deformated); |
| 3506 | HeapFree(GetProcessHeap(),0,buffer); |
| 3507 | } |
| 3508 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3509 | if (!MSI_RecordIsNull(row,3)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3510 | { |
| 3511 | static const WCHAR szLocalService[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3512 | {'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] | 3513 | UINT size; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3514 | buffer = load_dynamic_stringW(row,3); |
| 3515 | size = (strlenW(buffer)+1) * sizeof(WCHAR); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3516 | RegSetValueExW(hkey3,szLocalService,0,REG_SZ,(LPVOID)buffer,size); |
| 3517 | HeapFree(GetProcessHeap(),0,buffer); |
| 3518 | } |
| 3519 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3520 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3521 | { |
| 3522 | static const WCHAR szService[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3523 | {'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] | 3524 | UINT size; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3525 | buffer = load_dynamic_stringW(row,4); |
| 3526 | size = (strlenW(buffer)+1) * sizeof(WCHAR); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3527 | RegSetValueExW(hkey3,szService,0,REG_SZ,(LPVOID)buffer,size); |
| 3528 | HeapFree(GetProcessHeap(),0,buffer); |
| 3529 | } |
| 3530 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3531 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3532 | { |
| 3533 | static const WCHAR szDLL[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3534 | {'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] | 3535 | UINT size; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3536 | buffer = load_dynamic_stringW(row,5); |
| 3537 | size = (strlenW(buffer)+1) * sizeof(WCHAR); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3538 | RegSetValueExW(hkey3,szDLL,0,REG_SZ,(LPVOID)buffer,size); |
| 3539 | HeapFree(GetProcessHeap(),0,buffer); |
| 3540 | } |
| 3541 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3542 | if (!MSI_RecordIsNull(row,6)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3543 | { |
| 3544 | static const WCHAR szActivate[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3545 | {'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] | 3546 | static const WCHAR szY[] = {'Y',0}; |
| 3547 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3548 | if (MSI_RecordGetInteger(row,6)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3549 | RegSetValueExW(hkey3,szActivate,0,REG_SZ,(LPVOID)szY,4); |
| 3550 | } |
| 3551 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3552 | if (!MSI_RecordIsNull(row,7)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3553 | { |
| 3554 | static const WCHAR szRunAs[] = {'R','u','n','A','s',0}; |
| 3555 | static const WCHAR szUser[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3556 | {'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] | 3557 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3558 | if (MSI_RecordGetInteger(row,7)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3559 | RegSetValueExW(hkey3,szRunAs,0,REG_SZ,(LPVOID)szUser,34); |
| 3560 | } |
| 3561 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3562 | msiobj_release(&row->hdr); |
| 3563 | MSI_ViewClose(view); |
| 3564 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3565 | RegCloseKey(hkey3); |
| 3566 | RegCloseKey(hkey2); |
| 3567 | return rc; |
| 3568 | } |
| 3569 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3570 | static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3571 | { |
| 3572 | /* |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 3573 | * Again I am assuming the words, "Whose key file represents" when referring |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3574 | * to a Component as to meaning that Components KeyPath file |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3575 | * |
| 3576 | * Also there is a very strong connection between ClassInfo and ProgID |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 3577 | * that I am mostly glossing over. |
| 3578 | * 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] | 3579 | * into memory data structures and then be able to enable and disable them |
| 3580 | * based on component. |
| 3581 | */ |
| 3582 | |
| 3583 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3584 | MSIQUERY * view; |
| 3585 | MSIRECORD * row = 0; |
| 3586 | static const WCHAR ExecSeqQuery[] = { |
| 3587 | 'S','E','L','E','C','T',' ','*',' ', |
| 3588 | 'f','r','o','m',' ','C','l','a','s','s',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3589 | static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; |
| 3590 | static const WCHAR szProgID[] = { 'P','r','o','g','I','D',0 }; |
| 3591 | static const WCHAR szAppID[] = { 'A','p','p','I','D',0 }; |
| 3592 | HKEY hkey,hkey2,hkey3; |
| 3593 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3594 | if (!package) |
| 3595 | return ERROR_INVALID_HANDLE; |
| 3596 | |
| 3597 | rc = RegCreateKeyW(HKEY_CLASSES_ROOT,szCLSID,&hkey); |
| 3598 | if (rc != ERROR_SUCCESS) |
| 3599 | return ERROR_FUNCTION_FAILED; |
| 3600 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3601 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3602 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3603 | { |
| 3604 | rc = ERROR_SUCCESS; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3605 | goto end; |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3606 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3607 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3608 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3609 | if (rc != ERROR_SUCCESS) |
| 3610 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3611 | MSI_ViewClose(view); |
| 3612 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3613 | goto end; |
| 3614 | } |
| 3615 | |
| 3616 | while (1) |
| 3617 | { |
| 3618 | WCHAR clsid[0x100]; |
| 3619 | WCHAR buffer[0x100]; |
| 3620 | WCHAR desc[0x100]; |
| 3621 | DWORD sz; |
| 3622 | INT index; |
| 3623 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3624 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3625 | if (rc != ERROR_SUCCESS) |
| 3626 | { |
| 3627 | rc = ERROR_SUCCESS; |
| 3628 | break; |
| 3629 | } |
| 3630 | |
| 3631 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3632 | MSI_RecordGetStringW(row,3,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3633 | |
| 3634 | index = get_loaded_component(package,buffer); |
| 3635 | |
| 3636 | if (index < 0) |
| 3637 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3638 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3639 | continue; |
| 3640 | } |
| 3641 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 3642 | if (package->components[index].ActionRequest != INSTALLSTATE_LOCAL) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3643 | { |
| 3644 | TRACE("Skipping class reg due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3645 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3646 | continue; |
| 3647 | } |
| 3648 | |
| 3649 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3650 | MSI_RecordGetStringW(row,1,clsid,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3651 | RegCreateKeyW(hkey,clsid,&hkey2); |
| 3652 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3653 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3654 | { |
| 3655 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3656 | MSI_RecordGetStringW(row,5,desc,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3657 | |
| 3658 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)desc, |
| 3659 | (strlenW(desc)+1)*sizeof(WCHAR)); |
| 3660 | } |
| 3661 | else |
| 3662 | desc[0]=0; |
| 3663 | |
| 3664 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3665 | MSI_RecordGetStringW(row,2,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3666 | |
| 3667 | RegCreateKeyW(hkey2,buffer,&hkey3); |
| 3668 | |
| 3669 | index = get_loaded_file(package,package->components[index].KeyPath); |
| 3670 | RegSetValueExW(hkey3,NULL,0,REG_SZ, |
| 3671 | (LPVOID)package->files[index].TargetPath, |
| 3672 | (strlenW(package->files[index].TargetPath)+1) |
| 3673 | *sizeof(WCHAR)); |
| 3674 | |
| 3675 | RegCloseKey(hkey3); |
| 3676 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3677 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3678 | { |
| 3679 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3680 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3681 | |
| 3682 | RegCreateKeyW(hkey2,szProgID,&hkey3); |
| 3683 | |
| 3684 | RegSetValueExW(hkey3,NULL,0,REG_SZ,(LPVOID)buffer, |
| 3685 | (strlenW(buffer)+1)*sizeof(WCHAR)); |
| 3686 | |
| 3687 | RegCloseKey(hkey3); |
| 3688 | } |
| 3689 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3690 | if (!MSI_RecordIsNull(row,6)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3691 | { |
| 3692 | sz=0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3693 | MSI_RecordGetStringW(row,6,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3694 | |
| 3695 | RegSetValueExW(hkey2,szAppID,0,REG_SZ,(LPVOID)buffer, |
| 3696 | (strlenW(buffer)+1)*sizeof(WCHAR)); |
| 3697 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3698 | register_appid(package,buffer,desc); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3699 | } |
| 3700 | |
| 3701 | RegCloseKey(hkey2); |
| 3702 | |
| 3703 | FIXME("Process the rest of the fields >7\n"); |
| 3704 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3705 | ui_actiondata(package,szRegisterClassInfo,row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3706 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3707 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3708 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3709 | MSI_ViewClose(view); |
| 3710 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3711 | |
| 3712 | end: |
| 3713 | RegCloseKey(hkey); |
| 3714 | return rc; |
| 3715 | } |
| 3716 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3717 | static UINT register_progid_base(MSIPACKAGE* package, MSIRECORD * row, |
| 3718 | LPWSTR clsid) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3719 | { |
| 3720 | static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3721 | static const WCHAR szDefaultIcon[] = { |
| 3722 | 'D','e','f','a','u','l','t','I','c','o','n',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3723 | HKEY hkey,hkey2; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3724 | WCHAR buffer[0x100]; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3725 | DWORD sz; |
| 3726 | |
| 3727 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3728 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3729 | MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3730 | RegCreateKeyW(HKEY_CLASSES_ROOT,buffer,&hkey); |
| 3731 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3732 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3733 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3734 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3735 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3736 | RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) * |
| 3737 | sizeof(WCHAR)); |
| 3738 | } |
| 3739 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3740 | if (!MSI_RecordIsNull(row,3)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3741 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3742 | sz = 0x100; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3743 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3744 | MSI_RecordGetStringW(row,3,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3745 | RegCreateKeyW(hkey,szCLSID,&hkey2); |
| 3746 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) * |
| 3747 | sizeof(WCHAR)); |
| 3748 | |
| 3749 | if (clsid) |
| 3750 | strcpyW(clsid,buffer); |
| 3751 | |
| 3752 | RegCloseKey(hkey2); |
| 3753 | } |
| 3754 | else |
| 3755 | { |
| 3756 | FIXME("UNHANDLED case, Parent progid but classid is NULL\n"); |
| 3757 | return ERROR_FUNCTION_FAILED; |
| 3758 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3759 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3760 | { |
| 3761 | INT index = MSI_RecordGetInteger(row,6); |
| 3762 | LPWSTR FileName = load_dynamic_stringW(row,5); |
| 3763 | LPWSTR FilePath,IconPath; |
| 3764 | static const WCHAR fmt[] = {'%','s',',','%','i',0}; |
| 3765 | |
| 3766 | RegCreateKeyW(hkey,szDefaultIcon,&hkey2); |
| 3767 | build_icon_path(package,FileName,&FilePath); |
| 3768 | |
| 3769 | IconPath = HeapAlloc(GetProcessHeap(),0,(strlenW(FilePath)+5)* |
| 3770 | sizeof(WCHAR)); |
| 3771 | |
| 3772 | sprintfW(IconPath,fmt,FilePath,index); |
| 3773 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)IconPath, |
| 3774 | (strlenW(IconPath)+1) * sizeof(WCHAR)); |
| 3775 | HeapFree(GetProcessHeap(),0,FilePath); |
| 3776 | HeapFree(GetProcessHeap(),0,FileName); |
| 3777 | RegCloseKey(hkey2); |
| 3778 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3779 | return ERROR_SUCCESS; |
| 3780 | } |
| 3781 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3782 | static UINT register_progid(MSIPACKAGE *package, MSIRECORD * row, LPWSTR clsid); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3783 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3784 | static UINT register_parent_progid(MSIPACKAGE *package, LPCWSTR parent, |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3785 | LPWSTR clsid) |
| 3786 | { |
| 3787 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3788 | MSIQUERY * view; |
| 3789 | MSIRECORD * row = 0; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3790 | static const WCHAR Query_t[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3791 | {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','P','r','o','g' |
| 3792 | ,'I','d',' ','w','h','e','r','e',' ','P','r','o','g','I','d',' ','=',' ','`' |
| 3793 | ,'%','s','`',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3794 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3795 | if (!package) |
| 3796 | return ERROR_INVALID_HANDLE; |
| 3797 | |
Mike McCormack | 0c23885 | 2005-01-21 16:19:11 +0000 | [diff] [blame] | 3798 | rc = MSI_OpenQuery(package->db, &view, Query_t, parent); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3799 | if (rc != ERROR_SUCCESS) |
| 3800 | return rc; |
| 3801 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3802 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3803 | if (rc != ERROR_SUCCESS) |
| 3804 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3805 | MSI_ViewClose(view); |
| 3806 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3807 | return rc; |
| 3808 | } |
| 3809 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3810 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3811 | if (rc != ERROR_SUCCESS) |
| 3812 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3813 | MSI_ViewClose(view); |
| 3814 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3815 | return rc; |
| 3816 | } |
| 3817 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3818 | register_progid(package,row,clsid); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3819 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3820 | msiobj_release(&row->hdr); |
| 3821 | MSI_ViewClose(view); |
| 3822 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3823 | return rc; |
| 3824 | } |
| 3825 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3826 | static UINT register_progid(MSIPACKAGE *package, MSIRECORD * row, LPWSTR clsid) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3827 | { |
| 3828 | UINT rc = ERROR_SUCCESS; |
| 3829 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3830 | if (MSI_RecordIsNull(row,2)) |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3831 | rc = register_progid_base(package,row,clsid); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3832 | else |
| 3833 | { |
| 3834 | WCHAR buffer[0x1000]; |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 3835 | DWORD sz, disp; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3836 | HKEY hkey,hkey2; |
| 3837 | static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3838 | static const WCHAR szDefaultIcon[] = { |
| 3839 | 'D','e','f','a','u','l','t','I','c','o','n',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3840 | |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 3841 | /* check if already registered */ |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3842 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3843 | MSI_RecordGetStringW(row,1,buffer,&sz); |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 3844 | RegCreateKeyExW(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, |
| 3845 | KEY_ALL_ACCESS, NULL, &hkey, &disp ); |
| 3846 | if (disp == REG_OPENED_EXISTING_KEY) |
| 3847 | { |
| 3848 | TRACE("Key already registered\n"); |
| 3849 | RegCloseKey(hkey); |
| 3850 | return rc; |
| 3851 | } |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3852 | |
| 3853 | sz = 0x100; |
| 3854 | MSI_RecordGetStringW(row,2,buffer,&sz); |
| 3855 | rc = register_parent_progid(package,buffer,clsid); |
| 3856 | |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 3857 | /* clsid is same as parent */ |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3858 | RegCreateKeyW(hkey,szCLSID,&hkey2); |
| 3859 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)clsid, (strlenW(clsid)+1) * |
| 3860 | sizeof(WCHAR)); |
| 3861 | |
| 3862 | RegCloseKey(hkey2); |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 3863 | |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 3864 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3865 | if (!MSI_RecordIsNull(row,4)) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3866 | { |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 3867 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3868 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3869 | RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, |
| 3870 | (strlenW(buffer)+1) * sizeof(WCHAR)); |
| 3871 | } |
| 3872 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3873 | if (!MSI_RecordIsNull(row,5)) |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 3874 | { |
| 3875 | LPWSTR FileName = load_dynamic_stringW(row,5); |
| 3876 | LPWSTR FilePath; |
| 3877 | RegCreateKeyW(hkey,szDefaultIcon,&hkey2); |
| 3878 | build_icon_path(package,FileName,&FilePath); |
| 3879 | RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)FilePath, |
| 3880 | (strlenW(FilePath)+1) * sizeof(WCHAR)); |
| 3881 | HeapFree(GetProcessHeap(),0,FilePath); |
| 3882 | HeapFree(GetProcessHeap(),0,FileName); |
| 3883 | RegCloseKey(hkey2); |
| 3884 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3885 | |
| 3886 | RegCloseKey(hkey); |
| 3887 | } |
| 3888 | return rc; |
| 3889 | } |
| 3890 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3891 | static UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package) |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3892 | { |
| 3893 | /* |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3894 | * Sigh, here I am just brute force registering all progids |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 3895 | * this needs to be linked to the Classes that have been registered |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3896 | * but the easiest way to do that is to load all these stuff into |
| 3897 | * memory for easy checking. |
| 3898 | * |
Mike McCormack | c90c781 | 2004-07-09 22:58:27 +0000 | [diff] [blame] | 3899 | * Gives me something to continue to work toward. |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3900 | */ |
| 3901 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3902 | MSIQUERY * view; |
| 3903 | MSIRECORD * row = 0; |
| 3904 | static const WCHAR Query[] = { |
| 3905 | 'S','E','L','E','C','T',' ','*',' ', |
| 3906 | 'F','R','O','M',' ','P','r','o','g','I','d',0}; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3907 | |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3908 | if (!package) |
| 3909 | return ERROR_INVALID_HANDLE; |
| 3910 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3911 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3912 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 3913 | return ERROR_SUCCESS; |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3914 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3915 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3916 | if (rc != ERROR_SUCCESS) |
| 3917 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3918 | MSI_ViewClose(view); |
| 3919 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3920 | return rc; |
| 3921 | } |
| 3922 | |
| 3923 | while (1) |
| 3924 | { |
| 3925 | WCHAR clsid[0x1000]; |
| 3926 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3927 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3928 | if (rc != ERROR_SUCCESS) |
| 3929 | { |
| 3930 | rc = ERROR_SUCCESS; |
| 3931 | break; |
| 3932 | } |
| 3933 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3934 | register_progid(package,row,clsid); |
| 3935 | ui_actiondata(package,szRegisterProgIdInfo,row); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3936 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3937 | msiobj_release(&row->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3938 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3939 | MSI_ViewClose(view); |
| 3940 | msiobj_release(&view->hdr); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 3941 | return rc; |
| 3942 | } |
| 3943 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3944 | static UINT build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name, |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3945 | LPWSTR *FilePath) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3946 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3947 | LPWSTR ProductCode; |
| 3948 | LPWSTR SystemFolder; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3949 | LPWSTR dest; |
| 3950 | UINT rc; |
| 3951 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3952 | static const WCHAR szInstaller[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3953 | {'I','n','s','t','a','l','l','e','r','\\',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3954 | static const WCHAR szProductCode[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3955 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3956 | static const WCHAR szFolder[] = |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3957 | {'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] | 3958 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3959 | ProductCode = load_dynamic_property(package,szProductCode,&rc); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3960 | if (!ProductCode) |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3961 | return rc; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3962 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3963 | SystemFolder = load_dynamic_property(package,szFolder,NULL); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3964 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3965 | dest = build_directory_name(3, SystemFolder, szInstaller, ProductCode); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3966 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3967 | create_full_pathW(dest); |
| 3968 | |
| 3969 | *FilePath = build_directory_name(2, dest, icon_name); |
| 3970 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 3971 | HeapFree(GetProcessHeap(),0,SystemFolder); |
| 3972 | HeapFree(GetProcessHeap(),0,ProductCode); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 3973 | HeapFree(GetProcessHeap(),0,dest); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3974 | return ERROR_SUCCESS; |
| 3975 | } |
| 3976 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3977 | static UINT ACTION_CreateShortcuts(MSIPACKAGE *package) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3978 | { |
| 3979 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3980 | MSIQUERY * view; |
| 3981 | MSIRECORD * row = 0; |
| 3982 | static const WCHAR Query[] = { |
| 3983 | 'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ', |
| 3984 | 'S','h','o','r','t','c','u','t',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3985 | IShellLinkW *sl; |
| 3986 | IPersistFile *pf; |
| 3987 | HRESULT res; |
| 3988 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 3989 | if (!package) |
| 3990 | return ERROR_INVALID_HANDLE; |
| 3991 | |
| 3992 | res = CoInitialize( NULL ); |
| 3993 | if (FAILED (res)) |
| 3994 | { |
| 3995 | ERR("CoInitialize failed\n"); |
| 3996 | return ERROR_FUNCTION_FAILED; |
| 3997 | } |
| 3998 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 3999 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4000 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 84837d9 | 2004-07-20 01:22:37 +0000 | [diff] [blame] | 4001 | return ERROR_SUCCESS; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4002 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4003 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4004 | if (rc != ERROR_SUCCESS) |
| 4005 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4006 | MSI_ViewClose(view); |
| 4007 | msiobj_release(&view->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4008 | return rc; |
| 4009 | } |
| 4010 | |
| 4011 | while (1) |
| 4012 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4013 | LPWSTR target_file, target_folder; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4014 | WCHAR buffer[0x100]; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4015 | DWORD sz; |
| 4016 | DWORD index; |
| 4017 | static const WCHAR szlnk[]={'.','l','n','k',0}; |
| 4018 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4019 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4020 | if (rc != ERROR_SUCCESS) |
| 4021 | { |
| 4022 | rc = ERROR_SUCCESS; |
| 4023 | break; |
| 4024 | } |
| 4025 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4026 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4027 | MSI_RecordGetStringW(row,4,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4028 | |
| 4029 | index = get_loaded_component(package,buffer); |
| 4030 | |
| 4031 | if (index < 0) |
| 4032 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4033 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4034 | continue; |
| 4035 | } |
| 4036 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 4037 | if (package->components[index].ActionRequest != INSTALLSTATE_LOCAL) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4038 | { |
| 4039 | TRACE("Skipping shortcut creation due to disabled component\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4040 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4041 | continue; |
| 4042 | } |
| 4043 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4044 | ui_actiondata(package,szCreateShortcuts,row); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4045 | |
| 4046 | res = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, |
| 4047 | &IID_IShellLinkW, (LPVOID *) &sl ); |
| 4048 | |
| 4049 | if (FAILED(res)) |
| 4050 | { |
| 4051 | ERR("Is IID_IShellLink\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4052 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4053 | continue; |
| 4054 | } |
| 4055 | |
| 4056 | res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf ); |
| 4057 | if( FAILED( res ) ) |
| 4058 | { |
| 4059 | ERR("Is IID_IPersistFile\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4060 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4061 | continue; |
| 4062 | } |
| 4063 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4064 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4065 | MSI_RecordGetStringW(row,2,buffer,&sz); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4066 | target_folder = resolve_folder(package, buffer,FALSE,FALSE,NULL); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4067 | |
Aric Stewart | 8cc14a9 | 2004-12-27 18:56:30 +0000 | [diff] [blame] | 4068 | /* may be needed because of a bug somehwere else */ |
| 4069 | create_full_pathW(target_folder); |
| 4070 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4071 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4072 | MSI_RecordGetStringW(row,3,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4073 | reduce_to_longfilename(buffer); |
Aric Stewart | 00e1ecd | 2005-01-05 17:13:12 +0000 | [diff] [blame] | 4074 | if (!strchrW(buffer,'.') || strcmpiW(strchrW(buffer,'.'),szlnk)) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4075 | strcatW(buffer,szlnk); |
| 4076 | target_file = build_directory_name(2, target_folder, buffer); |
| 4077 | HeapFree(GetProcessHeap(),0,target_folder); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4078 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4079 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4080 | MSI_RecordGetStringW(row,5,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4081 | if (strchrW(buffer,'[')) |
| 4082 | { |
| 4083 | LPWSTR deformated; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4084 | deformat_string(package,buffer,&deformated); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4085 | IShellLinkW_SetPath(sl,deformated); |
| 4086 | HeapFree(GetProcessHeap(),0,deformated); |
| 4087 | } |
| 4088 | else |
| 4089 | { |
| 4090 | FIXME("UNHANDLED shortcut format, advertised shortcut\n"); |
| 4091 | IPersistFile_Release( pf ); |
| 4092 | IShellLinkW_Release( sl ); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4093 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4094 | continue; |
| 4095 | } |
| 4096 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4097 | if (!MSI_RecordIsNull(row,6)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4098 | { |
| 4099 | LPWSTR deformated; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4100 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4101 | MSI_RecordGetStringW(row,6,buffer,&sz); |
| 4102 | deformat_string(package,buffer,&deformated); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4103 | IShellLinkW_SetArguments(sl,deformated); |
| 4104 | HeapFree(GetProcessHeap(),0,deformated); |
| 4105 | } |
| 4106 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4107 | if (!MSI_RecordIsNull(row,7)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4108 | { |
| 4109 | LPWSTR deformated; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4110 | deformated = load_dynamic_stringW(row,7); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4111 | IShellLinkW_SetDescription(sl,deformated); |
| 4112 | HeapFree(GetProcessHeap(),0,deformated); |
| 4113 | } |
| 4114 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4115 | if (!MSI_RecordIsNull(row,8)) |
| 4116 | IShellLinkW_SetHotkey(sl,MSI_RecordGetInteger(row,8)); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4117 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4118 | if (!MSI_RecordIsNull(row,9)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4119 | { |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4120 | WCHAR *Path = NULL; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4121 | INT index; |
| 4122 | |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4123 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4124 | MSI_RecordGetStringW(row,9,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4125 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4126 | build_icon_path(package,buffer,&Path); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4127 | index = MSI_RecordGetInteger(row,10); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4128 | |
| 4129 | IShellLinkW_SetIconLocation(sl,Path,index); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4130 | HeapFree(GetProcessHeap(),0,Path); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4131 | } |
| 4132 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4133 | if (!MSI_RecordIsNull(row,11)) |
| 4134 | IShellLinkW_SetShowCmd(sl,MSI_RecordGetInteger(row,11)); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4135 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4136 | if (!MSI_RecordIsNull(row,12)) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4137 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4138 | LPWSTR Path; |
Aric Stewart | 7231a43 | 2004-07-09 19:26:30 +0000 | [diff] [blame] | 4139 | sz = 0x100; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4140 | MSI_RecordGetStringW(row,12,buffer,&sz); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4141 | Path = resolve_folder(package, buffer, FALSE, FALSE, NULL); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4142 | IShellLinkW_SetWorkingDirectory(sl,Path); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4143 | HeapFree(GetProcessHeap(), 0, Path); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4144 | } |
| 4145 | |
| 4146 | TRACE("Writing shortcut to %s\n",debugstr_w(target_file)); |
| 4147 | IPersistFile_Save(pf,target_file,FALSE); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4148 | |
| 4149 | HeapFree(GetProcessHeap(),0,target_file); |
| 4150 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4151 | IPersistFile_Release( pf ); |
| 4152 | IShellLinkW_Release( sl ); |
| 4153 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4154 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4155 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4156 | MSI_ViewClose(view); |
| 4157 | msiobj_release(&view->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4158 | |
| 4159 | |
| 4160 | CoUninitialize(); |
| 4161 | |
| 4162 | return rc; |
| 4163 | } |
| 4164 | |
| 4165 | |
| 4166 | /* |
| 4167 | * 99% of the work done here is only done for |
| 4168 | * advertised installs. However this is where the |
| 4169 | * Icon table is processed and written out |
Francois Gouget | 817c520 | 2004-07-16 19:15:40 +0000 | [diff] [blame] | 4170 | * so that is what I am going to do here. |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4171 | */ |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4172 | static UINT ACTION_PublishProduct(MSIPACKAGE *package) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4173 | { |
| 4174 | UINT rc; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4175 | MSIQUERY * view; |
| 4176 | MSIRECORD * row = 0; |
| 4177 | static const WCHAR Query[]={ |
| 4178 | 'S','E','L','E','C','T',' ','*',' ', |
| 4179 | 'f','r','o','m',' ','I','c','o','n',0}; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4180 | DWORD sz; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4181 | /* for registry stuff */ |
| 4182 | LPWSTR productcode; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4183 | HKEY hkey=0; |
| 4184 | HKEY hukey=0; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4185 | static const WCHAR szProductCode[]= |
| 4186 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4187 | static const WCHAR szProductName[] = { |
| 4188 | 'P','r','o','d','u','c','t','N','a','m','e',0}; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4189 | static const WCHAR szPackageCode[] = { |
| 4190 | 'P','a','c','k','a','g','e','C','o','d','e',0}; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4191 | LPWSTR buffer; |
| 4192 | DWORD size; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4193 | MSIHANDLE hDb, hSumInfo; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4194 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4195 | if (!package) |
| 4196 | return ERROR_INVALID_HANDLE; |
| 4197 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4198 | rc = MSI_DatabaseOpenViewW(package->db, Query, &view); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4199 | if (rc != ERROR_SUCCESS) |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4200 | goto next; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4201 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4202 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4203 | if (rc != ERROR_SUCCESS) |
| 4204 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4205 | MSI_ViewClose(view); |
| 4206 | msiobj_release(&view->hdr); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4207 | goto next; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4208 | } |
| 4209 | |
| 4210 | while (1) |
| 4211 | { |
| 4212 | HANDLE the_file; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4213 | WCHAR *FilePath=NULL; |
| 4214 | WCHAR *FileName=NULL; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4215 | CHAR buffer[1024]; |
| 4216 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4217 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4218 | if (rc != ERROR_SUCCESS) |
| 4219 | { |
| 4220 | rc = ERROR_SUCCESS; |
| 4221 | break; |
| 4222 | } |
| 4223 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4224 | FileName = load_dynamic_stringW(row,1); |
| 4225 | if (!FileName) |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4226 | { |
| 4227 | ERR("Unable to get FileName\n"); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4228 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4229 | continue; |
| 4230 | } |
| 4231 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4232 | build_icon_path(package,FileName,&FilePath); |
| 4233 | |
| 4234 | HeapFree(GetProcessHeap(),0,FileName); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4235 | |
| 4236 | TRACE("Creating icon file at %s\n",debugstr_w(FilePath)); |
| 4237 | |
| 4238 | the_file = CreateFileW(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, |
| 4239 | FILE_ATTRIBUTE_NORMAL, NULL); |
| 4240 | |
| 4241 | if (the_file == INVALID_HANDLE_VALUE) |
| 4242 | { |
| 4243 | ERR("Unable to create file %s\n",debugstr_w(FilePath)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4244 | msiobj_release(&row->hdr); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4245 | HeapFree(GetProcessHeap(),0,FilePath); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4246 | continue; |
| 4247 | } |
| 4248 | |
| 4249 | do |
| 4250 | { |
| 4251 | DWORD write; |
| 4252 | sz = 1024; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4253 | rc = MSI_RecordReadStream(row,2,buffer,&sz); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4254 | if (rc != ERROR_SUCCESS) |
| 4255 | { |
| 4256 | ERR("Failed to get stream\n"); |
| 4257 | CloseHandle(the_file); |
| 4258 | DeleteFileW(FilePath); |
| 4259 | break; |
| 4260 | } |
| 4261 | WriteFile(the_file,buffer,sz,&write,NULL); |
| 4262 | } while (sz == 1024); |
| 4263 | |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4264 | HeapFree(GetProcessHeap(),0,FilePath); |
| 4265 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4266 | CloseHandle(the_file); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4267 | msiobj_release(&row->hdr); |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4268 | } |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4269 | MSI_ViewClose(view); |
| 4270 | msiobj_release(&view->hdr); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4271 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4272 | next: |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4273 | /* ok there is alot more done here but i need to figure out what */ |
| 4274 | productcode = load_dynamic_property(package,szProductCode,&rc); |
| 4275 | if (!productcode) |
| 4276 | return rc; |
| 4277 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4278 | rc = MSIREG_OpenProductsKey(productcode,&hkey,TRUE); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4279 | if (rc != ERROR_SUCCESS) |
| 4280 | goto end; |
| 4281 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4282 | rc = MSIREG_OpenUserProductsKey(productcode,&hukey,TRUE); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4283 | if (rc != ERROR_SUCCESS) |
| 4284 | goto end; |
| 4285 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4286 | |
| 4287 | buffer = load_dynamic_property(package,szProductName,NULL); |
| 4288 | size = strlenW(buffer)*sizeof(WCHAR); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4289 | RegSetValueExW(hukey,szProductName,0,REG_SZ, (LPSTR)buffer,size); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4290 | HeapFree(GetProcessHeap(),0,buffer); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4291 | FIXME("Need to write more keys to the user registry\n"); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4292 | |
| 4293 | hDb= msiobj_findhandle( &package->db->hdr ); |
| 4294 | rc = MsiGetSummaryInformationW(hDb, NULL, 0, &hSumInfo); |
| 4295 | if (rc == ERROR_SUCCESS) |
| 4296 | { |
| 4297 | WCHAR guidbuffer[0x200]; |
| 4298 | size = 0x200; |
| 4299 | rc = MsiSummaryInfoGetPropertyW(hSumInfo, 8, NULL, NULL, NULL, |
| 4300 | guidbuffer, &size); |
| 4301 | if (rc == ERROR_SUCCESS) |
| 4302 | { |
| 4303 | WCHAR squashed[GUID_SIZE]; |
| 4304 | /* for now we only care about the first guid */ |
| 4305 | LPWSTR ptr = strchrW(guidbuffer,';'); |
| 4306 | if (ptr) *ptr = 0; |
| 4307 | squash_guid(guidbuffer,squashed); |
| 4308 | size = strlenW(guidbuffer)*sizeof(WCHAR); |
| 4309 | RegSetValueExW(hukey,szPackageCode,0,REG_SZ, (LPSTR)guidbuffer, |
| 4310 | size); |
| 4311 | |
| 4312 | } |
| 4313 | else |
| 4314 | { |
| 4315 | ERR("Unable to query Revision_Number... \n"); |
| 4316 | rc = ERROR_SUCCESS; |
| 4317 | } |
| 4318 | MsiCloseHandle(hSumInfo); |
| 4319 | } |
| 4320 | else |
| 4321 | { |
| 4322 | ERR("Unable to open Summary Information\n"); |
| 4323 | rc = ERROR_SUCCESS; |
| 4324 | } |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4325 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4326 | end: |
| 4327 | |
| 4328 | HeapFree(GetProcessHeap(),0,productcode); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4329 | RegCloseKey(hkey); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4330 | RegCloseKey(hukey); |
| 4331 | |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4332 | return rc; |
Aric Stewart | 2cf222f | 2004-07-06 19:00:23 +0000 | [diff] [blame] | 4333 | } |
| 4334 | |
Aric Stewart | 516a9c7 | 2005-01-14 15:59:26 +0000 | [diff] [blame] | 4335 | static UINT ACTION_WriteIniValues(MSIPACKAGE *package) |
| 4336 | { |
| 4337 | UINT rc; |
| 4338 | MSIQUERY * view; |
| 4339 | MSIRECORD * row = 0; |
| 4340 | static const WCHAR ExecSeqQuery[] = {'S','e','l','e','c','t',' ','*', |
| 4341 | ' ','f','r','o','m',' ','I','n','i','F','i','l','e',0}; |
| 4342 | static const WCHAR szWindowsFolder[] = |
| 4343 | {'W','i','n','d','o','w','s','F','o','l','d','e','r',0}; |
| 4344 | static const WCHAR szbs[] = {'\\',0}; |
| 4345 | |
| 4346 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
| 4347 | if (rc != ERROR_SUCCESS) |
| 4348 | { |
| 4349 | TRACE("no IniFile table\n"); |
| 4350 | return ERROR_SUCCESS; |
| 4351 | } |
| 4352 | |
| 4353 | rc = MSI_ViewExecute(view, 0); |
| 4354 | if (rc != ERROR_SUCCESS) |
| 4355 | { |
| 4356 | MSI_ViewClose(view); |
| 4357 | msiobj_release(&view->hdr); |
| 4358 | return rc; |
| 4359 | } |
| 4360 | |
| 4361 | while (1) |
| 4362 | { |
| 4363 | LPWSTR component,filename,dirproperty,section,key,value,identifier; |
| 4364 | LPWSTR deformated_section, deformated_key, deformated_value; |
| 4365 | LPWSTR folder, fullname = NULL; |
| 4366 | MSIRECORD * uirow; |
| 4367 | INT component_index,action; |
| 4368 | |
| 4369 | rc = MSI_ViewFetch(view,&row); |
| 4370 | if (rc != ERROR_SUCCESS) |
| 4371 | { |
| 4372 | rc = ERROR_SUCCESS; |
| 4373 | break; |
| 4374 | } |
| 4375 | |
| 4376 | component = load_dynamic_stringW(row, 8); |
| 4377 | component_index = get_loaded_component(package,component); |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 4378 | HeapFree(GetProcessHeap(),0,component); |
Aric Stewart | 516a9c7 | 2005-01-14 15:59:26 +0000 | [diff] [blame] | 4379 | |
| 4380 | if (package->components[component_index].ActionRequest != |
| 4381 | INSTALLSTATE_LOCAL) |
| 4382 | { |
| 4383 | TRACE("Skipping ini file due to disabled component\n"); |
| 4384 | msiobj_release(&row->hdr); |
| 4385 | continue; |
| 4386 | } |
| 4387 | |
| 4388 | identifier = load_dynamic_stringW(row,1); |
| 4389 | filename = load_dynamic_stringW(row,2); |
| 4390 | dirproperty = load_dynamic_stringW(row,3); |
| 4391 | section = load_dynamic_stringW(row,4); |
| 4392 | key = load_dynamic_stringW(row,5); |
| 4393 | value = load_dynamic_stringW(row,6); |
| 4394 | action = MSI_RecordGetInteger(row,7); |
| 4395 | |
| 4396 | deformat_string(package,section,&deformated_section); |
| 4397 | deformat_string(package,key,&deformated_key); |
| 4398 | deformat_string(package,value,&deformated_value); |
| 4399 | |
| 4400 | if (dirproperty) |
| 4401 | { |
| 4402 | folder = resolve_folder(package, dirproperty, FALSE, FALSE, NULL); |
| 4403 | if (!folder) |
| 4404 | folder = load_dynamic_property(package,dirproperty,NULL); |
| 4405 | } |
| 4406 | else |
| 4407 | folder = load_dynamic_property(package, szWindowsFolder, NULL); |
| 4408 | |
| 4409 | if (!folder) |
| 4410 | { |
| 4411 | ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty)); |
| 4412 | goto cleanup; |
| 4413 | } |
| 4414 | |
| 4415 | |
| 4416 | fullname = HeapAlloc(GetProcessHeap(),0, |
| 4417 | (strlenW(folder)+strlenW(filename)+2)*sizeof(WCHAR)); |
| 4418 | |
| 4419 | strcpyW(fullname,folder); |
| 4420 | if (fullname[strlenW(folder)] != '\\') |
| 4421 | strcatW(fullname,szbs); |
| 4422 | strcatW(fullname,filename); |
| 4423 | |
| 4424 | if (action == 0) |
| 4425 | { |
| 4426 | TRACE("Adding value %s to section %s in %s\n", |
| 4427 | debugstr_w(deformated_key), debugstr_w(deformated_section), |
| 4428 | debugstr_w(fullname)); |
| 4429 | WritePrivateProfileStringW(deformated_section, deformated_key, |
| 4430 | deformated_value, fullname); |
| 4431 | } |
| 4432 | else if (action == 1) |
| 4433 | { |
| 4434 | WCHAR returned[10]; |
| 4435 | GetPrivateProfileStringW(deformated_section, deformated_key, NULL, |
| 4436 | returned, 10, fullname); |
| 4437 | if (returned[0] == 0) |
| 4438 | { |
| 4439 | TRACE("Adding value %s to section %s in %s\n", |
| 4440 | debugstr_w(deformated_key), debugstr_w(deformated_section), |
| 4441 | debugstr_w(fullname)); |
| 4442 | |
| 4443 | WritePrivateProfileStringW(deformated_section, deformated_key, |
| 4444 | deformated_value, fullname); |
| 4445 | } |
| 4446 | } |
| 4447 | else if (action == 3) |
| 4448 | { |
| 4449 | FIXME("Append to existing section not yet implemented\n"); |
| 4450 | } |
| 4451 | |
| 4452 | uirow = MSI_CreateRecord(4); |
| 4453 | MSI_RecordSetStringW(uirow,1,identifier); |
| 4454 | MSI_RecordSetStringW(uirow,2,deformated_section); |
| 4455 | MSI_RecordSetStringW(uirow,3,deformated_key); |
| 4456 | MSI_RecordSetStringW(uirow,4,deformated_value); |
| 4457 | ui_actiondata(package,szWriteIniValues,uirow); |
| 4458 | msiobj_release( &uirow->hdr ); |
| 4459 | cleanup: |
| 4460 | HeapFree(GetProcessHeap(),0,identifier); |
| 4461 | HeapFree(GetProcessHeap(),0,fullname); |
| 4462 | HeapFree(GetProcessHeap(),0,filename); |
| 4463 | HeapFree(GetProcessHeap(),0,key); |
| 4464 | HeapFree(GetProcessHeap(),0,value); |
| 4465 | HeapFree(GetProcessHeap(),0,section); |
| 4466 | HeapFree(GetProcessHeap(),0,dirproperty); |
| 4467 | HeapFree(GetProcessHeap(),0,folder); |
| 4468 | HeapFree(GetProcessHeap(),0,deformated_key); |
| 4469 | HeapFree(GetProcessHeap(),0,deformated_value); |
| 4470 | HeapFree(GetProcessHeap(),0,deformated_section); |
| 4471 | msiobj_release(&row->hdr); |
| 4472 | } |
| 4473 | MSI_ViewClose(view); |
| 4474 | msiobj_release(&view->hdr); |
| 4475 | return rc; |
| 4476 | } |
| 4477 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4478 | static UINT ACTION_SelfRegModules(MSIPACKAGE *package) |
| 4479 | { |
| 4480 | UINT rc; |
| 4481 | MSIQUERY * view; |
| 4482 | MSIRECORD * row = 0; |
| 4483 | static const WCHAR ExecSeqQuery[] = {'S','e','l','e','c','t',' ','*',' ', |
| 4484 | 'f','r','o','m',' ','S','e','l','f','R','e','g',0}; |
| 4485 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4486 | static const WCHAR ExeStr[] = { |
| 4487 | 'r','e','g','s','v','r','3','2','.','e','x','e',' ','/','s',' ',0}; |
| 4488 | STARTUPINFOW si; |
| 4489 | PROCESS_INFORMATION info; |
| 4490 | BOOL brc; |
| 4491 | |
| 4492 | memset(&si,0,sizeof(STARTUPINFOW)); |
| 4493 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4494 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
| 4495 | if (rc != ERROR_SUCCESS) |
| 4496 | { |
| 4497 | TRACE("no SelfReg table\n"); |
| 4498 | return ERROR_SUCCESS; |
| 4499 | } |
| 4500 | |
| 4501 | rc = MSI_ViewExecute(view, 0); |
| 4502 | if (rc != ERROR_SUCCESS) |
| 4503 | { |
| 4504 | MSI_ViewClose(view); |
| 4505 | msiobj_release(&view->hdr); |
| 4506 | return rc; |
| 4507 | } |
| 4508 | |
| 4509 | while (1) |
| 4510 | { |
| 4511 | LPWSTR filename; |
| 4512 | INT index; |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4513 | DWORD len; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4514 | |
| 4515 | rc = MSI_ViewFetch(view,&row); |
| 4516 | if (rc != ERROR_SUCCESS) |
| 4517 | { |
| 4518 | rc = ERROR_SUCCESS; |
| 4519 | break; |
| 4520 | } |
| 4521 | |
| 4522 | filename = load_dynamic_stringW(row,1); |
| 4523 | index = get_loaded_file(package,filename); |
| 4524 | |
| 4525 | if (index < 0) |
| 4526 | { |
| 4527 | ERR("Unable to find file id %s\n",debugstr_w(filename)); |
| 4528 | HeapFree(GetProcessHeap(),0,filename); |
| 4529 | msiobj_release(&row->hdr); |
| 4530 | continue; |
| 4531 | } |
| 4532 | HeapFree(GetProcessHeap(),0,filename); |
| 4533 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4534 | len = strlenW(ExeStr); |
| 4535 | len += strlenW(package->files[index].TargetPath); |
| 4536 | len +=2; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4537 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4538 | filename = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); |
| 4539 | strcpyW(filename,ExeStr); |
| 4540 | strcatW(filename,package->files[index].TargetPath); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4541 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4542 | TRACE("Registering %s\n",debugstr_w(filename)); |
| 4543 | brc = CreateProcessW(NULL, filename, NULL, NULL, FALSE, 0, NULL, |
| 4544 | c_collen, &si, &info); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4545 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4546 | if (brc) |
| 4547 | WaitForSingleObject(info.hProcess,INFINITE); |
| 4548 | |
| 4549 | HeapFree(GetProcessHeap(),0,filename); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4550 | msiobj_release(&row->hdr); |
| 4551 | } |
| 4552 | MSI_ViewClose(view); |
| 4553 | msiobj_release(&view->hdr); |
| 4554 | return rc; |
| 4555 | } |
| 4556 | |
| 4557 | static UINT ACTION_PublishFeatures(MSIPACKAGE *package) |
| 4558 | { |
| 4559 | LPWSTR productcode; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4560 | UINT rc; |
| 4561 | DWORD i; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4562 | HKEY hkey=0; |
| 4563 | HKEY hukey=0; |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4564 | static const WCHAR szProductCode[]= |
| 4565 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4566 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4567 | if (!package) |
| 4568 | return ERROR_INVALID_HANDLE; |
| 4569 | |
| 4570 | productcode = load_dynamic_property(package,szProductCode,&rc); |
| 4571 | if (!productcode) |
| 4572 | return rc; |
| 4573 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4574 | rc = MSIREG_OpenFeaturesKey(productcode,&hkey,TRUE); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4575 | if (rc != ERROR_SUCCESS) |
| 4576 | goto end; |
| 4577 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4578 | rc = MSIREG_OpenUserFeaturesKey(productcode,&hukey,TRUE); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4579 | if (rc != ERROR_SUCCESS) |
| 4580 | goto end; |
| 4581 | |
| 4582 | /* here the guids are base 85 encoded */ |
| 4583 | for (i = 0; i < package->loaded_features; i++) |
| 4584 | { |
| 4585 | LPWSTR data = NULL; |
| 4586 | GUID clsid; |
| 4587 | int j; |
| 4588 | INT size; |
| 4589 | |
| 4590 | size = package->features[i].ComponentCount*21; |
| 4591 | size +=1; |
| 4592 | if (package->features[i].Feature_Parent[0]) |
| 4593 | size += strlenW(package->features[i].Feature_Parent)+2; |
| 4594 | |
| 4595 | data = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); |
| 4596 | |
| 4597 | data[0] = 0; |
| 4598 | for (j = 0; j < package->features[i].ComponentCount; j++) |
| 4599 | { |
| 4600 | WCHAR buf[21]; |
| 4601 | memset(buf,0,sizeof(buf)); |
| 4602 | TRACE("From %s\n",debugstr_w(package->components |
| 4603 | [package->features[i].Components[j]].ComponentId)); |
| 4604 | CLSIDFromString(package->components |
| 4605 | [package->features[i].Components[j]].ComponentId, |
| 4606 | &clsid); |
| 4607 | encode_base85_guid(&clsid,buf); |
| 4608 | TRACE("to %s\n",debugstr_w(buf)); |
| 4609 | strcatW(data,buf); |
| 4610 | } |
| 4611 | if (package->features[i].Feature_Parent[0]) |
| 4612 | { |
| 4613 | static const WCHAR sep[] = {'\2',0}; |
| 4614 | strcatW(data,sep); |
| 4615 | strcatW(data,package->features[i].Feature_Parent); |
| 4616 | } |
| 4617 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4618 | size = (strlenW(data)+1)*sizeof(WCHAR); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4619 | RegSetValueExW(hkey,package->features[i].Feature,0,REG_SZ, |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4620 | (LPSTR)data,size); |
| 4621 | HeapFree(GetProcessHeap(),0,data); |
| 4622 | |
| 4623 | size = strlenW(package->features[i].Feature_Parent)*sizeof(WCHAR); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4624 | RegSetValueExW(hukey,package->features[i].Feature,0,REG_SZ, |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4625 | (LPSTR)package->features[i].Feature_Parent,size); |
| 4626 | } |
| 4627 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4628 | end: |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4629 | RegCloseKey(hkey); |
| 4630 | RegCloseKey(hukey); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4631 | HeapFree(GetProcessHeap(), 0, productcode); |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 4632 | return rc; |
| 4633 | } |
| 4634 | |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4635 | static UINT ACTION_RegisterProduct(MSIPACKAGE *package) |
| 4636 | { |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4637 | static const WCHAR szProductCode[]= |
| 4638 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4639 | HKEY hkey=0; |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4640 | LPWSTR buffer; |
| 4641 | LPWSTR productcode; |
| 4642 | UINT rc,i; |
| 4643 | DWORD size; |
| 4644 | static WCHAR szNONE[] = {0}; |
| 4645 | static const WCHAR szWindowsInstaler[] = |
| 4646 | {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0}; |
| 4647 | static const WCHAR szPropKeys[][80] = |
| 4648 | { |
| 4649 | {'A','R','P','A','U','T','H','O','R','I','Z','E','D','C','D','F','P','R','E','F','I','X',0}, |
| 4650 | {'A','R','P','C','O','N','T','A','C','T'}, |
| 4651 | {'A','R','P','C','O','M','M','E','N','T','S',0}, |
| 4652 | {'P','r','o','d','u','c','t','N','a','m','e',0}, |
| 4653 | {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0}, |
| 4654 | {'A','R','P','H','E','L','P','L','I','N','K',0}, |
| 4655 | {'A','R','P','H','E','L','P','T','E','L','E','P','H','O','N','E',0}, |
| 4656 | {'A','R','P','I','N','S','T','A','L','L','L','O','C','A','T','I','O','N',0}, |
| 4657 | {'S','O','U','R','C','E','D','I','R',0}, |
| 4658 | {'M','a','n','u','f','a','c','t','u','r','e','r',0}, |
| 4659 | {'A','R','P','R','E','A','D','M','E',0}, |
| 4660 | {'A','R','P','S','I','Z','E',0}, |
| 4661 | {'A','R','P','U','R','L','I','N','F','O','A','B','O','U','T',0}, |
| 4662 | {'A','R','P','U','R','L','U','P','D','A','T','E','I','N','F','O',0}, |
| 4663 | {0}, |
| 4664 | }; |
| 4665 | |
| 4666 | static const WCHAR szRegKeys[][80] = |
| 4667 | { |
| 4668 | {'A','u','t','h','o','r','i','z','e','d','C','D','F','P','r','e','f','i','x',0}, |
| 4669 | {'C','o','n','t','a','c','t',0}, |
| 4670 | {'C','o','m','m','e','n','t','s',0}, |
| 4671 | {'D','i','s','p','l','a','y','N','a','m','e',0}, |
| 4672 | {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0}, |
| 4673 | {'H','e','l','p','L','i','n','k',0}, |
| 4674 | {'H','e','l','p','T','e','l','e','p','h','o','n','e',0}, |
| 4675 | {'I','n','s','t','a','l','l','L','o','c','a','t','i','o','n',0}, |
| 4676 | {'I','n','s','t','a','l','l','S','o','u','r','c','e',0}, |
| 4677 | {'P','u','b','l','i','s','h','e','r',0}, |
| 4678 | {'R','e','a','d','m','e',0}, |
| 4679 | {'S','i','z','e',0}, |
| 4680 | {'U','R','L','I','n','f','o','A','b','o','u','t',0}, |
| 4681 | {'U','R','L','U','p','d','a','t','e','I','n','f','o',0}, |
| 4682 | {0}, |
| 4683 | }; |
| 4684 | |
| 4685 | static const WCHAR path[] = { |
| 4686 | 'C',':','\\','W','i','n','d','o','w','s','\\', |
| 4687 | 'I','n','s','t','a','l','l','e','r','\\'}; |
| 4688 | static const WCHAR fmt[] = { |
| 4689 | 'C',':','\\','W','i','n','d','o','w','s','\\', |
| 4690 | 'I','n','s','t','a','l','l','e','r','\\', |
| 4691 | '%','x','.','m','s','i',0}; |
| 4692 | static const WCHAR szLocalPackage[]= |
| 4693 | {'L','o','c','a','l','P','a','c','k','a','g','e',0}; |
| 4694 | WCHAR packagefile[MAX_PATH]; |
| 4695 | INT num,start; |
| 4696 | |
| 4697 | if (!package) |
| 4698 | return ERROR_INVALID_HANDLE; |
| 4699 | |
| 4700 | productcode = load_dynamic_property(package,szProductCode,&rc); |
| 4701 | if (!productcode) |
| 4702 | return rc; |
| 4703 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4704 | rc = MSIREG_OpenUninstallKey(productcode,&hkey,TRUE); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4705 | if (rc != ERROR_SUCCESS) |
| 4706 | goto end; |
| 4707 | |
| 4708 | /* dump all the info i can grab */ |
| 4709 | FIXME("Flesh out more information \n"); |
| 4710 | |
| 4711 | i = 0; |
| 4712 | while (szPropKeys[i][0]!=0) |
| 4713 | { |
| 4714 | buffer = load_dynamic_property(package,szPropKeys[i],&rc); |
| 4715 | if (rc != ERROR_SUCCESS) |
| 4716 | buffer = szNONE; |
| 4717 | size = strlenW(buffer)*sizeof(WCHAR); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4718 | RegSetValueExW(hkey,szRegKeys[i],0,REG_SZ,(LPSTR)buffer,size); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4719 | i++; |
| 4720 | } |
| 4721 | |
| 4722 | rc = 0x1; |
| 4723 | size = sizeof(rc); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4724 | RegSetValueExW(hkey,szWindowsInstaler,0,REG_DWORD,(LPSTR)&rc,size); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4725 | |
| 4726 | /* copy the package locally */ |
| 4727 | num = GetTickCount() & 0xffff; |
| 4728 | if (!num) |
| 4729 | num = 1; |
| 4730 | start = num; |
| 4731 | sprintfW(packagefile,fmt,num); |
| 4732 | do |
| 4733 | { |
| 4734 | HANDLE handle = CreateFileW(packagefile,GENERIC_WRITE, 0, NULL, |
| 4735 | CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); |
| 4736 | if (handle != INVALID_HANDLE_VALUE) |
| 4737 | { |
| 4738 | CloseHandle(handle); |
| 4739 | break; |
| 4740 | } |
| 4741 | if (GetLastError() != ERROR_FILE_EXISTS && |
| 4742 | GetLastError() != ERROR_SHARING_VIOLATION) |
| 4743 | break; |
| 4744 | if (!(++num & 0xffff)) num = 1; |
| 4745 | sprintfW(packagefile,fmt,num); |
| 4746 | } while (num != start); |
| 4747 | |
| 4748 | create_full_pathW(path); |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 4749 | TRACE("Copying to local package %s\n",debugstr_w(packagefile)); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4750 | CopyFileW(package->PackagePath,packagefile,FALSE); |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 4751 | size = strlenW(packagefile)*sizeof(WCHAR); |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4752 | RegSetValueExW(hkey,szLocalPackage,0,REG_SZ,(LPSTR)packagefile,size); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4753 | |
| 4754 | end: |
| 4755 | HeapFree(GetProcessHeap(),0,productcode); |
| 4756 | RegCloseKey(hkey); |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4757 | |
| 4758 | return ERROR_SUCCESS; |
| 4759 | } |
| 4760 | |
| 4761 | static UINT ACTION_InstallExecute(MSIPACKAGE *package) |
| 4762 | { |
| 4763 | int i; |
| 4764 | if (!package) |
| 4765 | return ERROR_INVALID_HANDLE; |
| 4766 | |
| 4767 | for (i = 0; i < package->DeferredActionCount; i++) |
| 4768 | { |
| 4769 | LPWSTR action; |
| 4770 | action = package->DeferredAction[i]; |
| 4771 | ui_actionstart(package, action); |
| 4772 | TRACE("Executing Action (%s)\n",debugstr_w(action)); |
| 4773 | ACTION_CustomAction(package,action,TRUE); |
| 4774 | HeapFree(GetProcessHeap(),0,package->DeferredAction[i]); |
| 4775 | } |
| 4776 | HeapFree(GetProcessHeap(),0,package->DeferredAction); |
| 4777 | |
| 4778 | package->DeferredActionCount = 0; |
| 4779 | package->DeferredAction = NULL; |
| 4780 | |
| 4781 | return ERROR_SUCCESS; |
| 4782 | } |
| 4783 | |
| 4784 | static UINT ACTION_InstallFinalize(MSIPACKAGE *package) |
| 4785 | { |
| 4786 | int i; |
| 4787 | if (!package) |
| 4788 | return ERROR_INVALID_HANDLE; |
| 4789 | |
Aric Stewart | 54c67dd | 2005-01-25 20:17:09 +0000 | [diff] [blame^] | 4790 | /* first do the same as an InstallExecute */ |
| 4791 | ACTION_InstallExecute(package); |
| 4792 | |
| 4793 | /* then handle Commit Actions */ |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4794 | for (i = 0; i < package->CommitActionCount; i++) |
| 4795 | { |
| 4796 | LPWSTR action; |
| 4797 | action = package->CommitAction[i]; |
| 4798 | ui_actionstart(package, action); |
| 4799 | TRACE("Executing Commit Action (%s)\n",debugstr_w(action)); |
| 4800 | ACTION_CustomAction(package,action,TRUE); |
| 4801 | HeapFree(GetProcessHeap(),0,package->CommitAction[i]); |
| 4802 | } |
| 4803 | HeapFree(GetProcessHeap(),0,package->CommitAction); |
| 4804 | |
| 4805 | package->CommitActionCount = 0; |
| 4806 | package->CommitAction = NULL; |
| 4807 | |
| 4808 | return ERROR_SUCCESS; |
| 4809 | } |
| 4810 | |
| 4811 | static UINT ACTION_ForceReboot(MSIPACKAGE *package) |
| 4812 | { |
| 4813 | static const WCHAR RunOnce[] = { |
| 4814 | 'S','o','f','t','w','a','r','e','\\', |
| 4815 | 'M','i','c','r','o','s','o','f','t','\\', |
| 4816 | 'W','i','n','d','o','w','s','\\', |
| 4817 | 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', |
| 4818 | 'R','u','n','O','n','c','e'}; |
| 4819 | static const WCHAR InstallRunOnce[] = { |
| 4820 | 'S','o','f','t','w','a','r','e','\\', |
| 4821 | 'M','i','c','r','o','s','o','f','t','\\', |
| 4822 | 'W','i','n','d','o','w','s','\\', |
| 4823 | 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', |
| 4824 | 'I','n','s','t','a','l','l','e','r','\\', |
| 4825 | 'R','u','n','O','n','c','e','E','n','t','r','i','e','s'}; |
| 4826 | |
| 4827 | static const WCHAR msiexec_fmt[] = { |
| 4828 | 'C',':','\\','W','i','n','d','o','w','s','\\','S','y','s','t','e','m', |
| 4829 | '\\','M','s','i','E','x','e','c','.','e','x','e',' ','/','@',' ', |
| 4830 | '\"','%','s','\"',0}; |
| 4831 | static const WCHAR install_fmt[] = { |
| 4832 | '/','I',' ','\"','%','s','\"',' ', |
| 4833 | 'A','F','T','E','R','R','E','B','O','O','T','=','1',' ', |
| 4834 | 'R','U','N','O','N','C','E','E','N','T','R','Y','=','\"','%','s','\"',0}; |
| 4835 | WCHAR buffer[256]; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4836 | HKEY hkey,hukey; |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4837 | LPWSTR productcode; |
| 4838 | WCHAR squished_pc[100]; |
| 4839 | INT rc; |
| 4840 | DWORD size; |
| 4841 | static const WCHAR szProductCode[]= |
| 4842 | {'P','r','o','d','u','c','t','C','o','d','e',0}; |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4843 | static const WCHAR szLUS[] = { |
| 4844 | 'L','a','s','t','U','s','e','d','S','o','u','r','c','e',0}; |
| 4845 | static const WCHAR szSourceList[] = { |
| 4846 | 'S','o','u','r','c','e','L','i','s','t',0}; |
| 4847 | static const WCHAR szPackageName[] = { |
| 4848 | 'P','a','c','k','a','g','e','N','a','m','e',0}; |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4849 | |
| 4850 | if (!package) |
| 4851 | return ERROR_INVALID_HANDLE; |
| 4852 | |
| 4853 | productcode = load_dynamic_property(package,szProductCode,&rc); |
| 4854 | if (!productcode) |
| 4855 | return rc; |
| 4856 | |
| 4857 | squash_guid(productcode,squished_pc); |
| 4858 | |
| 4859 | RegCreateKeyW(HKEY_LOCAL_MACHINE,RunOnce,&hkey); |
| 4860 | sprintfW(buffer,msiexec_fmt,squished_pc); |
| 4861 | |
| 4862 | size = strlenW(buffer)*sizeof(WCHAR); |
| 4863 | RegSetValueExW(hkey,squished_pc,0,REG_SZ,(LPSTR)buffer,size); |
| 4864 | RegCloseKey(hkey); |
| 4865 | |
| 4866 | TRACE("Reboot command %s\n",debugstr_w(buffer)); |
| 4867 | |
| 4868 | RegCreateKeyW(HKEY_LOCAL_MACHINE,InstallRunOnce,&hkey); |
| 4869 | sprintfW(buffer,install_fmt,productcode,squished_pc); |
| 4870 | RegSetValueExW(hkey,squished_pc,0,REG_SZ,(LPSTR)buffer,size); |
| 4871 | RegCloseKey(hkey); |
| 4872 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4873 | rc = MSIREG_OpenUserProductsKey(productcode,&hukey,TRUE); |
| 4874 | if (rc == ERROR_SUCCESS) |
| 4875 | { |
| 4876 | HKEY hukey2; |
| 4877 | LPWSTR buf; |
| 4878 | RegCreateKeyW(hukey, szSourceList, &hukey2); |
| 4879 | buf = load_dynamic_property(package,cszSourceDir,NULL); |
| 4880 | size = strlenW(buf)*sizeof(WCHAR); |
| 4881 | RegSetValueExW(hukey2,szLUS,0,REG_SZ,(LPSTR)buf,size); |
| 4882 | HeapFree(GetProcessHeap(),0,buf); |
| 4883 | |
| 4884 | buf = strrchrW(package->PackagePath,'\\'); |
| 4885 | if (buf) |
| 4886 | { |
| 4887 | buf++; |
| 4888 | size = strlenW(buf)*sizeof(WCHAR); |
| 4889 | RegSetValueExW(hukey2,szPackageName,0,REG_SZ,(LPSTR)buf,size); |
| 4890 | } |
| 4891 | |
| 4892 | RegCloseKey(hukey2); |
| 4893 | } |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4894 | HeapFree(GetProcessHeap(),0,productcode); |
| 4895 | |
Aric Stewart | 68b0749 | 2005-01-25 11:05:37 +0000 | [diff] [blame] | 4896 | return ERROR_INSTALL_SUSPEND; |
Aric Stewart | 2cae30b | 2005-01-19 19:07:40 +0000 | [diff] [blame] | 4897 | } |
| 4898 | |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 4899 | /* Msi functions that seem appropriate here */ |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4900 | UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction ) |
| 4901 | { |
| 4902 | LPWSTR szwAction; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4903 | UINT rc; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4904 | |
| 4905 | TRACE(" exteral attempt at action %s\n",szAction); |
| 4906 | |
| 4907 | if (!szAction) |
| 4908 | return ERROR_FUNCTION_FAILED; |
| 4909 | if (hInstall == 0) |
| 4910 | return ERROR_FUNCTION_FAILED; |
| 4911 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4912 | szwAction = strdupAtoW(szAction); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4913 | |
| 4914 | if (!szwAction) |
| 4915 | return ERROR_FUNCTION_FAILED; |
| 4916 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4917 | |
| 4918 | rc = MsiDoActionW(hInstall, szwAction); |
| 4919 | HeapFree(GetProcessHeap(),0,szwAction); |
| 4920 | return rc; |
| 4921 | } |
| 4922 | |
| 4923 | UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction ) |
| 4924 | { |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4925 | MSIPACKAGE *package; |
| 4926 | UINT ret = ERROR_INVALID_HANDLE; |
| 4927 | |
Mike McCormack | 3ece246 | 2004-07-09 19:33:25 +0000 | [diff] [blame] | 4928 | TRACE(" external attempt at action %s \n",debugstr_w(szAction)); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4929 | |
| 4930 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 4931 | if( package ) |
| 4932 | { |
| 4933 | ret = ACTION_PerformAction(package,szAction); |
| 4934 | msiobj_release( &package->hdr ); |
| 4935 | } |
| 4936 | return ret; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4937 | } |
| 4938 | |
| 4939 | UINT WINAPI MsiGetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder, |
| 4940 | LPSTR szPathBuf, DWORD* pcchPathBuf) |
| 4941 | { |
| 4942 | LPWSTR szwFolder; |
| 4943 | LPWSTR szwPathBuf; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4944 | UINT rc; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4945 | |
| 4946 | TRACE("getting folder %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf); |
| 4947 | |
| 4948 | if (!szFolder) |
| 4949 | return ERROR_FUNCTION_FAILED; |
| 4950 | if (hInstall == 0) |
| 4951 | return ERROR_FUNCTION_FAILED; |
| 4952 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 4953 | szwFolder = strdupAtoW(szFolder); |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4954 | |
| 4955 | if (!szwFolder) |
| 4956 | return ERROR_FUNCTION_FAILED; |
| 4957 | |
| 4958 | szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR)); |
| 4959 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4960 | rc = MsiGetTargetPathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf); |
| 4961 | |
| 4962 | WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf, |
| 4963 | *pcchPathBuf, NULL, NULL ); |
| 4964 | |
| 4965 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 4966 | HeapFree(GetProcessHeap(),0,szwPathBuf); |
| 4967 | |
| 4968 | return rc; |
| 4969 | } |
| 4970 | |
| 4971 | UINT WINAPI MsiGetTargetPathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR |
| 4972 | szPathBuf, DWORD* pcchPathBuf) |
| 4973 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4974 | LPWSTR path; |
| 4975 | UINT rc = ERROR_FUNCTION_FAILED; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4976 | MSIPACKAGE *package; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4977 | |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 4978 | TRACE("(%s %p %li)\n",debugstr_w(szFolder),szPathBuf,*pcchPathBuf); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4979 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4980 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4981 | if (!package) |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4982 | return ERROR_INVALID_HANDLE; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4983 | path = resolve_folder(package, szFolder, FALSE, FALSE, NULL); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 4984 | msiobj_release( &package->hdr ); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4985 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4986 | if (path && (strlenW(path) > *pcchPathBuf)) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4987 | { |
| 4988 | *pcchPathBuf = strlenW(path)+1; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4989 | rc = ERROR_MORE_DATA; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4990 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4991 | else if (path) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4992 | { |
| 4993 | *pcchPathBuf = strlenW(path)+1; |
| 4994 | strcpyW(szPathBuf,path); |
| 4995 | TRACE("Returning Path %s\n",debugstr_w(path)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 4996 | rc = ERROR_SUCCESS; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4997 | } |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 4998 | HeapFree(GetProcessHeap(),0,path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 4999 | |
| 5000 | return rc; |
Aric Stewart | e95136b | 2004-06-29 03:44:01 +0000 | [diff] [blame] | 5001 | } |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5002 | |
| 5003 | |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5004 | UINT WINAPI MsiGetSourcePathA( MSIHANDLE hInstall, LPCSTR szFolder, |
| 5005 | LPSTR szPathBuf, DWORD* pcchPathBuf) |
| 5006 | { |
| 5007 | LPWSTR szwFolder; |
| 5008 | LPWSTR szwPathBuf; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5009 | UINT rc; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5010 | |
| 5011 | TRACE("getting source %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf); |
| 5012 | |
| 5013 | if (!szFolder) |
| 5014 | return ERROR_FUNCTION_FAILED; |
| 5015 | if (hInstall == 0) |
| 5016 | return ERROR_FUNCTION_FAILED; |
| 5017 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5018 | szwFolder = strdupAtoW(szFolder); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5019 | if (!szwFolder) |
| 5020 | return ERROR_FUNCTION_FAILED; |
| 5021 | |
| 5022 | szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR)); |
| 5023 | |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5024 | rc = MsiGetSourcePathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf); |
| 5025 | |
| 5026 | WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf, |
| 5027 | *pcchPathBuf, NULL, NULL ); |
| 5028 | |
| 5029 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 5030 | HeapFree(GetProcessHeap(),0,szwPathBuf); |
| 5031 | |
| 5032 | return rc; |
| 5033 | } |
| 5034 | |
| 5035 | UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR |
| 5036 | szPathBuf, DWORD* pcchPathBuf) |
| 5037 | { |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5038 | LPWSTR path; |
| 5039 | UINT rc = ERROR_FUNCTION_FAILED; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5040 | MSIPACKAGE *package; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5041 | |
| 5042 | TRACE("(%s %p %li)\n",debugstr_w(szFolder),szPathBuf,*pcchPathBuf); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5043 | |
| 5044 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 5045 | if( !package ) |
| 5046 | return ERROR_INVALID_HANDLE; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5047 | path = resolve_folder(package, szFolder, TRUE, FALSE, NULL); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5048 | msiobj_release( &package->hdr ); |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5049 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5050 | if (path && strlenW(path) > *pcchPathBuf) |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5051 | { |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5052 | *pcchPathBuf = strlenW(path)+1; |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 5053 | rc = ERROR_MORE_DATA; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5054 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 5055 | else if (path) |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5056 | { |
| 5057 | *pcchPathBuf = strlenW(path)+1; |
| 5058 | strcpyW(szPathBuf,path); |
| 5059 | TRACE("Returning Path %s\n",debugstr_w(path)); |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 5060 | rc = ERROR_SUCCESS; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5061 | } |
Aric Stewart | fa384f6 | 2004-12-22 18:46:17 +0000 | [diff] [blame] | 5062 | HeapFree(GetProcessHeap(),0,path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5063 | |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5064 | return rc; |
| 5065 | } |
| 5066 | |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5067 | |
| 5068 | UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, |
| 5069 | LPCSTR szFolderPath) |
| 5070 | { |
| 5071 | LPWSTR szwFolder; |
| 5072 | LPWSTR szwFolderPath; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5073 | UINT rc; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5074 | |
| 5075 | if (!szFolder) |
| 5076 | return ERROR_FUNCTION_FAILED; |
| 5077 | if (hInstall == 0) |
| 5078 | return ERROR_FUNCTION_FAILED; |
| 5079 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5080 | szwFolder = strdupAtoW(szFolder); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5081 | if (!szwFolder) |
| 5082 | return ERROR_FUNCTION_FAILED; |
| 5083 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5084 | szwFolderPath = strdupAtoW(szFolderPath); |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5085 | if (!szwFolderPath) |
| 5086 | { |
| 5087 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 5088 | return ERROR_FUNCTION_FAILED; |
| 5089 | } |
| 5090 | |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5091 | rc = MsiSetTargetPathW(hInstall, szwFolder, szwFolderPath); |
| 5092 | |
| 5093 | HeapFree(GetProcessHeap(),0,szwFolder); |
| 5094 | HeapFree(GetProcessHeap(),0,szwFolderPath); |
| 5095 | |
| 5096 | return rc; |
| 5097 | } |
| 5098 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5099 | UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder, |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5100 | LPCWSTR szFolderPath) |
| 5101 | { |
Mike McCormack | 4604e66 | 2004-08-06 17:30:20 +0000 | [diff] [blame] | 5102 | DWORD i; |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5103 | LPWSTR path = NULL; |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 5104 | LPWSTR path2 = NULL; |
Aric Stewart | 6296de3 | 2005-01-03 16:06:44 +0000 | [diff] [blame] | 5105 | INT len; |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 5106 | MSIFOLDER *folder; |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5107 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5108 | TRACE("(%p %s %s)\n",package, debugstr_w(szFolder),debugstr_w(szFolderPath)); |
| 5109 | |
| 5110 | if (package==NULL) |
| 5111 | return ERROR_INVALID_HANDLE; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5112 | |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5113 | if (szFolderPath[0]==0) |
| 5114 | return ERROR_FUNCTION_FAILED; |
| 5115 | |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 5116 | if (GetFileAttributesW(szFolderPath) == INVALID_FILE_ATTRIBUTES) |
| 5117 | return ERROR_FUNCTION_FAILED; |
| 5118 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5119 | path = resolve_folder(package,szFolder,FALSE,FALSE,&folder); |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 5120 | |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5121 | if (!path) |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 5122 | return ERROR_INVALID_PARAMETER; |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 5123 | |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 5124 | HeapFree(GetProcessHeap(),0,folder->Property); |
Aric Stewart | e2d4ea8 | 2004-07-04 00:33:45 +0000 | [diff] [blame] | 5125 | |
Aric Stewart | 6296de3 | 2005-01-03 16:06:44 +0000 | [diff] [blame] | 5126 | len = strlenW(szFolderPath); |
| 5127 | |
| 5128 | if (szFolderPath[len-1]!='\\') |
| 5129 | { |
| 5130 | len +=2; |
| 5131 | folder->Property = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); |
| 5132 | strcpyW(folder->Property,szFolderPath); |
| 5133 | strcatW(folder->Property,cszbs); |
| 5134 | } |
| 5135 | else |
| 5136 | folder->Property = dupstrW(szFolderPath); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5137 | |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 5138 | if (strcmpiW(path, szFolderPath) == 0) |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5139 | { |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 5140 | /* |
| 5141 | * Resolved Target has not really changed, so just |
| 5142 | * set this folder and do not recalculate everything. |
| 5143 | */ |
| 5144 | HeapFree(GetProcessHeap(),0,folder->ResolvedTarget); |
| 5145 | folder->ResolvedTarget = NULL; |
| 5146 | path2 = resolve_folder(package,szFolder,FALSE,TRUE,NULL); |
| 5147 | HeapFree(GetProcessHeap(),0,path2); |
Mike McCormack | ba8200b | 2004-12-22 15:25:30 +0000 | [diff] [blame] | 5148 | } |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 5149 | else |
| 5150 | { |
| 5151 | for (i = 0; i < package->loaded_folders; i++) |
| 5152 | { |
Michael Stefaniuc | b937407 | 2005-01-20 10:36:35 +0000 | [diff] [blame] | 5153 | HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedTarget); |
Aric Stewart | 4e55343 | 2005-01-04 20:47:20 +0000 | [diff] [blame] | 5154 | package->folders[i].ResolvedTarget=NULL; |
| 5155 | } |
| 5156 | |
| 5157 | for (i = 0; i < package->loaded_folders; i++) |
| 5158 | { |
| 5159 | path2=resolve_folder(package, package->folders[i].Directory, FALSE, |
| 5160 | TRUE, NULL); |
| 5161 | HeapFree(GetProcessHeap(),0,path2); |
| 5162 | } |
| 5163 | } |
| 5164 | HeapFree(GetProcessHeap(),0,path); |
Aric Stewart | bdb2955 | 2004-07-04 00:32:48 +0000 | [diff] [blame] | 5165 | |
| 5166 | return ERROR_SUCCESS; |
Aric Stewart | ed7c4bc | 2004-07-04 00:26:54 +0000 | [diff] [blame] | 5167 | } |
| 5168 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5169 | UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder, |
| 5170 | LPCWSTR szFolderPath) |
| 5171 | { |
| 5172 | MSIPACKAGE *package; |
| 5173 | UINT ret; |
| 5174 | |
| 5175 | TRACE("(%s %s)\n",debugstr_w(szFolder),debugstr_w(szFolderPath)); |
| 5176 | |
| 5177 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 5178 | ret = MSI_SetTargetPathW( package, szFolder, szFolderPath ); |
| 5179 | msiobj_release( &package->hdr ); |
| 5180 | return ret; |
| 5181 | } |
| 5182 | |
Vitaly Lipatov | 5c4116b | 2004-12-16 14:29:25 +0000 | [diff] [blame] | 5183 | /*********************************************************************** |
| 5184 | * MsiGetMode (MSI.@) |
| 5185 | * |
| 5186 | * Returns an internal installer state (if it is running in a mode iRunMode) |
| 5187 | * |
| 5188 | * PARAMS |
| 5189 | * hInstall [I] Handle to the installation |
| 5190 | * hRunMode [I] Checking run mode |
| 5191 | * MSIRUNMODE_ADMIN Administrative mode |
| 5192 | * MSIRUNMODE_ADVERTISE Advertisement mode |
| 5193 | * MSIRUNMODE_MAINTENANCE Maintenance mode |
| 5194 | * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled |
| 5195 | * MSIRUNMODE_LOGENABLED Log file is writing |
| 5196 | * MSIRUNMODE_OPERATIONS Operations in progress?? |
| 5197 | * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed |
| 5198 | * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation |
| 5199 | * MSIRUNMODE_CABINET Files from cabinet are installed |
| 5200 | * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is supressed |
| 5201 | * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is supressed |
| 5202 | * MSIRUNMODE_RESERVED11 Reserved |
| 5203 | * MSIRUNMODE_WINDOWS9X Running under Windows95/98 |
| 5204 | * MSIRUNMODE_ZAWENABLED Demand installation is supported |
| 5205 | * MSIRUNMODE_RESERVED14 Reserved |
| 5206 | * MSIRUNMODE_RESERVED15 Reserved |
| 5207 | * MSIRUNMODE_SCHEDULED called from install script |
| 5208 | * MSIRUNMODE_ROLLBACK called from rollback script |
| 5209 | * MSIRUNMODE_COMMIT called from commit script |
| 5210 | * |
| 5211 | * RETURNS |
| 5212 | * In the state: TRUE |
| 5213 | * Not in the state: FALSE |
| 5214 | * |
| 5215 | */ |
| 5216 | |
| 5217 | BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5218 | { |
Vitaly Lipatov | 5c4116b | 2004-12-16 14:29:25 +0000 | [diff] [blame] | 5219 | FIXME("STUB (iRunMode=%i)\n",iRunMode); |
| 5220 | return TRUE; |
Aric Stewart | 6e160f1 | 2004-06-29 04:07:22 +0000 | [diff] [blame] | 5221 | } |
| 5222 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5223 | /* |
Aric Stewart | d906ef0 | 2004-10-22 22:06:31 +0000 | [diff] [blame] | 5224 | * According to the docs, when this is called it immediately recalculates |
| 5225 | * all the component states as well |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5226 | */ |
| 5227 | UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature, |
| 5228 | INSTALLSTATE iState) |
| 5229 | { |
| 5230 | LPWSTR szwFeature = NULL; |
| 5231 | UINT rc; |
| 5232 | |
| 5233 | szwFeature = strdupAtoW(szFeature); |
| 5234 | |
| 5235 | if (!szwFeature) |
| 5236 | return ERROR_FUNCTION_FAILED; |
| 5237 | |
| 5238 | rc = MsiSetFeatureStateW(hInstall,szwFeature, iState); |
| 5239 | |
| 5240 | HeapFree(GetProcessHeap(),0,szwFeature); |
| 5241 | |
| 5242 | return rc; |
| 5243 | } |
| 5244 | |
| 5245 | UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature, |
| 5246 | INSTALLSTATE iState) |
| 5247 | { |
| 5248 | MSIPACKAGE* package; |
| 5249 | INT index; |
| 5250 | |
| 5251 | TRACE(" %s to %i\n",debugstr_w(szFeature), iState); |
| 5252 | |
| 5253 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 5254 | if (!package) |
| 5255 | return ERROR_INVALID_HANDLE; |
| 5256 | |
| 5257 | index = get_loaded_feature(package,szFeature); |
| 5258 | if (index < 0) |
| 5259 | return ERROR_UNKNOWN_FEATURE; |
| 5260 | |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 5261 | package->features[index].ActionRequest= iState; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5262 | |
| 5263 | return ERROR_SUCCESS; |
| 5264 | } |
| 5265 | |
| 5266 | UINT WINAPI MsiGetFeatureStateA(MSIHANDLE hInstall, LPSTR szFeature, |
| 5267 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 5268 | { |
| 5269 | LPWSTR szwFeature = NULL; |
| 5270 | UINT rc; |
| 5271 | |
| 5272 | szwFeature = strdupAtoW(szFeature); |
| 5273 | |
| 5274 | rc = MsiGetFeatureStateW(hInstall,szwFeature,piInstalled, piAction); |
| 5275 | |
| 5276 | HeapFree( GetProcessHeap(), 0 , szwFeature); |
| 5277 | |
| 5278 | return rc; |
| 5279 | } |
| 5280 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5281 | UINT MSI_GetFeatureStateW(MSIPACKAGE *package, LPWSTR szFeature, |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5282 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 5283 | { |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5284 | INT index; |
| 5285 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5286 | index = get_loaded_feature(package,szFeature); |
| 5287 | if (index < 0) |
| 5288 | return ERROR_UNKNOWN_FEATURE; |
| 5289 | |
| 5290 | if (piInstalled) |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 5291 | *piInstalled = package->features[index].Installed; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5292 | |
| 5293 | if (piAction) |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 5294 | *piAction = package->features[index].Action; |
| 5295 | |
Aric Stewart | ae1aa32 | 2004-12-27 19:02:59 +0000 | [diff] [blame] | 5296 | TRACE("returning %i %i\n",*piInstalled,*piAction); |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5297 | |
| 5298 | return ERROR_SUCCESS; |
| 5299 | } |
| 5300 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5301 | UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPWSTR szFeature, |
| 5302 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 5303 | { |
| 5304 | MSIPACKAGE* package; |
| 5305 | UINT ret; |
| 5306 | |
| 5307 | TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled, |
| 5308 | piAction); |
| 5309 | |
| 5310 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
| 5311 | if (!package) |
| 5312 | return ERROR_INVALID_HANDLE; |
| 5313 | ret = MSI_GetFeatureStateW(package, szFeature, piInstalled, piAction); |
| 5314 | msiobj_release( &package->hdr ); |
| 5315 | return ret; |
| 5316 | } |
| 5317 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5318 | UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szComponent, |
| 5319 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 5320 | { |
| 5321 | LPWSTR szwComponent= NULL; |
| 5322 | UINT rc; |
| 5323 | |
| 5324 | szwComponent= strdupAtoW(szComponent); |
| 5325 | |
| 5326 | rc = MsiGetComponentStateW(hInstall,szwComponent,piInstalled, piAction); |
| 5327 | |
| 5328 | HeapFree( GetProcessHeap(), 0 , szwComponent); |
| 5329 | |
| 5330 | return rc; |
| 5331 | } |
| 5332 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5333 | UINT MSI_GetComponentStateW(MSIPACKAGE *package, LPWSTR szComponent, |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5334 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
| 5335 | { |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5336 | INT index; |
| 5337 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5338 | TRACE("%p %s %p %p\n", package, debugstr_w(szComponent), piInstalled, |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5339 | piAction); |
| 5340 | |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5341 | index = get_loaded_component(package,szComponent); |
| 5342 | if (index < 0) |
| 5343 | return ERROR_UNKNOWN_COMPONENT; |
| 5344 | |
| 5345 | if (piInstalled) |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 5346 | *piInstalled = package->components[index].Installed; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5347 | |
| 5348 | if (piAction) |
Aric Stewart | fbdd709 | 2004-12-27 19:06:22 +0000 | [diff] [blame] | 5349 | *piInstalled = package->components[index].Action; |
Aric Stewart | a3149f8 | 2004-07-09 19:38:40 +0000 | [diff] [blame] | 5350 | |
| 5351 | return ERROR_SUCCESS; |
| 5352 | } |
| 5353 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5354 | UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPWSTR szComponent, |
| 5355 | INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5356 | { |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 5357 | MSIPACKAGE* package; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5358 | UINT ret; |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5359 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5360 | TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szComponent), |
| 5361 | piInstalled, piAction); |
| 5362 | |
| 5363 | package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 5364 | if (!package) |
| 5365 | return ERROR_INVALID_HANDLE; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5366 | ret = MSI_GetComponentStateW( package, szComponent, piInstalled, piAction); |
| 5367 | msiobj_release( &package->hdr ); |
| 5368 | return ret; |
| 5369 | } |
Aric Stewart | 8f0a761 | 2004-07-06 18:53:11 +0000 | [diff] [blame] | 5370 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5371 | #if 0 |
| 5372 | static UINT ACTION_Template(MSIPACKAGE *package) |
| 5373 | { |
| 5374 | UINT rc; |
| 5375 | MSIQUERY * view; |
| 5376 | MSIRECORD * row = 0; |
| 5377 | static const WCHAR ExecSeqQuery[] = {0}; |
Aric Stewart | eb0e0df | 2004-06-30 19:38:36 +0000 | [diff] [blame] | 5378 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 5379 | rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5380 | if (rc != ERROR_SUCCESS) |
| 5381 | return rc; |
| 5382 | |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 5383 | rc = MSI_ViewExecute(view, 0); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5384 | if (rc != ERROR_SUCCESS) |
| 5385 | { |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 5386 | MSI_ViewClose(view); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5387 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5388 | return rc; |
| 5389 | } |
| 5390 | |
| 5391 | while (1) |
| 5392 | { |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 5393 | rc = MSI_ViewFetch(view,&row); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5394 | if (rc != ERROR_SUCCESS) |
| 5395 | { |
| 5396 | rc = ERROR_SUCCESS; |
| 5397 | break; |
| 5398 | } |
| 5399 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5400 | msiobj_release(&row->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5401 | } |
Aric Stewart | 6269f00 | 2005-01-17 13:40:39 +0000 | [diff] [blame] | 5402 | MSI_ViewClose(view); |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 5403 | msiobj_release(&view->hdr); |
Aric Stewart | 401bd3f | 2004-06-28 20:34:35 +0000 | [diff] [blame] | 5404 | return rc; |
| 5405 | } |
| 5406 | #endif |