summaryrefslogtreecommitdiff
path: root/setup_native
diff options
context:
space:
mode:
authorGerd Weiss <gm@openoffice.org>2007-05-10 10:04:31 +0000
committerGerd Weiss <gm@openoffice.org>2007-05-10 10:04:31 +0000
commit6ab4bc1b8a28bf858e7c1c6e85e7062d80302c9a (patch)
tree7e36bfaff7811ff119da0c203fee4ccb5461adc4 /setup_native
parentea633c7b25b82aada56043b5f4c24def2e997a8c (diff)
INTEGRATION: CWS native82 (1.1.2); FILE ADDED
2007/03/26 14:14:33 dv 1.1.2.1: #i75394# This custom actions sets an error if there is a newer / older / same version / patch
Diffstat (limited to 'setup_native')
-rw-r--r--setup_native/source/win32/customactions/tools/checkversion.cxx153
1 files changed, 153 insertions, 0 deletions
diff --git a/setup_native/source/win32/customactions/tools/checkversion.cxx b/setup_native/source/win32/customactions/tools/checkversion.cxx
new file mode 100644
index 000000000000..01b28ddff2c6
--- /dev/null
+++ b/setup_native/source/win32/customactions/tools/checkversion.cxx
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: checkversion.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: gm $ $Date: 2007-05-10 11:04:31 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#define UNICODE
+
+#pragma warning(push,1) // disable warnings within system headers
+#include <windows.h>
+#include <msiquery.h>
+#pragma warning(pop)
+
+#include <string.h>
+#include <malloc.h>
+#include <stdio.h>
+#include "strsafe.h"
+
+#include <seterror.hxx>
+
+//----------------------------------------------------------
+BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
+{
+ DWORD sz = 0;
+ if ( MsiGetProperty( hMSI, pPropName, L"", &sz ) == ERROR_MORE_DATA )
+ {
+ sz++;
+ DWORD nbytes = sz * sizeof( wchar_t );
+ wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
+ ZeroMemory( buff, nbytes );
+ MsiGetProperty( hMSI, pPropName, buff, &sz );
+ *ppValue = buff;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//----------------------------------------------------------
+#ifdef DEBUG
+inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
+{
+ TCHAR buffer[1024];
+ va_list args;
+
+ va_start( args, pFormat );
+ StringCchVPrintf( buffer, sizeof(buffer), pFormat, args );
+ OutputDebugString( buffer );
+}
+#else
+static inline void OutputDebugStringFormat( LPCTSTR, ... )
+{
+}
+#endif
+
+//----------------------------------------------------------
+extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
+{
+ // MessageBox(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
+
+ wchar_t* pVal = NULL;
+
+ if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
+ {
+ OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal );
+ if ( *pVal != 0 )
+ SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND );
+ free( pVal );
+ }
+ pVal = NULL;
+ if ( GetMsiProp( hMSI, L"SAMEPRODUCTS", &pVal ) && pVal )
+ {
+ OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTS found [%s]"), pVal );
+ if ( *pVal != 0 )
+ SetMsiErrorCode( MSI_ERROR_SAME_VERSION_FOUND );
+ free( pVal );
+ }
+ pVal = NULL;
+ if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
+ {
+ OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal );
+ if ( *pVal != 0 )
+ SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND );
+ free( pVal );
+ }
+ pVal = NULL;
+ if ( GetMsiProp( hMSI, L"BETAPRODUCTS", &pVal ) && pVal )
+ {
+ OutputDebugStringFormat( TEXT("DEBUG: BETAPRODUCTS found [%s]"), pVal );
+ if ( *pVal != 0 )
+ SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND );
+ free( pVal );
+ }
+
+ pVal = NULL;
+ if ( GetMsiProp( hMSI, L"NEWPRODUCTSPATCH", &pVal ) && pVal )
+ {
+ OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTSPATCH found [%s]"), pVal );
+ if ( *pVal != 0 )
+ SetMsiErrorCode( MSI_ERROR_NEW_PATCH_FOUND );
+ free( pVal );
+ }
+ pVal = NULL;
+ if ( GetMsiProp( hMSI, L"SAMEPRODUCTSPATCH", &pVal ) && pVal )
+ {
+ OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTSPATCH found [%s]"), pVal );
+ if ( *pVal != 0 )
+ SetMsiErrorCode( MSI_ERROR_SAME_PATCH_FOUND );
+ free( pVal );
+ }
+ pVal = NULL;
+ if ( GetMsiProp( hMSI, L"OLDPRODUCTSPATCH", &pVal ) && pVal )
+ {
+ OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTSPATCH found [%s]"), pVal );
+ if ( *pVal != 0 )
+ SetMsiErrorCode( MSI_ERROR_OLD_PATCH_FOUND );
+ free( pVal );
+ }
+
+ return ERROR_SUCCESS;
+}
+
+