Reverse the order for deleting the items in resetcontent to correctly
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 typedef struct tagMSIFEATURE
22 {
23     WCHAR Feature[96];
24     WCHAR Feature_Parent[96];
25     WCHAR Title[0x100];
26     WCHAR Description[0x100];
27     INT Display;
28     INT Level;
29     WCHAR Directory[96];
30     INT Attributes;
31     
32     INSTALLSTATE Installed;
33     INSTALLSTATE ActionRequest;
34     INSTALLSTATE Action;
35
36     INT ComponentCount;
37     INT Components[1024]; /* yes hardcoded limit.... I am bad */
38     INT Cost;
39 } MSIFEATURE;
40
41 typedef struct tagMSICOMPONENT
42 {
43     WCHAR Component[96];
44     WCHAR ComponentId[96];
45     WCHAR Directory[96];
46     INT Attributes;
47     WCHAR Condition[0x100];
48     WCHAR KeyPath[96];
49
50     INSTALLSTATE Installed;
51     INSTALLSTATE ActionRequest;
52     INSTALLSTATE Action;
53
54     BOOL Enabled;
55     INT  Cost;
56 } MSICOMPONENT;
57
58 typedef struct tagMSIFOLDER
59 {
60     LPWSTR Directory;
61     LPWSTR TargetDefault;
62     LPWSTR SourceDefault;
63
64     LPWSTR ResolvedTarget;
65     LPWSTR ResolvedSource;
66     LPWSTR Property;   /* initially set property */
67     INT   ParentIndex;
68     INT   State;
69         /* 0 = uninitialized */
70         /* 1 = existing */
71         /* 2 = created remove if empty */
72         /* 3 = created persist if empty */
73     INT   Cost;
74     INT   Space;
75 }MSIFOLDER;
76
77 typedef struct tagMSIFILE
78 {
79     LPWSTR File;
80     INT ComponentIndex;
81     LPWSTR FileName;
82     INT FileSize;
83     LPWSTR Version;
84     LPWSTR Language;
85     INT Attributes;
86     INT Sequence;   
87
88     INT State;
89        /* 0 = uninitialize */
90        /* 1 = not present */
91        /* 2 = present but replace */
92        /* 3 = present do not replace */
93        /* 4 = Installed */
94     LPWSTR  SourcePath;
95     LPWSTR  TargetPath;
96     BOOL    Temporary; 
97 }MSIFILE;
98
99
100 UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action);
101 UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action);
102 void ACTION_FinishCustomActions( MSIPACKAGE* package);
103 UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, BOOL execute);
104 void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
105 UINT ACTION_AppSearch(MSIPACKAGE *package);
106
107 DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
108 WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index);
109 LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop, UINT* rc);
110 LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, 
111                       BOOL set_prop, MSIFOLDER **folder);
112 int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component );
113 int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature );
114 int get_loaded_file(MSIPACKAGE* package, LPCWSTR file);
115 int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
116
117
118
119 inline static char *strdupWtoA( const WCHAR *str )
120 {
121     char *ret = NULL;
122     if (str)
123     {
124         DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL
125 );
126         if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
127             WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
128     }
129     return ret;
130 }
131
132 inline static WCHAR *strdupAtoW( const char *str )
133 {
134     WCHAR *ret = NULL;
135     if (str)
136     {
137         DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
138         if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
139             MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
140     }
141     return ret;
142 }
143
144 inline static LPWSTR dupstrW(LPCWSTR src)
145 {
146     LPWSTR dest;
147     if (!src) return NULL;
148     dest = HeapAlloc(GetProcessHeap(), 0, (strlenW(src)+1)*sizeof(WCHAR));
149     strcpyW(dest, src);
150     return dest;
151 }