Back to index

lightning-sunbird  0.9+nobinonly
nsWinReg.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; 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.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
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 #ifndef __NS_WINREG_H__
00039 #define __NS_WINREG_H__
00040 
00041 #include "nsWinRegEnums.h" 
00042 #include "nsWinRegValue.h"
00043 
00044 #include "nscore.h"
00045 #include "nsISupports.h"
00046 
00047 #include "jsapi.h"
00048 
00049 #include "plevent.h"
00050 
00051 #include "nsString.h"
00052 #include "nsHashtable.h"
00053 
00054 #include "nsSoftwareUpdate.h"
00055 
00056 #include "nsInstallObject.h"
00057 #include "nsInstallVersion.h"
00058 #include "nsInstall.h"
00059 
00060 #define _MAXKEYVALUE_ 8196
00061 
00062 #ifndef MAX_BUF
00063 #define MAX_BUF 4096
00064 #endif
00065 
00066 class nsWinReg
00067 {
00068   public:
00069 
00070     enum
00071     {
00072       NS_HKEY_CLASSES_ROOT          = 0x80000000,
00073       NS_HKEY_CURRENT_USER          = 0x80000001,
00074       NS_HKEY_LOCAL_MACHINE         = 0x80000002,
00075       NS_HKEY_USERS                 = 0x80000003
00076     };
00077 
00078     /* Public Fields */
00079 
00080     /* Public Methods */
00081 
00082                       nsWinReg(nsInstall* suObj);
00083                       ~nsWinReg();
00084 
00085     PRInt32           SetRootKey(PRInt32 key);
00086     PRInt32           CreateKey(const nsAString& subkey, const nsAString& classname, PRInt32* aReturn);
00087     PRInt32           DeleteKey(const nsAString& subkey, PRInt32* aReturn);
00088     PRInt32           DeleteValue(const nsAString& subkey, const nsAString& valname, PRInt32* aReturn);
00089     PRInt32           SetValueString(const nsAString& subkey, const nsAString& valname, const nsAString& value, PRInt32* aReturn);
00090     PRInt32           GetValueString(const nsString& subkey, const nsString& valname, nsString* aReturn);
00091     PRInt32           SetValueNumber(const nsString& subkey, const nsString& valname, PRInt32 value, PRInt32* aReturn);
00092     PRInt32           GetValueNumber(const nsString& subkey, const nsString& valname, PRInt32* aReturn);
00093     PRInt32           SetValue(const nsString& subkey, const nsString& valname, nsWinRegValue* value, PRInt32* aReturn);
00094     PRInt32           GetValue(const nsString& subkey, const nsString& valname, nsWinRegValue** aReturn);
00095     PRInt32           EnumValueNames(const nsString& keyname, PRInt32 index, nsString &aReturn);
00096     PRInt32           EnumKeys(const nsString& keyname, PRInt32 index, nsString &aReturn);
00097 
00098     nsInstall*        InstallObject(void);
00099 
00100     PRInt32           KeyExists(const nsString& subkey, PRInt32* aReturn);
00101     PRInt32           ValueExists(const nsString& subkey, const nsString& valname, PRInt32* aReturn);
00102     PRInt32           IsKeyWritable(const nsString& subkey, PRInt32* aReturn);
00103     PRInt32           PrepareCreateKey(PRInt32 root, const nsString& subkey, PRInt32* aReturn);
00104     PRInt32           PrepareDeleteKey(PRInt32 root, const nsString& subkey, PRInt32* aReturn);
00105     PRInt32           PrepareDeleteValue(PRInt32 root, const nsString& subkey, const nsString& valname, PRInt32* aReturn);
00106     PRInt32           PrepareSetValueString(PRInt32 root, const nsString& subkey, PRInt32* aReturn);
00107     PRInt32           PrepareSetValueNumber(PRInt32 root, const nsString& subkey, PRInt32* aReturn);
00108     PRInt32           PrepareSetValue(PRInt32 root, const nsString& subkey, PRInt32* aReturn);
00109 
00110     PRInt32           FinalCreateKey(PRInt32 root, const nsString& subkey, const nsString& classname, PRInt32* aReturn);
00111     PRInt32           FinalDeleteKey(PRInt32 root, const nsString& subkey, PRInt32* aReturn);
00112     PRInt32           FinalDeleteValue(PRInt32 root, const nsString& subkey, const nsString& valname, PRInt32* aReturn);
00113     PRInt32           FinalSetValueString(PRInt32 root, const nsString& subkey, const nsString& valname, const nsString& value, PRInt32* aReturn);
00114     PRInt32           FinalSetValueNumber(PRInt32 root, const nsString& subkey, const nsString& valname, PRInt32 value, PRInt32* aReturn);
00115     PRInt32           FinalSetValue(PRInt32 root, const nsString& subkey, const nsString& valname, nsWinRegValue* value, PRInt32* aReturn);
00116 
00117     
00118   private:
00119     
00120     /* Private Fields */
00121     PRInt32    mRootKey;
00122     nsInstall* mInstallObject;
00123 
00124     /* Private Methods */
00125     PRBool            NativeKeyExists(const nsString& subkey);
00126     PRBool            NativeValueExists(const nsString& subkey, const nsString& valname);
00127     PRBool            NativeIsKeyWritable(const nsString& subkey);
00128     PRInt32           NativeCreateKey(const nsString& subkey, const nsString& classname);
00129     PRInt32           NativeDeleteKey(const nsString& subkey);
00130     PRInt32           NativeDeleteValue(const nsString& subkey, const nsString& valname);
00131 
00132     PRInt32           NativeSetValueString(const nsString& subkey, const nsString& valname, const nsString& value);
00133     PRInt32           NativeGetValueString(const nsString& subkey, const nsString& valname, nsString* aReturn);
00134     PRInt32           NativeSetValueNumber(const nsString& subkey, const nsString& valname, PRInt32 value);
00135     PRInt32           NativeGetValueNumber(const nsString& subkey, const nsString& valname, PRInt32* aReturn);
00136 
00137     PRInt32           NativeSetValue(const nsString& subkey, const nsString& valname, nsWinRegValue* value);
00138     nsWinRegValue*    NativeGetValue(const nsString& subkey, const nsString& valname);
00139 };
00140 
00141 #endif /* __NS_WINREG_H__ */
00142