Distinguishes between an external productname displayed to the user and an

internal product name used for registry and install paths.
  (Bug 140178, r=ssu, sr=dveditz)
This commit is contained in:
curt%netscape.com 2002-04-27 16:44:44 +00:00
parent 2285d06df5
commit 14a88c2b4f
5 changed files with 83 additions and 30 deletions

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Sean Su <ssu@netscape.com>
* Curt Patrick <curt@netscape.com>
*/
#include "extern.h"
@ -2593,7 +2594,7 @@ void SetTurboArgs(void)
wsprintf(szKey,
SETUP_STATE_REG_KEY,
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
AppendWinReg(HKEY_CURRENT_USER,
szKey,

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Sean Su <ssu@netscape.com>
* Curt Patrick <curt@netscape.com>
*/
#include "extern.h"
@ -280,7 +281,7 @@ void UnsetDownloadState(void)
wsprintf(szKey,
SETUP_STATE_REG_KEY,
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
DeleteWinRegValue(HKEY_CURRENT_USER, szKey, "Setup State");
}
@ -293,7 +294,7 @@ void SetDownloadState(void)
wsprintf(szKey,
SETUP_STATE_REG_KEY,
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
lstrcpy(szValue, "downloading");
@ -308,13 +309,13 @@ BOOL CheckForPreviousUnfinishedDownload(void)
BOOL bRv = FALSE;
if(sgProduct.szCompanyName &&
sgProduct.szProductName &&
sgProduct.szProductNameInternal &&
sgProduct.szUserAgent)
{
wsprintf(szKey,
SETUP_STATE_REG_KEY,
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
GetWinReg(HKEY_CURRENT_USER, szKey, "Setup State", szBuf, sizeof(szBuf));
if(lstrcmpi(szBuf, "downloading") == 0)
@ -331,7 +332,7 @@ void UnsetSetupCurrentDownloadFile(void)
wsprintf(szKey,
SETUP_STATE_REG_KEY,
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
DeleteWinRegValue(HKEY_CURRENT_USER,
szKey,
@ -345,7 +346,7 @@ void SetSetupCurrentDownloadFile(char *szCurrentFilename)
wsprintf(szKey,
SETUP_STATE_REG_KEY,
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
SetWinReg(HKEY_CURRENT_USER,
szKey,
@ -369,13 +370,13 @@ char *GetSetupCurrentDownloadFile(char *szCurrentDownloadFile,
ZeroMemory(szCurrentDownloadFile, dwCurrentDownloadFileBufSize);
if(sgProduct.szCompanyName &&
sgProduct.szProductName &&
sgProduct.szProductNameInternal &&
sgProduct.szUserAgent)
{
wsprintf(szKey,
SETUP_STATE_REG_KEY,
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
GetWinReg(HKEY_CURRENT_USER,
szKey,
@ -2508,6 +2509,10 @@ HRESULT InitSetupGeneral()
return(1);
if((sgProduct.szProductName = NS_GlobalAlloc(MAX_BUF)) == NULL)
return(1);
if((sgProduct.szProductNameInternal = NS_GlobalAlloc(MAX_BUF)) == NULL)
return(1);
if((sgProduct.szProductNamePrevious = NS_GlobalAlloc(MAX_BUF)) == NULL)
return(1);
if((sgProduct.szUninstallFilename = NS_GlobalAlloc(MAX_BUF)) == NULL)
return(1);
if((sgProduct.szUserAgent = NS_GlobalAlloc(MAX_BUF)) == NULL)
@ -2539,6 +2544,8 @@ void DeInitSetupGeneral()
FreeMemory(&(sgProduct.szProgramName));
FreeMemory(&(sgProduct.szCompanyName));
FreeMemory(&(sgProduct.szProductName));
FreeMemory(&(sgProduct.szProductNameInternal));
FreeMemory(&(sgProduct.szProductNamePrevious));
FreeMemory(&(sgProduct.szUninstallFilename));
FreeMemory(&(sgProduct.szUserAgent));
FreeMemory(&(sgProduct.szProgramFolderName));
@ -5427,6 +5434,10 @@ HRESULT ParseConfigIni(LPSTR lpszCmdLine)
/* get product name description */
GetPrivateProfileString("General", "Company Name", "", sgProduct.szCompanyName, MAX_BUF, szFileIniConfig);
GetPrivateProfileString("General", "Product Name", "", sgProduct.szProductName, MAX_BUF, szFileIniConfig);
GetPrivateProfileString("General", "Product Name Internal", "", sgProduct.szProductNameInternal, MAX_BUF, szFileIniConfig);
if (sgProduct.szProductNameInternal[0] == 0)
lstrcpy(sgProduct.szProductNameInternal, sgProduct.szProductName);
GetPrivateProfileString("General", "Product Name Previous", "", sgProduct.szProductNamePrevious, MAX_BUF, szFileIniConfig);
GetPrivateProfileString("General", "Uninstall Filename", "", sgProduct.szUninstallFilename, MAX_BUF, szFileIniConfig);
GetPrivateProfileString("General", "User Agent", "", sgProduct.szUserAgent, MAX_BUF, szFileIniConfig);
GetPrivateProfileString("General", "Sub Path", "", sgProduct.szSubPath, MAX_BUF, szFileIniConfig);
@ -6559,7 +6570,7 @@ HRESULT DecryptVariable(LPSTR szVariable, DWORD dwVariableSize)
{
char szKey[MAX_BUF];
wsprintf(szKey, "Software\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductName);
wsprintf(szKey, "Software\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductNameInternal);
/* parse for the current Netscape WinReg key */
GetWinReg(HKEY_LOCAL_MACHINE, szKey, "CurrentVersion", szBuf, sizeof(szBuf));
@ -6567,7 +6578,21 @@ HRESULT DecryptVariable(LPSTR szVariable, DWORD dwVariableSize)
if(*szBuf == '\0')
return(FALSE);
wsprintf(szVariable, "Software\\%s\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductName, szBuf);
wsprintf(szVariable, "Software\\%s\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductNameInternal, szBuf);
}
else if(lstrcmpi(szVariable, "Product PreviousVersion") == 0)
{
char szKey[MAX_BUF];
wsprintf(szKey, "Software\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductNamePrevious);
/* parse for the current Netscape WinReg key */
GetWinReg(HKEY_LOCAL_MACHINE, szKey, "CurrentVersion", szBuf, sizeof(szBuf));
if(*szBuf == '\0')
return(FALSE);
wsprintf(szVariable, "Software\\%s\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductNamePrevious, szBuf);
}
else
return(FALSE);

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Sean Su <ssu@netscape.com>
* Curt Patrick <curt@netscape.com>
*/
#include "extern.h"
@ -126,7 +127,7 @@ void GetUserAgentShort(char *szUserAgent, char *szOutUAShort, DWORD dwOutUAShort
}
}
char *GetWinRegSubKeyProductPath(HKEY hkRootKey, char *szInKey, char *szReturnSubKey, DWORD dwReturnSubKeySize, char *szInSubSubKey, char *szInName, char *szCompare)
DWORD GetWinRegSubKeyProductPath(HKEY hkRootKey, char *szInKey, char *szReturnSubKey, DWORD dwReturnSubKeySize, char *szInSubSubKey, char *szInName, char *szCompare, BOOL bUseCurrentVersion)
{
char *szRv = NULL;
char szKey[MAX_BUF];
@ -138,12 +139,18 @@ char *GetWinRegSubKeyProductPath(HKEY hkRootKey, char *szInKey, char *szReturnSu
DWORD dwTotalSubKeys;
DWORD dwTotalValues;
FILETIME ftLastWriteFileTime;
BOOL bFoundSubKey;
bFoundSubKey = FALSE;
/* get the current version value for this product */
GetWinReg(hkRootKey, szInKey, "CurrentVersion", szCurrentVersion, sizeof(szCurrentVersion));
if(RegOpenKeyEx(hkRootKey, szInKey, 0, KEY_READ, &hkHandle) != ERROR_SUCCESS)
return(szRv);
{
*szReturnSubKey = '\0';
return(0);
}
dwTotalSubKeys = 0;
dwTotalValues = 0;
@ -153,7 +160,9 @@ char *GetWinRegSubKeyProductPath(HKEY hkRootKey, char *szInKey, char *szReturnSu
dwBufSize = dwReturnSubKeySize;
if(RegEnumKeyEx(hkHandle, dwIndex, szReturnSubKey, &dwBufSize, NULL, NULL, NULL, &ftLastWriteFileTime) == ERROR_SUCCESS)
{
if((*szCurrentVersion != '\0') && (lstrcmpi(szCurrentVersion, szReturnSubKey) != 0))
if( (*szCurrentVersion != '\0') && (lstrcmpi(szCurrentVersion, szReturnSubKey) != 0)
||(!bUseCurrentVersion)
)
{
/* The key found is not the CurrentVersion (current UserAgent), so we can return it to be deleted.
* We don't want to return the SubKey that is the same as the CurrentVersion because it might
@ -173,7 +182,7 @@ char *GetWinRegSubKeyProductPath(HKEY hkRootKey, char *szInKey, char *szReturnSu
AppendBackSlash(szBuf, sizeof(szBuf));
if(lstrcmpi(szBuf, szCompare) == 0)
{
szRv = szReturnSubKey;
bFoundSubKey = TRUE;
/* found one subkey. break out of the for() loop */
break;
}
@ -182,19 +191,22 @@ char *GetWinRegSubKeyProductPath(HKEY hkRootKey, char *szInKey, char *szReturnSu
}
RegCloseKey(hkHandle);
return(szRv);
if(!bFoundSubKey)
*szReturnSubKey = '\0';
return(dwTotalSubKeys);
}
void CleanupPreviousVersionRegKeys(void)
{
char *szRvSubKey;
char szSubKeyFound[MAX_PATH + 1];
char szRvSubKey[MAX_PATH + 1];
char szSubSubKey[] = "Main";
char szName[] = "Install Directory";
char szWRMSUninstall[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
char szPath[MAX_BUF];
char szUAShort[MAX_BUF_TINY];
char szKey[MAX_BUF];
char szCleanupProduct[MAX_BUF];
DWORD dwSubKeyCount;
lstrcpy(szPath, sgProduct.szPath);
if(*sgProduct.szSubPath != '\0')
@ -206,30 +218,42 @@ void CleanupPreviousVersionRegKeys(void)
do
{
/* build prodyct key path here */
wsprintf(szKey, "Software\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductName);
szRvSubKey = GetWinRegSubKeyProductPath(HKEY_LOCAL_MACHINE, szKey, szSubKeyFound, sizeof(szSubKeyFound), szSubSubKey, szName, szPath);
if(szRvSubKey)
/* build product key path here */
lstrcpy(szCleanupProduct, sgProduct.szProductNameInternal);
wsprintf(szKey, "Software\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductNameInternal);
dwSubKeyCount = GetWinRegSubKeyProductPath(HKEY_LOCAL_MACHINE, szKey, szRvSubKey, sizeof(szRvSubKey), szSubSubKey, szName, szPath, TRUE);
if( (*szRvSubKey == '\0') && (*sgProduct.szProductNamePrevious != '\0') )
{
AppendBackSlash(szKey, sizeof(szKey));
lstrcat(szKey, szSubKeyFound);
lstrcpy(szCleanupProduct, sgProduct.szProductNamePrevious);
wsprintf(szKey, "Software\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductNamePrevious);
dwSubKeyCount = GetWinRegSubKeyProductPath(HKEY_LOCAL_MACHINE, szKey, szRvSubKey, sizeof(szRvSubKey), szSubSubKey, szName, szPath, FALSE);
}
if(*szRvSubKey != '\0')
{
if(dwSubKeyCount > 1)
{
AppendBackSlash(szKey, sizeof(szKey));
lstrcat(szKey, szRvSubKey);
}
DeleteWinRegKey(HKEY_LOCAL_MACHINE, szKey, TRUE);
GetUserAgentShort(szSubKeyFound, szUAShort, sizeof(szUAShort));
GetUserAgentShort(szRvSubKey, szUAShort, sizeof(szUAShort));
if(*szUAShort != '\0')
{
/* delete uninstall key that contains product name and its user agent in parenthesis, for
* example:
* Mozilla (0.8)
*/
wsprintf(szKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s (%s)", sgProduct.szProductName, szUAShort);
wsprintf(szKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s (%s)", szCleanupProduct, szUAShort);
DeleteWinRegKey(HKEY_LOCAL_MACHINE, szKey, TRUE);
/* delete uninstall key that contains product name and its user agent not in parenthesis,
* for example:
* Mozilla 0.8
*/
wsprintf(szKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s %s", sgProduct.szProductName, szUAShort);
wsprintf(szKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s %s", szCleanupProduct, szUAShort);
DeleteWinRegKey(HKEY_LOCAL_MACHINE, szKey, TRUE);
/* We are not looking to delete just the product name key, for example:
@ -243,7 +267,7 @@ void CleanupPreviousVersionRegKeys(void)
}
}
} while(szRvSubKey);
} while(*szRvSubKey);
}
void ProcessFileOps(DWORD dwTiming, char *szSectionPrefix)
@ -451,7 +475,7 @@ HRESULT CleanupArgsRegistry()
{
char szKey[MAX_BUF];
wsprintf(szKey, SETUP_STATE_REG_KEY, sgProduct.szCompanyName, sgProduct.szProductName,
wsprintf(szKey, SETUP_STATE_REG_KEY, sgProduct.szCompanyName, sgProduct.szProductNameInternal,
sgProduct.szUserAgent);
DeleteWinRegValue(HKEY_CURRENT_USER, szKey, "browserargs");
return(FO_SUCCESS);

View File

@ -104,9 +104,10 @@ void LogISProductInfo(void)
}
UpdateInstallStatusLog(szBuf);
wsprintf(szBuf, " Company name: %s\n Product name: %s\n Uninstall Filename: %s\n UserAgent: %s\n Alternate search path: %s\n",
wsprintf(szBuf, " Company name: %s\n Product name (external): %s\n Product name (internal): %s\n Uninstall Filename: %s\n UserAgent: %s\n Alternate search path: %s\n",
sgProduct.szCompanyName,
sgProduct.szProductName,
sgProduct.szProductNameInternal,
sgProduct.szUninstallFilename,
sgProduct.szUserAgent,
sgProduct.szAlternateArchiveSearchPath);

View File

@ -376,6 +376,8 @@ typedef struct setupStruct
LPSTR szProgramName;
LPSTR szCompanyName;
LPSTR szProductName;
LPSTR szProductNameInternal;
LPSTR szProductNamePrevious;
LPSTR szUninstallFilename;
LPSTR szUserAgent;
LPSTR szProgramFolderName;