MSI: implement SetTargetPath, start the basics for tracking UI level
Mike McCormack
mike at codeweavers.com
Thu Jul 1 10:20:00 CDT 2004
ChangeLog:
<aric at codeweavers.com>
* implement SetTargetPath, start the basics for tracking UI level
-------------- next part --------------
diff -u dlls/msi.old/action.c dlls/msi/action.c
--- dlls/msi.old/action.c 2004-07-01 10:13:47.000000000 -0500
+++ dlls/msi/action.c 2004-07-01 10:15:22.000000000 -0500
@@ -52,6 +52,9 @@
/*
* Prototypes
*/
+static UINT ACTION_ProcessExecSequence(MSIHANDLE hPackage, BOOL UIran);
+static UINT ACTION_ProcessUISequence(MSIHANDLE hPackage);
+
UINT ACTION_PerformAction(MSIHANDLE hPackage, const WCHAR *action);
static UINT ACTION_CostInitialize(MSIHANDLE hPackage);
static UINT ACTION_CreateFolders(MSIHANDLE hPackage);
@@ -104,13 +107,9 @@
UINT ACTION_DoTopLevelINSTALL(MSIHANDLE hPackage, LPCWSTR szPackagePath,
LPCWSTR szCommandLine)
{
- MSIHANDLE view;
+ DWORD sz;
+ CHAR buffer[10];
UINT rc;
- static const CHAR *ExecSeqQuery =
-"select * from InstallExecuteSequence where Sequence > 0 order by Sequence";
- MSIHANDLE db;
-
- FIXME("****We do not do any of the UI level stuff yet***\n");
if (szPackagePath)
{
@@ -128,7 +127,8 @@
}
size = MAX_PATH;
- if (MsiGetPropertyW(hPackage,cszSourceDir,check,&size) != ERROR_SUCCESS )
+ if (MsiGetPropertyW(hPackage,cszSourceDir,check,&size)
+ != ERROR_SUCCESS )
MsiSetPropertyW(hPackage, cszSourceDir, pth);
}
@@ -174,9 +174,57 @@
MsiSetPropertyW(hPackage,prop,val);
}
}
+
+ sz = 10;
+ if (MsiGetPropertyA(hPackage,"UILevel",buffer,&sz) == ERROR_SUCCESS)
+ {
+ if (atoi(buffer) >= INSTALLUILEVEL_REDUCED)
+ {
+ rc = ACTION_ProcessUISequence(hPackage);
+ if (rc == ERROR_SUCCESS)
+ rc = ACTION_ProcessExecSequence(hPackage,TRUE);
+ }
+ else
+ rc = ACTION_ProcessExecSequence(hPackage,FALSE);
+ }
+ else
+ rc = ACTION_ProcessExecSequence(hPackage,FALSE);
+
+ return rc;
+}
+
+
+static UINT ACTION_ProcessExecSequence(MSIHANDLE hPackage, BOOL UIran)
+{
+ MSIHANDLE view;
+ UINT rc;
+ static const CHAR *ExecSeqQuery =
+"select * from InstallExecuteSequence where Sequence > %i order by Sequence";
+ CHAR Query[1024];
+ MSIHANDLE db;
+ MSIHANDLE row = 0;
db = MsiGetActiveDatabase(hPackage);
- rc = MsiDatabaseOpenViewA(db, ExecSeqQuery, &view);
+
+ if (UIran)
+ {
+ INT seq = 0;
+ static const CHAR *IVQuery =
+"select Sequence from InstallExecuteSequence where Action = `InstallValidate`" ;
+
+ MsiDatabaseOpenViewA(db, IVQuery, &view);
+ MsiViewExecute(view, 0);
+ MsiViewFetch(view,&row);
+ seq = MsiRecordGetInteger(row,1);
+ MsiCloseHandle(row);
+ MsiViewClose(view);
+ MsiCloseHandle(view);
+ sprintf(Query,ExecSeqQuery,0);
+ }
+ else
+ sprintf(Query,ExecSeqQuery,0);
+
+ rc = MsiDatabaseOpenViewA(db, Query, &view);
MsiCloseHandle(db);
if (rc == ERROR_SUCCESS)
@@ -196,7 +244,6 @@
{
WCHAR buffer[0x100];
DWORD sz = 0x100;
- MSIHANDLE row = 0;
rc = MsiViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
@@ -256,6 +303,93 @@
}
+static UINT ACTION_ProcessUISequence(MSIHANDLE hPackage)
+{
+ MSIHANDLE view;
+ UINT rc;
+ static const CHAR *ExecSeqQuery =
+"select * from InstallUISequence where Sequence > 0 order by Sequence";
+ MSIHANDLE db;
+
+ db = MsiGetActiveDatabase(hPackage);
+ rc = MsiDatabaseOpenViewA(db, ExecSeqQuery, &view);
+ MsiCloseHandle(db);
+
+ if (rc == ERROR_SUCCESS)
+ {
+ rc = MsiViewExecute(view, 0);
+
+ if (rc != ERROR_SUCCESS)
+ {
+ MsiViewClose(view);
+ MsiCloseHandle(view);
+ goto end;
+ }
+
+ TRACE("Running the actions \n");
+
+ while (1)
+ {
+ WCHAR buffer[0x100];
+ DWORD sz = 0x100;
+ MSIHANDLE row = 0;
+
+ rc = MsiViewFetch(view,&row);
+ if (rc != ERROR_SUCCESS)
+ {
+ rc = ERROR_SUCCESS;
+ break;
+ }
+
+ /* check conditions */
+ if (!MsiRecordIsNull(row,2))
+ {
+ sz=0x100;
+ rc = MsiRecordGetStringW(row,2,buffer,&sz);
+ if (rc != ERROR_SUCCESS)
+ {
+ MsiCloseHandle(row);
+ break;
+ }
+
+ if (MsiEvaluateConditionW(hPackage, buffer) ==
+ MSICONDITION_FALSE)
+ {
+ MsiCloseHandle(row);
+ continue;
+ }
+
+ }
+
+ sz=0x100;
+ rc = MsiRecordGetStringW(row,1,buffer,&sz);
+ if (rc != ERROR_SUCCESS)
+ {
+ ERR("Error is %x\n",rc);
+ MsiCloseHandle(row);
+ break;
+ }
+
+ rc = ACTION_PerformAction(hPackage,buffer);
+
+ if (rc != ERROR_SUCCESS)
+ {
+ ERR("Execution halted due to error (%i)\n",rc);
+ MsiCloseHandle(row);
+ break;
+ }
+
+ MsiCloseHandle(row);
+ }
+
+ MsiViewClose(view);
+ MsiCloseHandle(view);
+ }
+
+end:
+ return rc;
+}
+
/********************************************************
* ACTION helper functions and functions that perform the actions
*******************************************************/
@@ -2042,6 +2176,54 @@
return rc;
}
+
+UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder,
+ LPCSTR szFolderPath)
+{
+ LPWSTR szwFolder;
+ LPWSTR szwFolderPath;
+ UINT rc,len;
+
+ 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));
+
+ 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));
+
+ 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);
+ HeapFree(GetProcessHeap(),0,szwFolderPath);
+
+ return rc;
+}
+
+UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder,
+ LPCWSTR szFolderPath)
+{
+ TRACE("(%s %s)\n",debugstr_w(szFolder),debugstr_w(szFolderPath));
+
+ return MsiSetPropertyW(hInstall,szFolder,szFolderPath);
+}
+
BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, DWORD iRunMode)
{
FIXME("STUB (%li)\n",iRunMode);
diff -u dlls/msi.old/msi.c dlls/msi/msi.c
--- dlls/msi.old/msi.c 2004-07-01 10:13:47.000000000 -0500
+++ dlls/msi/msi.c 2004-07-01 10:15:22.000000000 -0500
@@ -62,6 +62,10 @@
static const WCHAR szComponents[] = {
'C','o','m','p','o','n','e','n','t','s',0 };
+/* the UI level */
+INSTALLUILEVEL gUILevel;
+HWND gUIhwnd;
+
/*
* .MSI file format
*
@@ -681,8 +685,17 @@
INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
{
- FIXME("%08x %p\n", dwUILevel, phWnd);
- return dwUILevel;
+ INSTALLUILEVEL old = gUILevel;
+ HWND oldwnd = gUIhwnd;
+ TRACE("%08x %p\n", dwUILevel, phWnd);
+
+ gUILevel = dwUILevel;
+ if (phWnd)
+ {
+ gUIhwnd = *phWnd;
+ *phWnd = oldwnd;
+ }
+ return old;
}
INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
@@ -1071,6 +1084,8 @@
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hinstDLL);
+ gUILevel = INSTALLUILEVEL_BASIC;
+ gUIhwnd = 0;
/* FIXME: Initialisation */
} else if (fdwReason == DLL_PROCESS_DETACH) {
/* FIXME: Cleanup */
diff -u dlls/msi.old/msi.spec dlls/msi/msi.spec
--- dlls/msi.old/msi.spec 2004-07-01 10:13:47.000000000 -0500
+++ dlls/msi/msi.spec 2004-07-01 10:15:22.000000000 -0500
@@ -143,8 +143,8 @@
143 stub MsiSetMode
144 stdcall MsiSetPropertyA(long str str)
145 stdcall MsiSetPropertyW(long wstr wstr)
-146 stub MsiSetTargetPathA
-147 stub MsiSetTargetPathW
+146 stdcall MsiSetTargetPathA(long str str)
+147 stdcall MsiSetTargetPathW(long wstr wstr)
148 stdcall MsiSummaryInfoGetPropertyA(long long ptr ptr ptr ptr ptr)
149 stdcall MsiSummaryInfoGetPropertyCount(long ptr)
150 stdcall MsiSummaryInfoGetPropertyW(long long ptr ptr ptr ptr ptr)
diff -u dlls/msi.old/msipriv.h dlls/msi/msipriv.h
--- dlls/msi.old/msipriv.h 2004-07-01 10:13:47.000000000 -0500
+++ dlls/msi/msipriv.h 2004-07-01 10:15:22.000000000 -0500
@@ -221,4 +221,9 @@
extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
extern void enum_stream_names( IStorage *stg );
+
+/* UI globals */
+extern INSTALLUILEVEL gUILevel;
+extern HWND gUIhwnd;
+
#endif /* __WINE_MSI_PRIVATE__ */
diff -u dlls/msi.old/package.c dlls/msi/package.c
--- dlls/msi.old/package.c 2004-07-01 10:13:47.000000000 -0500
+++ dlls/msi/package.c 2004-07-01 10:15:22.000000000 -0500
@@ -21,6 +21,7 @@
#define NONAMELESSUNION
#include <stdarg.h>
+#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
@@ -214,9 +215,6 @@
Time
Date
Privilaged
-DATABASE
-OriginalDatabase
-UILevel
*/
SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES_COMMON,NULL,0,pth);
@@ -270,6 +268,7 @@
MSIHANDLE handle;
MSIHANDLE db;
MSIPACKAGE *package;
+ CHAR uilevel[10];
static const WCHAR OriginalDatabase[] =
{'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
@@ -301,6 +300,8 @@
set_installer_properties(handle);
MsiSetPropertyW(handle, OriginalDatabase, szPackage);
MsiSetPropertyW(handle, Database, szPackage);
+ sprintf(uilevel,"%i",gUILevel);
+ MsiSetPropertyA(handle, "UILevel", uilevel);
*phPackage = handle;
@@ -396,10 +397,11 @@
if (!hInstall)
return ERROR_INVALID_HANDLE;
- if (MsiGetPropertyW(hInstall,szName,0,&sz)==ERROR_MORE_DATA)
+ rc = MsiGetPropertyW(hInstall,szName,0,&sz);
+ if (rc==ERROR_MORE_DATA || rc == ERROR_SUCCESS)
{
FIXME("Cannot set exising properties! FIXME MIKE!\n");
- return ERROR_FUNCTION_FAILED;
+ return ERROR_SUCCESS;
}
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
More information about the wine-patches
mailing list