Back to index

lightning-sunbird  0.9+nobinonly
rdi.c
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Navigator.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corp.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Sean Su <ssu@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "extern.h"
00040 #include "extra.h"
00041 #include "parser.h"
00042 #include "ifuncns.h"
00043 
00044 char szUnreadMailKey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail";
00045 char szMozillaDesktopKey[] = "Software\\Mozilla\\Desktop";
00046 char szRDISection[] = "Restore Desktop Integration";
00047 
00048 /* This function enumerates HKEY_LOCAL_MACHINE\Sofware\Mozilla\Desktop for
00049  * variable information on what desktop integration was done by the
00050  * browser/mail client.
00051  *
00052  * These variables found cannot be deleted or modified until the enumeration
00053  * is complete, or else this function will fail! */
00054 void RestoreDesktopIntegration()
00055 {
00056 #ifdef OLDCODE
00057   char      szVarName[MAX_BUF];
00058   char      szValue[MAX_BUF];
00059   char      szSubKey[MAX_BUF];
00060   HKEY      hkHandle;
00061   DWORD     dwIndex;
00062   DWORD     dwSubKeySize;
00063   DWORD     dwTotalValues;
00064   char      szKHKEY[]               = "HKEY";
00065   char      szKisHandling[]         = "isHandling";
00066 
00067   if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, szMozillaDesktopKey, 0, KEY_READ|KEY_WRITE, &hkHandle) != ERROR_SUCCESS)
00068     return;
00069 
00070   dwTotalValues  = 0;
00071   RegQueryInfoKey(hkHandle, NULL, NULL, NULL, NULL, NULL, NULL, &dwTotalValues, NULL, NULL, NULL, NULL);
00072   for(dwIndex = 0; dwIndex < dwTotalValues; dwIndex++)
00073   {
00074     /* Enumerate thru all the vars found within the Mozilla Desktop key */
00075     dwSubKeySize = sizeof(szVarName);
00076     if(RegEnumValue(hkHandle, dwIndex, szVarName, &dwSubKeySize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
00077     {
00078       if(strnicmp(szVarName, szKHKEY, strlen(szKHKEY)) == 0)
00079       {
00080         HKEY hkRootKey;
00081 
00082         hkRootKey = GetRootKeyAndSubKeyPath(szVarName, szSubKey, sizeof(szSubKey));
00083         if(*szSubKey != '\0')
00084         {
00085           GetWinReg(HKEY_LOCAL_MACHINE, szMozillaDesktopKey, szVarName, szValue, sizeof(szValue));
00086           if(*szValue != '\0')
00087           {
00088             /* Due to a bug in the browser code that saves the previous HKEY
00089              * value it's trying to replace as garbage chars, we need to try
00090              * to detect it.  If found, do not restore it. This bug only
00091              * happens for the saved ddeexec keys. */
00092             if(DdeexecCheck(szSubKey, szValue))
00093             {
00094               /* Restore the previous saved setting here */
00095               SetWinReg(hkRootKey,
00096                         szSubKey,
00097                         NULL,
00098                         REG_SZ,
00099                         szValue,
00100                         strlen(szValue));
00101             }
00102           }
00103           else
00104             /* if the saved value is an empty string, then
00105              * delete the default var for this key */
00106             DeleteWinRegValue(hkRootKey,
00107                               szSubKey,
00108                               szValue);
00109         }
00110       }
00111     }
00112   }
00113   RegCloseKey(hkHandle);
00114   return;
00115 #endif
00116 }
00117 
00118 BOOL UndoDesktopIntegration(void)
00119 {
00120 #ifdef OLDCODE
00121   char szMozillaKey[] = "Software\\Mozilla";
00122   char szBuf[MAX_BUF];
00123 
00124   /* Check to see if uninstall.ini has indicated to restore
00125    * the destktop integration performed by the browser/mail */
00126   GetPrivateProfileString(szRDISection, "Enabled", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00127   if(stricmp(szBuf, "TRUE") == 0)
00128   {
00129     RestoreDesktopIntegration();
00130 
00131     DeleteWinRegKey(HKEY_LOCAL_MACHINE, szMozillaDesktopKey, TRUE);
00132     DeleteWinRegKey(HKEY_LOCAL_MACHINE, szMozillaKey, FALSE);
00133   }
00134 #endif
00135   return(0);
00136 }
00137