Back to index

lightning-sunbird  0.9+nobinonly
nsMapiRegistryUtils.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Srilatha Moturi <srilatha@netscape.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /***************************************************************************
00039 *
00040 * This File is no longer used by Thunderbird. Seamonkey is the only consumer.
00041 * See mozilla/mail/components/shell for the Thunderbird registry code
00042 *
00043 *****************************************************************************/
00044 
00045 #ifndef nsmapiregistryutils_h____
00046 #define nsmapiregistryutils_h____
00047 
00048 #include <windows.h>
00049 #include <string.h>
00050 #include <winreg.h>
00051 
00052 #include "nsString.h"
00053 #include "nsIStringBundle.h"
00054 
00055 #ifndef MOZ_THUNDERBIRD
00056 #define kAppDesktopKey "Software\\Mozilla\\Desktop"
00057 #else
00058 #define kAppDesktopKey "Software\\Mozilla Thunderbird\\Desktop"
00059 #endif
00060 
00061 class nsMapiRegistryUtils
00062 {
00063 private :
00064     nsCAutoString m_thisApp ;
00065     nsAutoString m_brand ;
00066     nsAutoString m_vendor ;
00067     nsAutoString m_versionNo ;
00068 
00069     nsCOMPtr<nsIStringBundle> m_mapiStringBundle ;
00070 
00071     // sets result to the value of varName (as defined in brand.properties)
00072     void getVarValue(const PRUnichar * varName, nsAutoString & result);
00073 
00074     // verifyRestrictedAccess - Returns PR_TRUE if this user only has restricted access
00075     // to the registry keys we need to modify. Consumers should call the public method 
00076     PRBool verifyRestrictedAccess() ;
00077 
00078     PRBool mRestrictedRegAccess; // cannot write to HKLM in the registry
00079 
00080     static void RegCopyKey(HKEY aSrcKey, HKEY aDestKey, const char* aSubKeyName); // recursively copies the given sub key from the src key to the dest key
00081     nsresult recursiveDeleteKey(HKEY hKeyParent, const char* lpszKeyChild);
00082 
00083 public :
00084     nsMapiRegistryUtils() ;
00085 
00086     // returns TRUE if the Mapi32.dll is smart dll.
00087     PRBool isSmartDll();
00088     // returns TRUE if the Mapi32.dll is a Mozilla dll.
00089     PRBool isMozDll();
00090 
00091     PRBool HasRestrictedRegistryAccess() { return mRestrictedRegAccess; }
00092 
00093     // Returns the (fully-qualified) name of this executable.
00094     const char * thisApplication() ; 
00095     // This returns the brand name for this application
00096     const PRUnichar * brandName() ;
00097     // This returns the vendor name of this application
00098     const nsString& vendorName();
00099 
00100     // set the Windows registry key
00101     nsresult SetRegistryKey(HKEY baseKey, const char * keyName, 
00102                         const char * valueName, char * value);
00103     // delete a registry key
00104     nsresult DeleteRegistryValue(HKEY baseKey, const char * keyName, const char * valueName);
00105 
00106     // get a Windows registry key
00107     void GetRegistryKey(HKEY baseKey, const char * keyName, const char * valueName, nsCAutoString & value);
00108 
00109     // Returns TRUE if the current application is default mail client.
00110     PRBool IsDefaultMailClient();
00111     nsresult setDefaultMailClient(); // Sets Mozilla as default Mail Client
00112     nsresult unsetDefaultMailClient(); // Removes Mozilla as the default Mail client and restores the previous setting
00113     nsresult saveDefaultMailClient(); // Save default mail client settings in HKEY_LOCAL_MACHINE\\Software\\Mozilla\\Desktop   
00114     nsresult saveUserDefaultMailClient(); // save default 
00115     PRBool IsDefaultFeedClient();
00116     nsresult setDefaultFeedClient();
00117     nsresult unsetDefaultFeedClient();
00118        
00119     PRBool IsDefaultNewsClient();      // Returns TRUE if the current application is default news client.  
00120     nsresult setDefaultNewsClient();   // Sets Mozilla as the default News Client    
00121     nsresult unsetDefaultNewsClient(); // Removes Mozilla as the default Mail client and restores the previous setting    
00122     nsresult saveDefaultNewsClient();  // Saves the current setting of the default News Client in HKEY_LOCAL_MACHINE\\Software\\Mozilla\\Desktop
00123     nsresult saveUserDefaultNewsClient();
00124 
00125     nsresult setupDefaultProtocolKey(const char * aDefaultAppRegKey, const char * aProtocol, const char * aProtocolEntryValue, const char * aCmdLineParam); 
00126     nsresult setProtocolHandler(const char * aDefaultAppRegKey, const char * protocolName); // installs protocol handler on Software\Classes<protocolName>
00127 
00128     nsresult setupFileExtension(const char * aDefaultAppRegKey, const char * aExtension);
00129     nsresult restoreFileExtension(const char * aDefaultAppRegKey, const char * aExtension);
00130 
00131     nsresult registerNewsApp(PRBool aForceRegistration); // aForceRegistration set to TRUE if we want to force the keys to be set again
00132     nsresult registerMailApp(PRBool aForceRegistration);
00133 
00134     nsresult CopyMozMapiToWinSysDir();
00135     nsresult RestoreBackedUpMapiDll();
00136 
00137     // Returns FALSE if showMapiDialog is set to 0.
00138     PRBool getShowDialog() ;
00139 
00140     // create a string bundle for MAPI messages
00141     nsresult MakeMapiStringBundle(nsIStringBundle ** aMapiStringBundle) ;
00142     // display an error dialog for MAPI messages
00143     nsresult ShowMapiErrorDialog(PRBool aForMail); // set to false if showing a news error
00144 } ;
00145 
00146 #endif