/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in * compliance with the NPL. You may obtain a copy of the NPL at * http://www.mozilla.org/NPL/ * * Software distributed under the NPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL * for the specific language governing rights and limitations under the * NPL. * * The Initial Developer of this code under the NPL is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ #include "nsISupports.idl" %{C++ #include "jsapi.h" typedef int (*PrefChangedFunc)(const char *, void *); #define NS_PREF_CID \ { /* {dc26e0e0-ca94-11d1-a9a4-00805f8a7ac4} */ \ 0xdc26e0e0, \ 0xca94, \ 0x11d1, \ { 0xa9, 0xa4, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xc4 } \ } #define NS_PREF_VALUE_CHANGED 1 %} [ptr] native JSContext(JSContext); [ptr] native JSObject(JSObject); native PrefChangedFunc(PrefChangedFunc); interface nsIFileSpec; [scriptable, uuid(a22ad7b0-ca86-11d1-a9a4-00805f8a7ac4)] interface nsIPref : nsISupports { %{C++ /* Pref types - see GetPrefType() */ enum { ePrefInvalid = 0, ePrefLocked = 1, ePrefUserset = 2, ePrefConfig = 4, ePreRemote = 8, ePrefLilocal = 16, ePrefString = 32, ePrefInt = 64, ePrefBool = 128, ePrefValuetypeMask = (ePrefString | ePrefInt | ePrefBool) }; %} // Initialize/shutdown void StartUp(); void ReadUserPrefs(); void ReadUserPrefsFrom(in nsIFileSpec spec); void ResetPrefs(); void ShutDown(); // Config file input void ReadUserJSFile(in nsIFileSpec filename); void ReadLIJSFile(in nsIFileSpec filename); void EvaluateConfigScript(in string js_buffer, in PRUint32 length, in boolean bGlobalContext, in boolean bCallbacks); void EvaluateConfigScriptFile(in string js_buffer, in PRUint32 length, in nsIFileSpec filename, in boolean bGlobalContext, in boolean bCallbacks); void SavePrefFileAs(in nsIFileSpec filename); void SaveLIPrefFile(in nsIFileSpec filename); /* JS Stuff - don't allow this to be scriptable */ [noscript] readonly attribute JSContext configContext; [noscript] readonly attribute JSObject globalConfigObject; [noscript] readonly attribute JSObject prefConfigObject; /* Getters */ long GetPrefType(in string pref); long GetIntPref(in string pref); boolean GetBoolPref(in string pref); [noscript] void GetBinaryPref(in string pref, in voidStar buf, inout long buf_length); void GetColorPref(in string pref, out octet red, out octet green, out octet blue); unsigned long GetColorPrefDWord(in string pref); void GetRectPref(in string pref, out short left, out short top, out short right, out short bottom); /* set preferences */ void SetCharPref(in string pref, in string value); void SetIntPref(in string pref, in long value); void SetBoolPref(in string pref, in boolean value); [noscript] void SetBinaryPref(in string pref, in voidStar value, in unsigned long size); void SetColorPref(in string pref,in octet red, in octet green,in octet blue); void SetColorPrefDWord(in string pref, in unsigned long colorref); void SetRectPref(in string pref, in short left, in short top, in short right, in short bottom); void ClearUserPref(in string pref_name); /* get defaults */ long GetDefaultIntPref(in string pref); boolean GetDefaultBoolPref(in string pref); [noscript] void GetDefaultBinaryPref(in string pref, in voidStar value, out long length); void GetDefaultColorPref(in string pref, out octet red, out octet green, out octet blue); unsigned long GetDefaultColorPrefDWord(in string pref); void GetDefaultRectPref(in string pref, out short left, out short top, out short right, out short bottom); /* set defaults */ void SetDefaultCharPref(in string pref, in string value); void SetDefaultIntPref(in string pref, in long value); void SetDefaultBoolPref(in string pref, in boolean value); [noscript] void SetDefaultBinaryPref(in string pref, in voidStar value, in unsigned long size); void SetDefaultColorPref(in string pref,in octet red, in octet green,in octet blue); void SetDefaultRectPref(in string pref, in short left, in short top, in short right, in short bottom); /* copy versions of getters */ string CopyCharPref(in string pref); [noscript] voidStar CopyBinaryPref(in string pref, out long size); string CopyDefaultCharPref(in string pref); [noscript] voidStar CopyDefaultBinaryPref(in string pref, out long size); nsIFileSpec GetFilePref(in string pref); void SetFilePref(in string pref, in nsIFileSpec value, in boolean setDefault); /* pref attributes */ boolean PrefIsLocked(in string pref); /* save pref values */ void SavePrefFile(); /* callbacks */ [noscript] void RegisterCallback(in string domain, in PrefChangedFunc callback, in voidStar closure); [noscript] void UnregisterCallback(in string domain, in PrefChangedFunc callback, in voidStar closure); void CopyPrefsTree(in string srcRoot, in string destRoot); void DeleteBranch(in string branchName); string CreateChildList(in string parent_node); string NextChild(in string child_list, out short index); };