msi: Load the component states in CostFinalize instead of CostInitialize.
[wine] / dlls / msi / action.h
1 /*
2  * Common prototypes for Action handlers
3  *
4  * Copyright 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __MSI_ACTION_H__
22 #define __MSI_ACTION_H__
23
24 #include "wine/list.h"
25
26 typedef struct tagMSIFEATURE
27 {
28     struct list entry;
29     LPWSTR Feature;
30     LPWSTR Feature_Parent;
31     LPWSTR Title;
32     LPWSTR Description;
33     INT Display;
34     INT Level;
35     LPWSTR Directory;
36     INT Attributes;
37     
38     INSTALLSTATE Installed;
39     INSTALLSTATE ActionRequest;
40     INSTALLSTATE Action;
41
42     struct list Components;
43     
44     INT Cost;
45 } MSIFEATURE;
46
47 typedef struct tagMSICOMPONENT
48 {
49     struct list entry;
50     DWORD magic;
51     LPWSTR Component;
52     LPWSTR ComponentId;
53     LPWSTR Directory;
54     INT Attributes;
55     LPWSTR Condition;
56     LPWSTR KeyPath;
57
58     INSTALLSTATE Installed;
59     INSTALLSTATE ActionRequest;
60     INSTALLSTATE Action;
61
62     BOOL ForceLocalState;
63     BOOL Enabled;
64     INT  Cost;
65     INT  RefCount;
66
67     LPWSTR FullKeypath;
68     LPWSTR AdvertiseString;
69 } MSICOMPONENT;
70
71 typedef struct tagComponentList
72 {
73     struct list entry;
74     MSICOMPONENT *component;
75 } ComponentList;
76
77 typedef struct tagMSIFOLDER
78 {
79     struct list entry;
80     LPWSTR Directory;
81     LPWSTR TargetDefault;
82     LPWSTR SourceLongPath;
83     LPWSTR SourceShortPath;
84
85     LPWSTR ResolvedTarget;
86     LPWSTR ResolvedSource;
87     LPWSTR Property;   /* initially set property */
88     struct tagMSIFOLDER *Parent;
89     INT   State;
90         /* 0 = uninitialized */
91         /* 1 = existing */
92         /* 2 = created remove if empty */
93         /* 3 = created persist if empty */
94     INT   Cost;
95     INT   Space;
96 } MSIFOLDER;
97
98 typedef enum _msi_file_state {
99     msifs_invalid,
100     msifs_missing,
101     msifs_overwrite,
102     msifs_present,
103     msifs_installed,
104     msifs_skipped,
105 } msi_file_state;
106
107 typedef struct tagMSIFILE
108 {
109     struct list entry;
110     LPWSTR File;
111     MSICOMPONENT *Component;
112     LPWSTR FileName;
113     LPWSTR ShortName;
114     LPWSTR LongName;
115     INT FileSize;
116     LPWSTR Version;
117     LPWSTR Language;
118     INT Attributes;
119     INT Sequence;   
120     msi_file_state state;
121     LPWSTR  SourcePath;
122     LPWSTR  TargetPath;
123     BOOL IsCompressed;
124 } MSIFILE;
125
126 typedef struct tagMSITEMPFILE
127 {
128     struct list entry;
129     LPWSTR File;
130     LPWSTR Path;
131 } MSITEMPFILE;
132
133 typedef struct tagMSIAPPID
134 {
135     struct list entry;
136     LPWSTR AppID; /* Primary key */
137     LPWSTR RemoteServerName;
138     LPWSTR LocalServer;
139     LPWSTR ServiceParameters;
140     LPWSTR DllSurrogate;
141     BOOL ActivateAtStorage;
142     BOOL RunAsInteractiveUser;
143 } MSIAPPID;
144
145 typedef struct tagMSIPROGID MSIPROGID;
146
147 typedef struct tagMSICLASS
148 {
149     struct list entry;
150     LPWSTR clsid;     /* Primary Key */
151     LPWSTR Context;   /* Primary Key */
152     MSICOMPONENT *Component;
153     MSIPROGID *ProgID;
154     LPWSTR ProgIDText;
155     LPWSTR Description;
156     MSIAPPID *AppID;
157     LPWSTR FileTypeMask;
158     LPWSTR IconPath;
159     LPWSTR DefInprocHandler;
160     LPWSTR DefInprocHandler32;
161     LPWSTR Argument;
162     MSIFEATURE *Feature;
163     INT Attributes;
164     /* not in the table, set during installation */
165     BOOL Installed;
166 } MSICLASS;
167
168 typedef struct tagMSIMIME MSIMIME;
169
170 typedef struct tagMSIEXTENSION
171 {
172     struct list entry;
173     LPWSTR Extension;  /* Primary Key */
174     MSICOMPONENT *Component;
175     MSIPROGID *ProgID;
176     LPWSTR ProgIDText;
177     MSIMIME *Mime;
178     MSIFEATURE *Feature;
179     /* not in the table, set during installation */
180     BOOL Installed;
181     struct list verbs;
182 } MSIEXTENSION;
183
184 struct tagMSIPROGID
185 {
186     struct list entry;
187     LPWSTR ProgID;  /* Primary Key */
188     MSIPROGID *Parent;
189     MSICLASS *Class;
190     LPWSTR Description;
191     LPWSTR IconPath;
192     /* not in the table, set during installation */
193     BOOL InstallMe;
194     MSIPROGID *CurVer;
195     MSIPROGID *VersionInd;
196 };
197
198 typedef struct tagMSIVERB
199 {
200     struct list entry;
201     LPWSTR Verb;
202     INT Sequence;
203     LPWSTR Command;
204     LPWSTR Argument;
205 } MSIVERB;
206
207 struct tagMSIMIME
208 {
209     struct list entry;
210     LPWSTR ContentType;  /* Primary Key */
211     MSIEXTENSION *Extension;
212     LPWSTR clsid;
213     MSICLASS *Class;
214     /* not in the table, set during installation */
215     BOOL InstallMe;
216 };
217
218 enum SCRIPTS {
219         INSTALL_SCRIPT = 0,
220         COMMIT_SCRIPT = 1,
221         ROLLBACK_SCRIPT = 2,
222         TOTAL_SCRIPTS = 3
223 };
224
225 #define SEQUENCE_UI       0x1
226 #define SEQUENCE_EXEC     0x2
227 #define SEQUENCE_INSTALL  0x10
228
229 typedef struct tagMSISCRIPT
230 {
231     LPWSTR  *Actions[TOTAL_SCRIPTS];
232     UINT    ActionCount[TOTAL_SCRIPTS];
233     BOOL    ExecuteSequenceRun;
234     BOOL    CurrentlyScripting;
235     UINT    InWhatSequence;
236     LPWSTR  *UniqueActions;
237     UINT    UniqueActionsCount;
238 } MSISCRIPT;
239
240
241 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, BOOL force);
242 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action);
243 extern void ACTION_FinishCustomActions( MSIPACKAGE* package);
244 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, BOOL execute);
245
246 /* actions in other modules */
247 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
248 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
249 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
250 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
251 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
252 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
253 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
254 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
255 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
256 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
257
258
259 /* Helpers */
260 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
261 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
262 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
263 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
264 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, 
265                       BOOL set_prop, MSIFOLDER **folder);
266 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
267 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
268 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
269 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
270 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
271 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
272 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
273 extern LPWSTR build_directory_name(DWORD , ...);
274 extern BOOL create_full_pathW(const WCHAR *path);
275 extern BOOL ACTION_VerifyComponentForAction(MSICOMPONENT*, INSTALLSTATE);
276 extern BOOL ACTION_VerifyFeatureForAction(MSIFEATURE*, INSTALLSTATE);
277 extern void reduce_to_longfilename(WCHAR*);
278 extern void reduce_to_shortfilename(WCHAR*);
279 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
280 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
281 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
282 extern BOOL check_unique_action(MSIPACKAGE *, LPCWSTR);
283 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
284 extern UINT msi_create_component_directories( MSIPACKAGE *package );
285
286
287 /* control event stuff */
288 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
289                                       MSIRECORD *data);
290 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
291 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, LPCWSTR event,
292                                    LPCWSTR control, LPCWSTR attribute);
293 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
294                                       LPCWSTR control, LPCWSTR attribute );
295
296 /* User Interface messages from the actions */
297 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
298 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
299
300
301 /* string consts use a number of places  and defined in helpers.c*/
302 extern const WCHAR cszSourceDir[];
303 extern const WCHAR szProductCode[];
304 extern const WCHAR cszRootDrive[];
305 extern const WCHAR cszbs[];
306
307 #endif /* __MSI_ACTION_H__ */