summaryrefslogtreecommitdiff
path: root/desktop/win32
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-12-16 09:24:51 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-12-16 09:24:51 +0000
commit1ce7ca393dacafceaea22eb92e693e8b2a743619 (patch)
tree825d2cb2098faf82ffc378ab97b3c2138eb9c643 /desktop/win32
parent83ba83080e28dc7dd724f103b75b88a5d13a3852 (diff)
CWS-TOOLING: integrate CWS native210_DEV300
Diffstat (limited to 'desktop/win32')
-rw-r--r--desktop/win32/source/setup/setup.cpp79
-rw-r--r--desktop/win32/source/setup/setup.hxx4
-rw-r--r--desktop/win32/source/setup/setup_main.cxx4
-rw-r--r--desktop/win32/source/setup/setup_main.hxx1
4 files changed, 87 insertions, 1 deletions
diff --git a/desktop/win32/source/setup/setup.cpp b/desktop/win32/source/setup/setup.cpp
index 1941363cf1..744d467e86 100644
--- a/desktop/win32/source/setup/setup.cpp
+++ b/desktop/win32/source/setup/setup.cpp
@@ -61,11 +61,12 @@
#define SECTION_SETUP TEXT( "Setup" )
#define SECTION_LANGUAGE TEXT( "Languages" )
#define PRODUCT_NAME_VAR TEXT( "%PRODUCTNAME" )
-
+#define PRODUCT_VERSION TEXT( "ProductVersion" )
#define ERROR_SHOW_USAGE -2
#define PARAM_SETUP_USED TEXT( " SETUP_USED=1 " )
#define PARAM_PACKAGE TEXT( "/I " )
+#define PARAM_MINOR_UPGRADE TEXT( "/FVOMUS " )
#define PARAM_ADMIN TEXT( "/A " )
#define PARAM_TRANSFORM TEXT( " TRANSFORMS=" )
#define PARAM_REBOOT TEXT( " REBOOT=Force" )
@@ -132,6 +133,8 @@ SetupAppX::SetupAppX()
m_pModuleFile = NULL;
m_pPatchFiles = NULL;
m_pMSIErrorCode = NULL;
+ m_pUpgradeKey = NULL;
+ m_pProductVersion = NULL;
m_pErrorText = new TCHAR[ MAX_TEXT_LENGTH ];
m_pErrorText[0] = '\0';
@@ -143,6 +146,7 @@ SetupAppX::SetupAppX()
m_bQuiet = false;
m_bRegNoMsoTypes = false;
m_bRegAllMsoTypes = false;
+ m_bIsMinorUpgrade = false;
m_bIgnoreAlreadyRunning = false;
}
@@ -186,6 +190,8 @@ SetupAppX::~SetupAppX()
if ( m_pErrorText ) delete [] m_pErrorText;
if ( m_pModuleFile ) delete [] m_pModuleFile;
if ( m_pPatchFiles ) delete [] m_pPatchFiles;
+ if ( m_pUpgradeKey ) delete [] m_pUpgradeKey;
+ if ( m_pProductVersion ) delete [] m_pProductVersion;
}
//--------------------------------------------------------------------------
@@ -359,6 +365,20 @@ boolean SetupAppX::ReadProfile()
Log( TEXT( " productname = %s\r\n" ), pValue );
m_pAppTitle = SetProdToAppTitle( m_pProductName );
}
+ else if ( lstrcmpi( TEXT( "upgradekey" ), pName ) == 0 )
+ {
+ m_pUpgradeKey = pValue;
+ Log( TEXT( " upgradekey = %s\r\n" ), pValue );
+ }
+ else if ( lstrcmpi( TEXT( "productversion" ), pName ) == 0 )
+ {
+ m_pProductVersion = pValue;
+ Log( TEXT( " productversion = %s\r\n" ), pValue );
+ }
+ else if ( lstrcmpi( TEXT( "productcode" ), pName ) == 0 )
+ {
+ delete [] pValue;
+ }
else
{
Log( TEXT( "Warning: unknown entry in profile <%s>\r\n" ), pName );
@@ -916,6 +936,8 @@ boolean SetupAppX::Install( long nLanguage )
if ( m_pAdvertise )
nParLen += lstrlen( m_pAdvertise ) + 1; // one for the space
+ else if ( m_bIsMinorUpgrade )
+ nParLen += lstrlen( PARAM_MINOR_UPGRADE );
else
nParLen += lstrlen( PARAM_PACKAGE );
@@ -952,6 +974,8 @@ boolean SetupAppX::Install( long nLanguage )
StringCchCat( pParams, nParLen, m_pAdvertise );
else if ( IsAdminInstall() )
StringCchCat( pParams, nParLen, PARAM_ADMIN );
+ else if ( m_bIsMinorUpgrade )
+ StringCchCat( pParams, nParLen, PARAM_MINOR_UPGRADE );
else
StringCchCat( pParams, nParLen, PARAM_PACKAGE );
@@ -1181,6 +1205,59 @@ boolean SetupAppX::CheckVersion()
}
//--------------------------------------------------------------------------
+boolean SetupAppX::CheckForUpgrade()
+{
+ // When we have patch files we will never try an Minor upgrade
+ if ( m_pPatchFiles ) return true;
+
+ if ( !m_pUpgradeKey || ( _tcslen( m_pUpgradeKey ) == 0 ) )
+ {
+ Log( TEXT( " No Upgrade Key Found -> continue with standard installation!\r\n" ) );
+ return true;
+ }
+
+ HKEY hInstKey = NULL;
+
+ if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, m_pUpgradeKey, 0, KEY_READ, &hInstKey ) )
+ {
+ Log( TEXT( " Found Upgrade Key in Registry (HKLM) -> will try minor upgrade!\r\n" ) );
+ m_bIsMinorUpgrade = true;
+ }
+ else if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_CURRENT_USER, m_pUpgradeKey, 0, KEY_READ, &hInstKey ) )
+ {
+ Log( TEXT( " Found Upgrade Key in Registry (HKCU) -> will try minor upgrade!\r\n" ) );
+ m_bIsMinorUpgrade = true;
+ }
+ else
+ {
+ Log( TEXT( " Didn't Find Upgrade Key in Registry -> continue with standard installation!\r\n" ) );
+ return true;
+ }
+
+ if ( m_pProductVersion && ( _tcslen( m_pProductVersion ) > 0 ) )
+ {
+ TCHAR *sProductVersion = new TCHAR[ MAX_PATH + 1 ];
+ DWORD nSize = MAX_PATH + 1;
+
+ sProductVersion[0] = '\0';
+
+ // get product version
+ if ( ERROR_SUCCESS == RegQueryValueEx( hInstKey, PRODUCT_VERSION, NULL, NULL, (LPBYTE)sProductVersion, &nSize ) )
+ {
+ if ( lstrcmpi( sProductVersion, m_pProductVersion ) == 0 )
+ {
+ Log( TEXT( " Same Product Version already installed, no minor upgrade!\r\n" ) );
+ m_bIsMinorUpgrade = false;
+ }
+ }
+
+ delete [] sProductVersion;
+ }
+
+ return true;
+}
+
+//--------------------------------------------------------------------------
boolean SetupAppX::InstallMsi( LPCTSTR pInstaller )
{
if ( ! IsAdmin() )
diff --git a/desktop/win32/source/setup/setup.hxx b/desktop/win32/source/setup/setup.hxx
index 8a96f0d5f8..8119685c4b 100644
--- a/desktop/win32/source/setup/setup.hxx
+++ b/desktop/win32/source/setup/setup.hxx
@@ -84,12 +84,15 @@ class SetupAppX : public SetupApp
LPTSTR m_pErrorText;
LPTSTR m_pModuleFile;
LPTSTR m_pPatchFiles;
+ LPCTSTR m_pUpgradeKey;
+ LPCTSTR m_pProductVersion;
int *m_pMSIErrorCode;
boolean m_bQuiet : 1;
boolean m_bIgnoreAlreadyRunning : 1;
boolean m_bRegNoMsoTypes :1;
boolean m_bRegAllMsoTypes :1;
+ boolean m_bIsMinorUpgrade :1;
FILE *m_pLogFile;
@@ -133,6 +136,7 @@ public:
virtual boolean GetPatches();
virtual boolean ChooseLanguage( long& rLanguage );
virtual boolean CheckVersion();
+ virtual boolean CheckForUpgrade();
virtual boolean Install( long nLanguage );
virtual UINT GetError() const;
diff --git a/desktop/win32/source/setup/setup_main.cxx b/desktop/win32/source/setup/setup_main.cxx
index 1e873547ab..e8f9be4719 100644
--- a/desktop/win32/source/setup/setup_main.cxx
+++ b/desktop/win32/source/setup/setup_main.cxx
@@ -118,6 +118,10 @@ extern "C" int __stdcall WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int )
if ( ! pSetup->CheckVersion() )
throw pSetup->GetError();
+ // CheckForUpgrade() has to be called after calling GetPatches()!
+ if ( ! pSetup->CheckForUpgrade() )
+ throw pSetup->GetError();
+
long nLanguage;
if ( ! pSetup->ChooseLanguage( nLanguage ) )
diff --git a/desktop/win32/source/setup/setup_main.hxx b/desktop/win32/source/setup/setup_main.hxx
index fd50bec443..5366dcf825 100644
--- a/desktop/win32/source/setup/setup_main.hxx
+++ b/desktop/win32/source/setup/setup_main.hxx
@@ -52,6 +52,7 @@ public:
virtual boolean GetPatches() = 0;
virtual boolean ChooseLanguage( long& rLanguage ) = 0;
virtual boolean CheckVersion() = 0;
+ virtual boolean CheckForUpgrade() = 0;
virtual boolean Install( long nLanguage ) = 0;
virtual UINT GetError() const = 0;