fixing bug 99526 - update uninstaller to be able to undo the new MAPI settings set by mail. r=dveditz, sr=mscott. affects windows platforms only.

This commit is contained in:
ssu%netscape.com 2001-09-21 06:30:08 +00:00
Родитель 2eb302f1a5
Коммит fc99c9369e
2 изменённых файлов: 156 добавлений и 87 удалений

Просмотреть файл

@ -107,21 +107,9 @@ YesToAll=Y&es to all
;Process Name=psm.exe
;Message=Setup has detected that an instance of Personal Security Manager is currently running. Personal Security Manager will quit by itself when there are no other applications running that require it. A reboot might be necessary. Setup will then be able to continue.
[Restore Desktop Integration Associations]
.gif=TRUE
.htm=TRUE
.html=TRUE
.jpeg=TRUE
.jpg=TRUE
.png=TRUE
.xml=TRUE
.xul=TRUE
[Restore Desktop Integration Protocols]
chrome=TRUE
ftp=TRUE
http=TRUE
https=TRUE
; This section attempts to restore/undo the desktop integration performed by the browser/mail
[Restore Desktop Integration]
Enabled=TRUE
[Messages]
ERROR_DLL_LOAD=Could not load %s

Просмотреть файл

@ -26,96 +26,177 @@
#include "extra.h"
#include "ifuncns.h"
char gszRDISection[] = "Restore Desktop Integration";
void RestoreDesktopIntegrationAssociations(HKEY hkRoot, LPSTR szWinRegDesktopKey)
/* This function parses takes as input a registry key path string beginning
* with HKEY_XXXX (root key) and parses out the sub key path and the root
* key.
*
* It returns the root key as HKEY and the sub key path as char* */
HKEY GetRootKeyAndSubKeyPath(char *szInKeyPath, char *szOutSubKeyPath, DWORD dwOutSubKeyPathSize)
{
char *szBufPtr = NULL;
char szSection[MAX_BUF];
char szAllKeys[MAX_BUF];
char szValue[MAX_BUF];
char szRDIName[] = "HKEY_LOCAL_MACHINE\\Software\\Classes";
char szName[MAX_BUF];
char *ptr = szInKeyPath;
HKEY hkRootKey = HKEY_CLASSES_ROOT;
wsprintf(szSection, "%s Associations", gszRDISection);
GetPrivateProfileString(szSection, NULL, "", szAllKeys, sizeof(szAllKeys), szFileIniUninstall);
if(*szAllKeys != '\0')
ZeroMemory(szOutSubKeyPath, dwOutSubKeyPathSize);
if(ptr == NULL)
return(hkRootKey);
/* search for the first '\' char */
while(*ptr && (*ptr != '\\'))
++ptr;
if((*ptr == '\0') ||
(*ptr == '\\'))
{
szBufPtr = szAllKeys;
while(*szBufPtr != '\0')
BOOL bPtrModified = FALSE;
if(*ptr == '\\')
{
GetPrivateProfileString(szSection, szBufPtr, "", szValue, sizeof(szValue), szFileIniUninstall);
if(lstrcmpi(szValue, "TRUE") == 0)
*ptr = '\0';
bPtrModified = TRUE;
}
hkRootKey = ParseRootKey(szInKeyPath);
if(bPtrModified)
*ptr = '\\';
if((*ptr != '\0') &&
((unsigned)lstrlen(ptr + 1) + 1 <= dwOutSubKeyPathSize))
/* copy only the sub key path after the root key string */
lstrcpy(szOutSubKeyPath, ptr + 1);
}
return(hkRootKey);
}
/* This function checks for nonprintable characters.
* If at least one is found in the input string, it will return TRUE,
* else FALSE */
BOOL CheckForNonPrintableChars(char *szInString)
{
int i;
int iLen;
BOOL bFoundNonPrintableChar = FALSE;
if(!szInString)
return(TRUE);
iLen = lstrlen(szInString);
for(i = 0; i < iLen; i++)
{
if(!isprint(szInString[i]))
{
bFoundNonPrintableChar = TRUE;
break;
}
}
return(bFoundNonPrintableChar);
}
/* This function checks to see if the key path is a ddeexec path. If so,
* it then checks for non printable chars */
BOOL DdeexecCheck(char *szKey, char *szValue)
{
char szKddeexec[] = "shell\\open\\ddeexec";
char szKeyLower[MAX_BUF];
BOOL bPass = TRUE;
lstrcpy(szKeyLower, szKey);
strlwr(szKeyLower);
if(strstr(szKeyLower, szKddeexec) && CheckForNonPrintableChars(szValue))
bPass = FALSE;
return(bPass);
}
/* This function enumerates HKEY_LOCAL_MACHINE\Sofware\Mozilla\Desktop for
* variable information on what desktop integration was done by the
* browser/mail client.
*
* These variables found cannot be deleted or modified until the enumeration
* is complete, or else this function will fail! */
void RestoreDesktopIntegration()
{
char szVarName[MAX_BUF];
char szValue[MAX_BUF];
char szSubKey[MAX_BUF];
HKEY hkHandle;
DWORD dwIndex;
DWORD dwSubKeySize;
DWORD dwTotalValues;
char szWRMozillaDesktopKey[] = "Software\\Mozilla\\Desktop";
char szKHKEY[] = "HKEY";
char szKisHandling[] = "isHandling";
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, szWRMozillaDesktopKey, 0, KEY_READ|KEY_WRITE, &hkHandle) != ERROR_SUCCESS)
return;
dwTotalValues = 0;
RegQueryInfoKey(hkHandle, NULL, NULL, NULL, NULL, NULL, NULL, &dwTotalValues, NULL, NULL, NULL, NULL);
for(dwIndex = 0; dwIndex < dwTotalValues; dwIndex++)
{
/* Enumerate thru all the vars found within the Mozilla Desktop key */
dwSubKeySize = sizeof(szVarName);
if(RegEnumValue(hkHandle, dwIndex, szVarName, &dwSubKeySize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
if(strnicmp(szVarName, szKHKEY, lstrlen(szKHKEY)) == 0)
{
wsprintf(szName, "%s\\%s", szRDIName, szBufPtr);
GetWinReg(hkRoot, szWinRegDesktopKey, szName, szValue, sizeof(szValue));
if(*szValue != '\0')
HKEY hkRootKey;
hkRootKey = GetRootKeyAndSubKeyPath(szVarName, szSubKey, sizeof(szSubKey));
if(*szSubKey != '\0')
{
SetWinReg(HKEY_CLASSES_ROOT, szBufPtr, NULL, REG_SZ, szValue, lstrlen(szValue));
GetWinReg(HKEY_LOCAL_MACHINE, szWRMozillaDesktopKey, szVarName, szValue, sizeof(szValue));
if(*szValue != '\0')
{
/* Due to a bug in the browser code that saves the previous HKEY
* value it's trying to replace as garbage chars, we need to try
* to detect it. If found, do not restore it. This bug only
* happens for the saved ddeexec keys. */
if(DdeexecCheck(szSubKey, szValue))
{
/* Restore the previous saved setting here */
SetWinReg(hkRootKey,
szSubKey,
NULL,
REG_SZ,
szValue,
lstrlen(szValue));
}
}
else
/* if the saved value is an empty string, then
* delete the default var for this key */
DeleteWinRegValue(hkRootKey,
szSubKey,
szValue);
}
}
/* move the pointer to the next key */
szBufPtr += lstrlen(szBufPtr) + 1;
}
}
}
void ResetWinRegDIProcotol(HKEY hkRoot, LPSTR szWinRegDesktopKey, LPSTR szRDIName, LPSTR szProtocol, LPSTR szLatterKeyPath)
{
char szKey[MAX_BUF];
char szName[MAX_BUF];
char szValue[MAX_BUF];
wsprintf(szName, "%s\\%s\\%s", szRDIName, szProtocol, szLatterKeyPath);
GetWinReg(hkRoot, szWinRegDesktopKey, szName, szValue, sizeof(szValue));
if(*szValue != '\0')
{
wsprintf(szKey, "%s\\%s", szProtocol, szLatterKeyPath);
SetWinReg(HKEY_CLASSES_ROOT, szKey, NULL, REG_SZ, szValue, lstrlen(szValue));
}
}
void RestoreDesktopIntegrationProtocols(HKEY hkRoot, LPSTR szWinRegDesktopKey)
{
char *szBufPtr = NULL;
char szSection[MAX_BUF];
char szAllKeys[MAX_BUF];
char szValue[MAX_BUF];
char szRDIName[] = "HKEY_LOCAL_MACHINE\\Software\\Classes";
wsprintf(szSection, "%s Protocols", gszRDISection);
GetPrivateProfileString(szSection, NULL, "", szAllKeys, sizeof(szAllKeys), szFileIniUninstall);
if(*szAllKeys != '\0')
{
szBufPtr = szAllKeys;
while(*szBufPtr != '\0')
{
GetPrivateProfileString(szSection, szBufPtr, "", szValue, sizeof(szValue), szFileIniUninstall);
if(lstrcmpi(szValue, "TRUE") == 0)
{
ResetWinRegDIProcotol(hkRoot, szWinRegDesktopKey, szRDIName, szBufPtr, "shell\\open\\command");
ResetWinRegDIProcotol(hkRoot, szWinRegDesktopKey, szRDIName, szBufPtr, "shell\\open\\ddeexec");
ResetWinRegDIProcotol(hkRoot, szWinRegDesktopKey, szRDIName, szBufPtr, "shell\\open\\ddeexec\\Application");
}
/* move the pointer to the next key */
szBufPtr += lstrlen(szBufPtr) + 1;
}
}
RegCloseKey(hkHandle);
return;
}
BOOL UndoDesktopIntegration(void)
{
char szMozillaDesktopKey[MAX_BUF];
char szMozillaKey[] = "Software\\Mozilla";
char szRDISection[] = "Restore Desktop Integration";
char szBuf[MAX_BUF];
wsprintf(szMozillaDesktopKey, "%s\\%s", szMozillaKey, "Desktop");
RestoreDesktopIntegrationAssociations(HKEY_LOCAL_MACHINE, szMozillaDesktopKey);
RestoreDesktopIntegrationProtocols(HKEY_LOCAL_MACHINE, szMozillaDesktopKey);
/* Check to see if uninstall.ini has indicated to restore
* the destktop integration performed by the browser/mail */
GetPrivateProfileString(szRDISection, "Enabled", "", szBuf, sizeof(szBuf), szFileIniUninstall);
if(lstrcmpi(szBuf, "TRUE") == 0)
{
wsprintf(szMozillaDesktopKey, "%s\\%s", szMozillaKey, "Desktop");
RestoreDesktopIntegration();
DeleteWinRegKey(HKEY_LOCAL_MACHINE, szMozillaDesktopKey, TRUE);
DeleteWinRegKey(HKEY_LOCAL_MACHINE, szMozillaKey, FALSE);
DeleteWinRegKey(HKEY_LOCAL_MACHINE, szMozillaDesktopKey, TRUE);
DeleteWinRegKey(HKEY_LOCAL_MACHINE, szMozillaKey, FALSE);
}
return(0);
}