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