From 2e9b5f7c0705cd4928e64c812a64f2670ab0b90a Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Sun, 4 Jul 2004 00:31:17 +0000 Subject: [PATCH] Use the newly implemented UPDATE code to set properties. --- dlls/msi/action.c | 2 ++ dlls/msi/msi.c | 19 ++++++++-- dlls/msi/msipriv.h | 3 ++ dlls/msi/package.c | 88 +++++++++++++++++++++++++++++++++++++--------- 4 files changed, 94 insertions(+), 18 deletions(-) diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 0bd6f4ea92a..ab0c53274e2 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -1245,6 +1245,8 @@ static UINT ACTION_CostFinalize(MSIHANDLE hPackage) MsiViewClose(view); MsiCloseHandle(view); + MsiSetPropertyA(hPackage,"CostingComplete","1"); + return ERROR_SUCCESS; } diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index ac46c216194..906fa87a760 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -65,6 +65,9 @@ static const WCHAR szComponents[] = { /* the UI level */ INSTALLUILEVEL gUILevel; HWND gUIhwnd; +INSTALLUI_HANDLERA gUIHandler; +DWORD gUIFilter; +LPVOID gUIContext; /* * .MSI file format @@ -701,8 +704,14 @@ INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd) INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler, DWORD dwMessageFilter, LPVOID pvContext) { - FIXME("STUB\n"); - return NULL; + INSTALLUI_HANDLERA prev = gUIHandler; + + TRACE("(%p %lx %p)\n",puiHandler,dwMessageFilter,pvContext); + gUIHandler = puiHandler; + gUIFilter = dwMessageFilter; + gUIContext = pvContext; + + return prev; } UINT WINAPI MsiLoadStringA(HINSTANCE hInstance, UINT uID, LPSTR lpBuffer, int nBufferMax, DWORD e) @@ -1084,8 +1093,14 @@ UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage ) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { if (fdwReason == DLL_PROCESS_ATTACH) { DisableThreadLibraryCalls(hinstDLL); + /* + * UI Initialization + */ gUILevel = INSTALLUILEVEL_BASIC; gUIhwnd = 0; + gUIHandler = NULL; + gUIFilter = 0; + gUIContext = NULL; /* FIXME: Initialisation */ } else if (fdwReason == DLL_PROCESS_DETACH) { /* FIXME: Cleanup */ diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 7451a52112e..35a5d9dfbef 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -225,5 +225,8 @@ extern void enum_stream_names( IStorage *stg ); /* UI globals */ extern INSTALLUILEVEL gUILevel; extern HWND gUIhwnd; +extern INSTALLUI_HANDLERA gUIHandler; +extern DWORD gUIFilter; +extern LPVOID gUIContext; #endif /* __WINE_MSI_PRIVATE__ */ diff --git a/dlls/msi/package.c b/dlls/msi/package.c index c6ee8790a03..d147b162305 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -338,7 +338,43 @@ MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall) INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType, MSIHANDLE hRecord) { - FIXME("STUB: \n"); + DWORD log_type = 0; + LPSTR message; + DWORD sz; + INT msg_field=1; + FIXME("STUB: %x \n",eMessageType); + + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ERROR) + log_type |= INSTALLLOGMODE_ERROR; + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_WARNING) + log_type |= INSTALLLOGMODE_WARNING; + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_USER) + log_type |= INSTALLLOGMODE_USER; + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_INFO) + log_type |= INSTALLLOGMODE_INFO; + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_COMMONDATA) + log_type |= INSTALLLOGMODE_COMMONDATA; + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART) + { + log_type |= INSTALLLOGMODE_ACTIONSTART; + msg_field = 2; + } + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONDATA) + log_type |= INSTALLLOGMODE_ACTIONDATA; + + sz = 0; + MsiRecordGetStringA(hRecord,msg_field,NULL,&sz); + sz++; + message = HeapAlloc(GetProcessHeap(),0,sz); + MsiRecordGetStringA(hRecord,msg_field,message,&sz); + + TRACE("(%p %lx %lx)\n",gUIHandler, gUIFilter, log_type); + if (gUIHandler && (gUIFilter & log_type)) + gUIHandler(gUIContext,eMessageType,message); + else + TRACE("%s\n",debugstr_a(message)); + + HeapFree(GetProcessHeap(),0,message); return ERROR_SUCCESS; } @@ -388,8 +424,17 @@ UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue MSIHANDLE view,row; UINT rc; DWORD sz = 0; - static const CHAR Insert[]= - "INSERT into `_Property` (`_Property`,`Value`) VALUES (?)"; + static const WCHAR Insert[]= + {'I','N','S','E','R','T',' ','i','n','t','o',' ','`','_','P','r','o','p' +,'e','r','t','y','`',' ','(','`','_','P','r','o','p','e','r','t','y','`' +,',','`','V','a','l','u','e','`',')',' ','V','A','L','U','E','S' +,' ','(','?',')',0}; + static const WCHAR Update[]= + {'U','P','D','A','T','E',' ','_','P','r','o','p','e' +,'r','t','y',' ','s','e','t',' ','`','V','a','l','u','e','`',' ','=' +,' ','?',' ','w','h','e','r','e',' ','`','_','P','r','o','p' +,'e','r','t','y','`',' ','=',' ','\'','%','s','\'',0}; + WCHAR Query[1024]; TRACE("Setting property (%s %s)\n",debugstr_w(szName), debugstr_w(szValue)); @@ -397,24 +442,35 @@ UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue if (!hInstall) return ERROR_INVALID_HANDLE; - rc = MsiGetPropertyW(hInstall,szName,0,&sz); - if (rc==ERROR_MORE_DATA || rc == ERROR_SUCCESS) - { - FIXME("Cannot set exising properties! FIXME MIKE!\n"); - return ERROR_SUCCESS; - } - package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE); if( !package) return ERROR_INVALID_HANDLE; - rc = MsiDatabaseOpenViewA(package->db,Insert,&view); - if (rc!= ERROR_SUCCESS) - return rc; + rc = MsiGetPropertyW(hInstall,szName,0,&sz); + if (rc==ERROR_MORE_DATA || rc == ERROR_SUCCESS) + { + sprintfW(Query,Update,szName); - row = MsiCreateRecord(2); - MsiRecordSetStringW(row,1,szName); - MsiRecordSetStringW(row,2,szValue); + row = MsiCreateRecord(1); + MsiRecordSetStringW(row,1,szValue); + + } + else + { + strcpyW(Query,Insert); + + row = MsiCreateRecord(2); + MsiRecordSetStringW(row,1,szName); + MsiRecordSetStringW(row,2,szValue); + } + + + rc = MsiDatabaseOpenViewW(package->db,Query,&view); + if (rc!= ERROR_SUCCESS) + { + MsiCloseHandle(row); + return rc; + } rc = MsiViewExecute(view,row);