MSI: cleanup of actions
Mike McCormack
mike at codeweavers.com
Fri Jul 9 13:20:56 CDT 2004
ChangeLog:
<aric at codeweavers.com>
* cleanup of actions
-------------- next part --------------
diff -ur dlls/msi.old/action.c dlls/msi/action.c
--- dlls/msi.old/action.c 2004-07-09 13:16:47.000000000 -0500
+++ dlls/msi/action.c 2004-07-09 13:17:25.000000000 -0500
@@ -61,6 +61,7 @@
INT Attributes;
INSTALLSTATE State;
+ BOOL Enabled;
INT ComponentCount;
INT Components[1024]; /* yes hardcoded limit.... I am bad */
INT Cost;
@@ -232,6 +233,18 @@
return ret;
}
+inline static WCHAR *strdupAtoW( const char *str )
+{
+ WCHAR *ret = NULL;
+ if (str)
+ {
+ DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
+ if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
+ MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
+ }
+ return ret;
+}
+
inline static WCHAR *load_dynamic_stringW(MSIHANDLE row, INT index)
{
DWORD sz;
@@ -401,6 +414,7 @@
HeapFree(GetProcessHeap(),0,ActionFormat);
ActionFormat = load_dynamic_stringW(row,3);
+ strcpyW(LastAction,action);
MsiCloseHandle(row);
MsiViewClose(view);
MsiCloseHandle(view);
@@ -1133,7 +1147,8 @@
strcpyW(info.target,target);
strcpyW(info.source,tmp_file);
TRACE("Start Asyncronous execution\n");
- CreateThread(NULL,0,DllThread,(LPVOID)&info,0,&ThreadId);
+ FIXME("DATABASE NOT THREADSAFE... not starting\n");
+// CreateThread(NULL,0,DllThread,(LPVOID)&info,0,&ThreadId);
return ERROR_SUCCESS;
}
@@ -2973,6 +2988,7 @@
{
TRACE("Override of install level found\n");
feature_state = TRUE;
+ package->features[i].Enabled = feature_state;
}
TRACE("Feature %s has a state of %i\n",
@@ -4086,7 +4102,7 @@
UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction )
{
LPWSTR szwAction;
- UINT len,rc;
+ UINT rc;
TRACE(" exteral attempt at action %s\n",szAction);
@@ -4095,13 +4111,11 @@
if (hInstall == 0)
return ERROR_FUNCTION_FAILED;
- len = MultiByteToWideChar( CP_ACP, 0, szAction, -1, NULL, 0);
- szwAction = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR));
+ szwAction = strdupAtoW(szAction);
if (!szwAction)
return ERROR_FUNCTION_FAILED;
- MultiByteToWideChar( CP_ACP, 0, szAction, -1, szwAction, len);
rc = MsiDoActionW(hInstall, szwAction);
HeapFree(GetProcessHeap(),0,szwAction);
@@ -4119,7 +4133,7 @@
{
LPWSTR szwFolder;
LPWSTR szwPathBuf;
- UINT len,rc;
+ UINT rc;
TRACE("getting folder %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf);
@@ -4128,16 +4142,13 @@
if (hInstall == 0)
return ERROR_FUNCTION_FAILED;
- len = MultiByteToWideChar( CP_ACP, 0, szFolder, -1, NULL, 0);
- szwFolder= HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR));
+ szwFolder = strdupAtoW(szFolder);
if (!szwFolder)
return ERROR_FUNCTION_FAILED;
szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, szFolder, -1, szwFolder, len);
-
rc = MsiGetTargetPathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf);
WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf,
@@ -4180,7 +4191,7 @@
{
LPWSTR szwFolder;
LPWSTR szwPathBuf;
- UINT len,rc;
+ UINT rc;
TRACE("getting source %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf);
@@ -4189,16 +4200,12 @@
if (hInstall == 0)
return ERROR_FUNCTION_FAILED;
- len = MultiByteToWideChar( CP_ACP, 0, szFolder, -1, NULL, 0);
- szwFolder= HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR));
-
+ szwFolder = strdupAtoW(szFolder);
if (!szwFolder)
return ERROR_FUNCTION_FAILED;
szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, szFolder, -1, szwFolder, len);
-
rc = MsiGetSourcePathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf);
WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf,
@@ -4240,32 +4247,24 @@
{
LPWSTR szwFolder;
LPWSTR szwFolderPath;
- UINT rc,len;
+ UINT rc;
if (!szFolder)
return ERROR_FUNCTION_FAILED;
if (hInstall == 0)
return ERROR_FUNCTION_FAILED;
- len = MultiByteToWideChar( CP_ACP, 0, szFolder, -1, NULL, 0);
- szwFolder= HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR));
-
+ szwFolder = strdupAtoW(szFolder);
if (!szwFolder)
return ERROR_FUNCTION_FAILED;
- MultiByteToWideChar( CP_ACP, 0, szFolder, -1, szwFolder, len);
-
- len = MultiByteToWideChar( CP_ACP, 0, szFolderPath, -1, NULL, 0);
- szwFolderPath= HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR));
-
+ szwFolderPath = strdupAtoW(szFolderPath);
if (!szwFolderPath)
{
HeapFree(GetProcessHeap(),0,szwFolder);
return ERROR_FUNCTION_FAILED;
}
- MultiByteToWideChar( CP_ACP, 0, szFolderPath, -1, szwFolderPath, len);
-
rc = MsiSetTargetPathW(hInstall, szwFolder, szwFolderPath);
HeapFree(GetProcessHeap(),0,szwFolder);
@@ -4318,6 +4317,142 @@
return FALSE;
}
+/*
+ * according to the docs when this is called it immediently recalculates all the
+ * components states as well
+ */
+UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature,
+ INSTALLSTATE iState)
+{
+ LPWSTR szwFeature = NULL;
+ UINT rc;
+
+ szwFeature = strdupAtoW(szFeature);
+
+ if (!szwFeature)
+ return ERROR_FUNCTION_FAILED;
+
+ rc = MsiSetFeatureStateW(hInstall,szwFeature, iState);
+
+ HeapFree(GetProcessHeap(),0,szwFeature);
+
+ return rc;
+}
+
+UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
+ INSTALLSTATE iState)
+{
+ MSIPACKAGE* package;
+ INT index;
+
+ TRACE(" %s to %i\n",debugstr_w(szFeature), iState);
+
+ package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
+ if (!package)
+ return ERROR_INVALID_HANDLE;
+
+ index = get_loaded_feature(package,szFeature);
+ if (index < 0)
+ return ERROR_UNKNOWN_FEATURE;
+
+ package->features[index].State = iState;
+
+ return ERROR_SUCCESS;
+}
+
+UINT WINAPI MsiGetFeatureStateA(MSIHANDLE hInstall, LPSTR szFeature,
+ INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
+{
+ LPWSTR szwFeature = NULL;
+ UINT rc;
+
+ szwFeature = strdupAtoW(szFeature);
+
+ rc = MsiGetFeatureStateW(hInstall,szwFeature,piInstalled, piAction);
+
+ HeapFree( GetProcessHeap(), 0 , szwFeature);
+
+ return rc;
+}
+
+UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPWSTR szFeature,
+ INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
+{
+ MSIPACKAGE* package;
+ INT index;
+
+ TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled,
+piAction);
+
+ package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
+ if (!package)
+ return ERROR_INVALID_HANDLE;
+
+ index = get_loaded_feature(package,szFeature);
+ if (index < 0)
+ return ERROR_UNKNOWN_FEATURE;
+
+ if (piInstalled)
+ *piInstalled = package->features[index].State;
+
+ if (piAction)
+ {
+ if (package->features[index].Enabled)
+ *piAction = INSTALLSTATE_LOCAL;
+ else
+ *piAction = INSTALLSTATE_UNKNOWN;
+ }
+
+ return ERROR_SUCCESS;
+}
+
+UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szComponent,
+ INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
+{
+ LPWSTR szwComponent= NULL;
+ UINT rc;
+
+ szwComponent= strdupAtoW(szComponent);
+
+ rc = MsiGetComponentStateW(hInstall,szwComponent,piInstalled, piAction);
+
+ HeapFree( GetProcessHeap(), 0 , szwComponent);
+
+ return rc;
+}
+
+UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPWSTR szComponent,
+ INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
+{
+ MSIPACKAGE* package;
+ INT index;
+
+ TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szComponent), piInstalled,
+piAction);
+
+ package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
+ if (!package)
+ return ERROR_INVALID_HANDLE;
+
+ index = get_loaded_component(package,szComponent);
+ if (index < 0)
+ return ERROR_UNKNOWN_COMPONENT;
+
+ if (piInstalled)
+ *piInstalled = package->components[index].State;
+
+ if (piAction)
+ {
+ if (package->components[index].Enabled &&
+ package->components[index].FeatureState)
+ *piAction = INSTALLSTATE_LOCAL;
+ else
+ *piAction = INSTALLSTATE_UNKNOWN;
+ }
+
+ return ERROR_SUCCESS;
+}
+
#if 0
static UINT ACTION_Template(MSIHANDLE hPackage)
{
diff -ur dlls/msi.old/msi.c dlls/msi/msi.c
--- dlls/msi.old/msi.c 2004-07-09 13:16:47.000000000 -0500
+++ dlls/msi/msi.c 2004-07-09 13:17:25.000000000 -0500
@@ -1096,6 +1096,101 @@
return ERROR_CALL_NOT_IMPLEMENTED;
}
+INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
+ LPSTR lpPathBuf, DWORD* pcchBuf)
+{
+ INSTALLSTATE rc;
+ UINT len;
+ LPWSTR szwProduct= NULL;
+ LPWSTR szwComponent= NULL;
+ LPWSTR lpwPathBuf= NULL;
+
+ if( szProduct)
+ {
+ len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
+ szwProduct= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+ if( !szwProduct)
+ return ERROR_OUTOFMEMORY;
+ MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
+ }
+
+ if( szComponent)
+ {
+ len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
+ szwComponent= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+ if( !szwComponent)
+ return ERROR_OUTOFMEMORY;
+ MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
+ }
+
+ if (pcchBuf && *pcchBuf > 0)
+ lpwPathBuf = HeapAlloc( GetProcessHeap(), 0, *pcchBuf * sizeof(WCHAR));
+ else
+ lpwPathBuf = NULL;
+
+ rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf);
+
+ HeapFree( GetProcessHeap(), 0, szwProduct);
+ HeapFree( GetProcessHeap(), 0, szwComponent);
+ if (lpwPathBuf)
+ {
+ WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, *pcchBuf,
+ lpPathBuf, GUID_SIZE, NULL, NULL);
+ HeapFree( GetProcessHeap(), 0, lpwPathBuf);
+ }
+
+ return rc;
+}
+
+INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
+ LPWSTR lpPathBuf, DWORD* pcchBuf)
+{
+ FIXME("STUB: (%s %s %p %p)\n", debugstr_w(szProduct),
+ debugstr_w(szComponent), lpPathBuf, pcchBuf);
+
+ return INSTALLSTATE_UNKNOWN;
+}
+
+INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
+{
+ INSTALLSTATE rc;
+ UINT len;
+ LPWSTR szwProduct= NULL;
+ LPWSTR szwFeature= NULL;
+
+ if( szProduct)
+ {
+ len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
+ szwProduct= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+ if( !szwProduct)
+ return ERROR_OUTOFMEMORY;
+ MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
+ }
+
+ if( szFeature)
+ {
+ len = MultiByteToWideChar( CP_ACP, 0, szFeature, -1, NULL, 0 );
+ szwFeature= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+ if( !szwFeature)
+ return ERROR_OUTOFMEMORY;
+ MultiByteToWideChar( CP_ACP, 0, szFeature, -1, szwFeature, len );
+ }
+
+ rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
+
+ HeapFree( GetProcessHeap(), 0, szwProduct);
+ HeapFree( GetProcessHeap(), 0, szwFeature);
+
+ return rc;
+}
+
+INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
+{
+ FIXME("STUB: (%s %s)\n", debugstr_w(szProduct), debugstr_w(szFeature));
+ return INSTALLSTATE_UNKNOWN;
+}
+
+
/******************************************************************
* DllMain
*
diff -ur dlls/msi.old/msi.spec dlls/msi/msi.spec
--- dlls/msi.old/msi.spec 2004-07-09 13:16:47.000000000 -0500
+++ dlls/msi/msi.spec 2004-07-09 13:17:25.000000000 -0500
@@ -107,8 +107,8 @@
107 stub MsiProvideComponentW
108 stub MsiProvideQualifiedComponentA
109 stub MsiProvideQualifiedComponentW
-110 stub MsiQueryFeatureStateA
-111 stub MsiQueryFeatureStateW
+110 stdcall MsiQueryFeatureStateA(str str)
+111 stdcall MsiQueryFeatureStateW(wstr wstr)
112 stdcall MsiQueryProductStateA(str)
113 stdcall MsiQueryProductStateW(wstr)
114 stdcall MsiRecordDataSize(long long)
@@ -135,8 +135,8 @@
135 stub MsiSetComponentStateW
136 stdcall MsiSetExternalUIA(ptr long ptr)
137 stub MsiSetExternalUIW
-138 stub MsiSetFeatureStateA
-139 stub MsiSetFeatureStateW
+138 stdcall MsiSetFeatureStateA(long str long)
+139 stdcall MsiSetFeatureStateW(long wstr long)
140 stub MsiSetInstallLevel
141 stdcall MsiSetInternalUI(long ptr)
142 stub MsiVerifyDiskSpace
@@ -169,8 +169,8 @@
169 stdcall MsiEnableLogW(long wstr long)
170 stdcall MsiFormatRecordA(long long ptr ptr)
171 stdcall MsiFormatRecordW(long long ptr ptr)
-172 stub MsiGetComponentPathA
-173 stub MsiGetComponentPathW
+172 stdcall MsiGetComponentPathA(str str ptr ptr)
+173 stdcall MsiGetComponentPathW(wstr wstr ptr ptr)
174 stub MsiApplyPatchA
175 stub MsiApplyPatchW
176 stub MsiAdvertiseScriptA
diff -ur dlls/msi.old/msiquery.c dlls/msi/msiquery.c
--- dlls/msi.old/msiquery.c 2004-07-09 13:16:47.000000000 -0500
+++ dlls/msi/msiquery.c 2004-07-09 13:17:25.000000000 -0500
@@ -398,34 +398,6 @@
return ERROR_CALL_NOT_IMPLEMENTED;
}
-UINT WINAPI MsiGetFeatureStateA(MSIHANDLE hInstall, LPSTR szFeature,
- INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
-{
- FIXME("%ld %s %p %p\n", hInstall, debugstr_a(szFeature), piInstalled, piAction);
- return ERROR_CALL_NOT_IMPLEMENTED;
-}
-
-UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPWSTR szFeature,
- INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
-{
- FIXME("%ld %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled, piAction);
- return ERROR_CALL_NOT_IMPLEMENTED;
-}
-
-UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szFeature,
- INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
-{
- FIXME("%ld %s %p %p\n", hInstall, debugstr_a(szFeature), piInstalled, piAction);
- return ERROR_CALL_NOT_IMPLEMENTED;
-}
-
-UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPWSTR szFeature,
- INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
-{
- FIXME("%ld %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled, piAction);
- return ERROR_CALL_NOT_IMPLEMENTED;
-}
-
UINT WINAPI MsiViewModify(MSIHANDLE hView, MSIMODIFY eModifyMode, MSIHANDLE
hRecord)
{
More information about the wine-patches
mailing list