Keep the checkGLcall glActiveTexture/glActiveTextureARB separation in
[wine] / dlls / msi / suminfo.c
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002 Mike McCormack 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 #define NONAMELESSUNION
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
28 #include "winnls.h"
29 #include "shlwapi.h"
30 #include "wine/debug.h"
31 #include "msi.h"
32 #include "msiquery.h"
33 #include "msipriv.h"
34 #include "objidl.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(msi);
37
38 const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
39                        'I','n','f','o','r','m','a','t','i','o','n',0 };
40
41 static void MSI_CloseSummaryInfo( VOID *arg )
42 {
43     MSISUMMARYINFO *suminfo = (MSISUMMARYINFO *) arg;
44     IPropertyStorage_Release( suminfo->propstg );
45 }
46
47 UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, 
48               LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
49 {
50     LPWSTR szwDatabase = NULL;
51     UINT ret;
52
53     TRACE("%ld %s %d %p\n", hDatabase, debugstr_a(szDatabase), 
54           uiUpdateCount, phSummaryInfo);
55
56     if( szDatabase )
57     {
58         UINT len = MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, NULL, 0 );
59         szwDatabase = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
60         if( !szwDatabase )
61             return ERROR_FUNCTION_FAILED;
62         MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, szwDatabase, len );
63     }
64
65     ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, phSummaryInfo);
66
67     if( szwDatabase )
68         HeapFree( GetProcessHeap(), 0, szwDatabase );
69
70     return ret;
71 }
72
73 UINT WINAPI MsiGetSummaryInformationW(MSIHANDLE hDatabase, 
74               LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
75 {
76     HRESULT r;
77     MSIHANDLE handle, hdb = hDatabase;
78     MSISUMMARYINFO *suminfo;
79     MSIDATABASE *db;
80     UINT ret = ERROR_SUCCESS;
81     IPropertySetStorage *psstg = NULL;
82     IPropertyStorage *ps = NULL;
83     DWORD grfMode;
84
85     TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
86            uiUpdateCount, phSummaryInfo);
87
88     if( !phSummaryInfo )
89         return ERROR_INVALID_PARAMETER;
90
91     if( szDatabase )
92     {
93         UINT res;
94
95         res = MsiOpenDatabaseW(szDatabase, NULL, &hdb);
96         if( res != ERROR_SUCCESS )
97             return res;
98     }
99
100     db = msihandle2msiinfo(hdb, MSIHANDLETYPE_DATABASE);
101     if( !db )
102         return ERROR_INVALID_PARAMETER;
103
104     r = IStorage_QueryInterface( db->storage, 
105              &IID_IPropertySetStorage, (LPVOID)&psstg);
106     if( FAILED( r ) )
107     {
108         ERR("IStorage -> IPropertySetStorage failed\n");
109         return ERROR_FUNCTION_FAILED;
110     }
111     ERR("storage = %p propertysetstorage = %p\n", db->storage, psstg);
112
113     grfMode = STGM_READ | STGM_SHARE_EXCLUSIVE;
114     r = IPropertySetStorage_Open( psstg, &FMTID_SummaryInformation, grfMode, &ps );
115     if( FAILED( r ) )
116     {
117         ERR("failed to get IPropertyStorage r=%08lx\n",r);
118         ret = ERROR_FUNCTION_FAILED;
119         goto end;
120     }
121
122     handle = alloc_msihandle( MSIHANDLETYPE_SUMMARYINFO, 
123                   sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo,
124                   (void**) &suminfo );
125     if( !handle )
126     {
127         ret = ERROR_FUNCTION_FAILED;
128         goto end;
129     }
130
131     IPropertyStorage_AddRef(ps);
132     suminfo->propstg = ps;
133     *phSummaryInfo = handle;
134
135 end:
136     if( ps )
137         IPropertyStorage_Release(ps);
138     if( psstg )
139         IPropertySetStorage_Release(psstg);
140     if( !hDatabase )
141         MsiCloseHandle( hdb );
142
143     return ret;
144 }
145
146 UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
147 {
148     MSISUMMARYINFO *suminfo;
149
150     FIXME("%ld %p\n",hSummaryInfo, pCount);
151
152     suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
153     if( !suminfo )
154         return ERROR_INVALID_HANDLE;
155
156     return ERROR_CALL_NOT_IMPLEMENTED;
157 }
158
159 UINT WINAPI MsiSummaryInfoGetPropertyA(
160       MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
161       FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)
162 {
163     MSISUMMARYINFO *suminfo;
164     HRESULT r;
165     PROPSPEC spec;
166     PROPVARIANT var;
167
168     TRACE("%ld %d %p %p %p %p %p\n",
169         hSummaryInfo, uiProperty, puiDataType, piValue,
170         pftValue, szValueBuf, pcchValueBuf);
171
172     suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
173     if( !suminfo )
174         return ERROR_INVALID_HANDLE;
175
176     spec.ulKind = PRSPEC_PROPID;
177     spec.u.propid = uiProperty;
178
179     r = IPropertyStorage_ReadMultiple( suminfo->propstg, 1, &spec, &var);
180     if( FAILED(r) )
181         return ERROR_FUNCTION_FAILED;
182
183     if( puiDataType )
184         *puiDataType = var.vt;
185
186     switch( var.vt )
187     {
188     case VT_I4:
189         if( piValue )
190             *piValue = var.u.lVal;
191         break;
192     case VT_LPSTR:
193         if( pcchValueBuf && szValueBuf )
194         {
195             lstrcpynA(szValueBuf, var.u.pszVal, *pcchValueBuf );
196             *pcchValueBuf = lstrlenA( var.u.pszVal );
197         }
198         break;
199     case VT_FILETIME:
200         if( pftValue )
201             memcpy(pftValue, &var.u.filetime, sizeof (FILETIME) );
202         break;
203     case VT_EMPTY:
204         break;
205     default:
206         FIXME("Unknown property variant type\n");
207         break;
208     }
209
210     return ERROR_SUCCESS;
211 }
212
213 UINT WINAPI MsiSummaryInfoGetPropertyW(
214       MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
215       FILETIME *pftValue, LPWSTR szValueBuf, DWORD *pcchValueBuf)
216 {
217     FIXME("%ld %d %p %p %p %p %p\n",
218         hSummaryInfo, uiProperty, puiDataType, piValue,
219         pftValue, szValueBuf, pcchValueBuf);
220     
221     return ERROR_CALL_NOT_IMPLEMENTED;
222 }