public/IAdminSystem.h
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/public/IAdminSystem.h	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,724 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod
     1.8 - * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#ifndef _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
    1.36 -#define _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
    1.37 -
    1.38 -#include <IShareSys.h>
    1.39 -
    1.40 -#define SMINTERFACE_ADMINSYS_NAME		"IAdminSys"
    1.41 -#define SMINTERFACE_ADMINSYS_VERSION	5
    1.42 -
    1.43 -/**
    1.44 - * @file IAdminSystem.h
    1.45 - * @brief Defines the interface to manage the Admin Users/Groups and Override caches.
    1.46 - *
    1.47 - *   The administration system is more of a volatile cache than a system.  It is designed to be 
    1.48 - * temporary rather than permanent, in order to compensate for more storage methods.  For example,
    1.49 - * a flat file might be read into the cache all at once.  But a MySQL-based system might only cache
    1.50 - * admin permissions when that specific admin connects.  
    1.51 - *
    1.52 - *   The override cache is the simplest to explain.  Any time an override is added, any existing 
    1.53 - * and all future commands will gain a new access level set by the override.  If unset, the default
    1.54 - * access level is restored.  This cache is dynamically changeable.
    1.55 - *
    1.56 - *   The group cache contains, for each group:
    1.57 - *	1] A set of inherent flags - fully readable/writable.
    1.58 - *  2] An immunity table - insertion and retrieval only.
    1.59 - *  3] An override table - insertion and retrieval only.
    1.60 - *   Individual groups can be invalidated entirely.  It should be considered an expensive
    1.61 - *  operation, since each admin needs to be patched up to not reference the group.
    1.62 - *
    1.63 - *   For more information, see the SourceMod Development wiki.
    1.64 - */
    1.65 -
    1.66 -namespace SourceMod
    1.67 -{
    1.68 -	/**
    1.69 -	 * @brief Access levels (flags) for admins.
    1.70 -	 */
    1.71 -	enum AdminFlag
    1.72 -	{
    1.73 -		Admin_Reservation = 0,	/**< Reserved slot */
    1.74 -		Admin_Generic,			/**< Generic admin abilities */
    1.75 -		Admin_Kick,				/**< Kick another user */
    1.76 -		Admin_Ban,				/**< Ban another user */
    1.77 -		Admin_Unban,			/**< Unban another user */
    1.78 -		Admin_Slay,				/**< Slay/kill/damage another user */
    1.79 -		Admin_Changemap,		/**< Change the map */
    1.80 -		Admin_Convars,			/**< Change basic convars */
    1.81 -		Admin_Config,			/**< Change configuration */
    1.82 -		Admin_Chat,				/**< Special chat privileges */
    1.83 -		Admin_Vote,				/**< Special vote privileges */
    1.84 -		Admin_Password,			/**< Set a server password */
    1.85 -		Admin_RCON,				/**< Use RCON */
    1.86 -		Admin_Cheats,			/**< Change sv_cheats and use its commands */
    1.87 -		Admin_Root,				/**< All access by default */
    1.88 -		Admin_Custom1,			/**< First custom flag type */
    1.89 -		Admin_Custom2,			/**< Second custom flag type */
    1.90 -		Admin_Custom3,			/**< Third custom flag type */
    1.91 -		Admin_Custom4,			/**< Fourth custom flag type */
    1.92 -		Admin_Custom5,			/**< Fifth custom flag type */
    1.93 -		Admin_Custom6,			/**< Sixth custom flag type */
    1.94 -		/* --- */
    1.95 -		AdminFlags_TOTAL,
    1.96 -	};
    1.97 -
    1.98 -	#define ADMFLAG_RESERVATION			(1<<0)		/**< Convenience macro for Admin_Reservation as a FlagBit */
    1.99 -	#define ADMFLAG_GENERIC				(1<<1)		/**< Convenience macro for Admin_Generic as a FlagBit */
   1.100 -	#define ADMFLAG_KICK				(1<<2)		/**< Convenience macro for Admin_Kick as a FlagBit */
   1.101 -	#define ADMFLAG_BAN					(1<<3)		/**< Convenience macro for Admin_Ban as a FlagBit */
   1.102 -	#define ADMFLAG_UNBAN				(1<<4)		/**< Convenience macro for Admin_Unban as a FlagBit */
   1.103 -	#define ADMFLAG_SLAY				(1<<5)		/**< Convenience macro for Admin_Slay as a FlagBit */
   1.104 -	#define ADMFLAG_CHANGEMAP			(1<<6)		/**< Convenience macro for Admin_Changemap as a FlagBit */
   1.105 -	#define ADMFLAG_CONVARS				(1<<7)		/**< Convenience macro for Admin_Convars as a FlagBit */
   1.106 -	#define ADMFLAG_CONFIG				(1<<8)		/**< Convenience macro for Admin_Config as a FlagBit */
   1.107 -	#define ADMFLAG_CHAT				(1<<9)		/**< Convenience macro for Admin_Chat as a FlagBit */
   1.108 -	#define ADMFLAG_VOTE				(1<<10)		/**< Convenience macro for Admin_Vote as a FlagBit */
   1.109 -	#define ADMFLAG_PASSWORD			(1<<11)		/**< Convenience macro for Admin_Password as a FlagBit */
   1.110 -	#define ADMFLAG_RCON				(1<<12)		/**< Convenience macro for Admin_RCON as a FlagBit */
   1.111 -	#define ADMFLAG_CHEATS				(1<<13)		/**< Convenience macro for Admin_Cheats as a FlagBit */
   1.112 -	#define ADMFLAG_ROOT				(1<<14)		/**< Convenience macro for Admin_Root as a FlagBit */
   1.113 -	#define ADMFLAG_CUSTOM1				(1<<15)		/**< Convenience macro for Admin_Custom1 as a FlagBit */
   1.114 -	#define ADMFLAG_CUSTOM2				(1<<16)		/**< Convenience macro for Admin_Custom2 as a FlagBit */
   1.115 -	#define ADMFLAG_CUSTOM3				(1<<17)		/**< Convenience macro for Admin_Custom3 as a FlagBit */
   1.116 -	#define ADMFLAG_CUSTOM4				(1<<18)		/**< Convenience macro for Admin_Custom4 as a FlagBit */
   1.117 -	#define ADMFLAG_CUSTOM5				(1<<19)		/**< Convenience macro for Admin_Custom5 as a FlagBit */
   1.118 -	#define ADMFLAG_CUSTOM6				(1<<20)		/**< Convenience macro for Admin_Custom6 as a FlagBit */
   1.119 -
   1.120 -	/**
   1.121 -	 * @brief Specifies which type of command to override (command or command group).
   1.122 -	 */
   1.123 -	enum OverrideType
   1.124 -	{
   1.125 -		Override_Command = 1,	/**< Command */
   1.126 -		Override_CommandGroup,	/**< Command group */
   1.127 -	};
   1.128 -
   1.129 -	/**
   1.130 -	 * @brief Specifies how a command is overridden for a user group.
   1.131 -	 */
   1.132 -	enum OverrideRule
   1.133 -	{
   1.134 -		Command_Deny = 0,		/**< Deny access */
   1.135 -		Command_Allow = 1,		/**< Allow access */
   1.136 -	};
   1.137 -
   1.138 -	/**
   1.139 -	 * @brief DEPRECATED.  Specifies a generic immunity type.
   1.140 -	 */
   1.141 -	enum ImmunityType
   1.142 -	{
   1.143 -		Immunity_Default = 1,	/**< Immunity value of 1 */
   1.144 -		Immunity_Global,		/**< Immunity value of 2 */
   1.145 -	};
   1.146 -
   1.147 -	/**
   1.148 -	 * @brief Defines user access modes.
   1.149 -	 */
   1.150 -	enum AccessMode
   1.151 -	{
   1.152 -		Access_Real,		/**< Access the user has inherently */
   1.153 -		Access_Effective,	/**< Access the user has from their groups */
   1.154 -	};
   1.155 -
   1.156 -	/**
   1.157 -	 * @brief Represents an index to one group.
   1.158 -	 */
   1.159 -	typedef int		GroupId;
   1.160 -
   1.161 -	/**
   1.162 -	 * @brief Represents an index to one user entry.
   1.163 -	 */
   1.164 -	typedef int		AdminId;
   1.165 -
   1.166 -	/**
   1.167 -	 * @brief Represents an invalid/nonexistent group or an erroneous operation.
   1.168 -	 */
   1.169 -	#define INVALID_GROUP_ID	-1
   1.170 -
   1.171 -	/**
   1.172 -	 * @brief Represents an invalid/nonexistent user or an erroneous operation.
   1.173 -	 */
   1.174 -	#define INVALID_ADMIN_ID	-1
   1.175 -
   1.176 -	/**
   1.177 -	 * @brief Represents the various cache regions.
   1.178 -	 */
   1.179 -	enum AdminCachePart
   1.180 -	{
   1.181 -		AdminCache_Overrides = 0,		/**< Global overrides */
   1.182 -		AdminCache_Groups = 1,			/**< All groups (automatically invalidates admins too) */
   1.183 -		AdminCache_Admins = 2,			/**< All admins */
   1.184 -	};
   1.185 -
   1.186 -	/**
   1.187 -	 * @brief Provides callbacks for admin cache operations.
   1.188 -	 */
   1.189 -	class IAdminListener
   1.190 -	{
   1.191 -	public:
   1.192 -		virtual unsigned int GetInterfaceVersion()
   1.193 -		{
   1.194 -			return SMINTERFACE_ADMINSYS_VERSION;
   1.195 -		}
   1.196 -	public:
   1.197 -		/**
   1.198 -		 * @brief Called when the admin cache needs to be rebuilt.  
   1.199 -		 *
   1.200 -		 * @param auto_rebuild		True if this is being called because of a group rebuild.
   1.201 -		 */
   1.202 -		virtual void OnRebuildAdminCache(bool auto_rebuild) =0;
   1.203 -
   1.204 -		/**
   1.205 -		 * @brief Called when the group cache needs to be rebuilt.
   1.206 -		 */
   1.207 -		virtual void OnRebuildGroupCache() =0;
   1.208 -		
   1.209 -		/**
   1.210 -		 * @brief Called when the global override cache needs to be rebuilt.
   1.211 -		 */
   1.212 -		virtual void OnRebuildOverrideCache() =0;
   1.213 -	};
   1.214 -
   1.215 -	/**
   1.216 -	 * @brief Admin permission levels.
   1.217 -	 */
   1.218 -	typedef unsigned int FlagBits;
   1.219 -
   1.220 -	/**
   1.221 -	 * @brief Provides functions for manipulating the admin options cache.
   1.222 -	 */
   1.223 -	class IAdminSystem : public SMInterface
   1.224 -	{
   1.225 -	public:
   1.226 -		const char *GetInterfaceName()
   1.227 -		{
   1.228 -			return SMINTERFACE_ADMINSYS_NAME;
   1.229 -		}
   1.230 -		unsigned int GetInterfaceVersion()
   1.231 -		{
   1.232 -			return SMINTERFACE_ADMINSYS_VERSION;
   1.233 -		}
   1.234 -	public:
   1.235 -		/**
   1.236 -		 * @brief Adds a global command flag override.  Any command registered with this name
   1.237 -		 * will assume the new flag.  This is applied retroactively as well.
   1.238 -		 *
   1.239 -		 * @param cmd			String containing command name (case sensitive).
   1.240 -		 * @param type			Override type (specific command or group).
   1.241 -		 * @param flags			New admin flag.
   1.242 -		 */
   1.243 -		virtual void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags) =0;
   1.244 -
   1.245 -		/**
   1.246 -		 * @brief Returns a command override.
   1.247 -		 *
   1.248 -		 * @param cmd			String containing command name (case sensitive).
   1.249 -		 * @param type			Override type (specific command or group).
   1.250 -		 * @param pFlags		Optional pointer to the set flag.
   1.251 -		 * @return				True if there is an override, false otherwise.
   1.252 -		 */
   1.253 -		virtual bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags) =0;
   1.254 -
   1.255 -		/**
   1.256 -		 * @brief Unsets a command override.
   1.257 -		 *
   1.258 -		 * @param cmd			String containing command name (case sensitive).
   1.259 -		 * @param type			Override type (specific command or group).
   1.260 -		 */
   1.261 -		virtual void UnsetCommandOverride(const char *cmd, OverrideType type) =0;
   1.262 -
   1.263 -		/**
   1.264 -		 * @brief Adds a new group.  Name must be unique.
   1.265 -		 *
   1.266 -		 * @param group_name	String containing the group name.
   1.267 -		 * @return				A new group id, INVALID_GROUP_ID if it already exists.
   1.268 -		 */
   1.269 -		virtual GroupId AddGroup(const char *group_name) =0;
   1.270 -
   1.271 -		/**
   1.272 -		 * @brief Finds a group by name.
   1.273 -		 *
   1.274 -		 * @param group_name	String containing the group name.
   1.275 -		 * @return				A group id, or INVALID_GROUP_ID if not found.
   1.276 -		 */
   1.277 -		virtual GroupId FindGroupByName(const char *group_name) =0;
   1.278 -
   1.279 -		/**
   1.280 -		 * @brief Adds or removes a flag from a group's flag set.
   1.281 -		 * Note: These are called "add flags" because they add to a user's flags.
   1.282 -		 *
   1.283 -		 * @param id			Group id.
   1.284 -		 * @param flag			Admin flag to toggle.
   1.285 -		 * @param enabled		True to set the flag, false to unset/disable.
   1.286 -		 */
   1.287 -		virtual void SetGroupAddFlag(GroupId id, AdminFlag flag, bool enabled) =0;
   1.288 -
   1.289 -		/**
   1.290 -		 * @brief Gets the set value of an add flag on a group's flag set.
   1.291 -		 *
   1.292 -		 * @param id			Group id.
   1.293 -		 * @param flag			Admin flag to retrieve.
   1.294 -		 * @return				True if enabled, false otherwise,
   1.295 -		 */
   1.296 -		virtual bool GetGroupAddFlag(GroupId id, AdminFlag flag) =0;
   1.297 -
   1.298 -		/**
   1.299 -		 * @brief Returns an array of flag bits that are added to a user from their group.
   1.300 -		 * Note: These are called "add flags" because they add to a user's flags.
   1.301 -		 *
   1.302 -		 * @param id			GroupId of the group.
   1.303 -		 * @return				Bit string containing the bits of each flag.
   1.304 -		 */
   1.305 -		virtual FlagBits GetGroupAddFlags(GroupId id) =0;
   1.306 -
   1.307 -		/**
   1.308 -		 * @brief DEPRECATED.  Sets a group's immunity level using backwards 
   1.309 -		 * compatible types.  
   1.310 -		 *
   1.311 -		 * If the new level being set is lower than the group's actual immunity 
   1.312 -		 * level, no operation takes place.
   1.313 -		 *
   1.314 -		 * @param id			Group id.
   1.315 -		 * @param type			Immunity type which will be converted to a 
   1.316 -		 * 						numerical level.
   1.317 -		 * @param enabled		True to set the level.  False sets the 
   1.318 -		 * 						group's immunity value to 0.
   1.319 -		 */
   1.320 -		virtual void SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled) =0;
   1.321 -
   1.322 -		/**
   1.323 -		 * @brief DEPRECATED.  Returns whether a group has an immunity level
   1.324 -		 * using backwards compatible types.
   1.325 -		 * 
   1.326 -		 * This simply checks whether the group's immunity value is greater 
   1.327 -		 * than or equal to the new-style value for the old type.
   1.328 -		 *
   1.329 -		 * @param id			Group id.
   1.330 -		 * @param type			Generic immunity type.
   1.331 -		 * @return				True if the group has this immunity, false 
   1.332 -		 * 						otherwise.
   1.333 -		 */
   1.334 -		virtual bool GetGroupGenericImmunity(GroupId id, ImmunityType type) =0;
   1.335 -
   1.336 -		/**
   1.337 -		 * @brief Adds immunity to a specific group.
   1.338 -		 *
   1.339 -		 * @param id			Group id.
   1.340 -		 * @param other_id		Group id to receive immunity to.
   1.341 -		 */
   1.342 -		virtual void AddGroupImmunity(GroupId id, GroupId other_id) =0;
   1.343 -
   1.344 -		/**
   1.345 -		 * @brief Returns the number of specific group immunities.
   1.346 -		 *
   1.347 -		 * @param id			Group id.
   1.348 -		 * @return				Number of group immunities.
   1.349 -		 */
   1.350 -		virtual unsigned int GetGroupImmunityCount(GroupId id) =0;
   1.351 -
   1.352 -		/**
   1.353 -		 * @brief Returns a group that this group is immune to given an index.
   1.354 -		 *
   1.355 -		 * @param id			Group id.
   1.356 -		 * @param number		Index from 0 to N-1, from GetGroupImmunities().
   1.357 -		 * @return				GroupId that this group is immune to.
   1.358 -		 */
   1.359 -		virtual GroupId GetGroupImmunity(GroupId id, unsigned int number) =0;
   1.360 -
   1.361 -		/**
   1.362 -		 * @brief Adds a group-specific override type.
   1.363 -		 *
   1.364 -		 * @param id			Group id.
   1.365 -		 * @param name			String containing command name (case sensitive).
   1.366 -		 * @param type			Override type (specific command or group).
   1.367 -		 * @param rule			Override allow/deny setting.
   1.368 -		 */
   1.369 -		virtual void AddGroupCommandOverride(GroupId id,
   1.370 -											 const char *name,
   1.371 -											 OverrideType type,
   1.372 -											 OverrideRule rule) =0;
   1.373 -
   1.374 -		/**
   1.375 -		 * @brief Retrieves a group-specific command override.
   1.376 -		 *
   1.377 -		 * @param id			Group id.
   1.378 -		 * @param name			String containing command name (case sensitive).
   1.379 -		 * @param type			Override type (specific command or group).
   1.380 -		 * @param pRule			Optional pointer to store allow/deny setting.
   1.381 -		 * @return				True if an override exists, false otherwise.
   1.382 -		 */
   1.383 -		virtual bool GetGroupCommandOverride(GroupId id,
   1.384 -											 const char *name,
   1.385 -											 OverrideType type,
   1.386 -											 OverrideRule *pRule) =0;
   1.387 -
   1.388 -		/**
   1.389 -		 * @brief Tells the admin system to dump a portion of the cache.  
   1.390 -		 * This calls into plugin forwards to rebuild the cache.
   1.391 -		 *
   1.392 -		 * @param part			Portion of the cache to dump.
   1.393 -		 * @param rebuild		If true, the rebuild forwards/events will fire.
   1.394 -		 */
   1.395 -		virtual void DumpAdminCache(AdminCachePart part, bool rebuild) =0;
   1.396 -
   1.397 -		/**
   1.398 -		 * @brief Adds an admin interface listener.
   1.399 -		 *
   1.400 -		 * @param pListener		Pointer to an IAdminListener to add.
   1.401 -		 */
   1.402 -		virtual void AddAdminListener(IAdminListener *pListener) =0;
   1.403 -
   1.404 -		/**
   1.405 -		 * @brief Removes an admin interface listener.
   1.406 -		 *
   1.407 -		 * @param pListener		Pointer to an IAdminListener to remove.
   1.408 -		 */
   1.409 -		virtual void RemoveAdminListener(IAdminListener *pListener) =0;
   1.410 -
   1.411 -		/**
   1.412 -		 * @brief Registers an authentication identity type.
   1.413 -		 * Note: Default types are "steam," "name," and "ip."
   1.414 -		 *
   1.415 -		 * @param name			String containing the type name.
   1.416 -		 */
   1.417 -		virtual void RegisterAuthIdentType(const char *name) =0;
   1.418 -
   1.419 -		/**
   1.420 -		 * @brief Creates a new user entry.
   1.421 -		 *
   1.422 -		 * @param name		Name for this entry (does not have to be unique).
   1.423 -		 *					Specify NULL for an anonymous admin.
   1.424 -		 * @return			A new AdminId index.
   1.425 -		 */
   1.426 -		virtual AdminId CreateAdmin(const char *name) =0;
   1.427 -
   1.428 -		/**
   1.429 -		 * @brief Gets an admin's user name.
   1.430 -		 *
   1.431 -		 * @param id		AdminId index for this admin.
   1.432 -		 * @return			A string containing the admin's name, or NULL
   1.433 -		 *					if the admin was created anonymously.
   1.434 -		 */
   1.435 -		virtual const char *GetAdminName(AdminId id) =0;
   1.436 -
   1.437 -		/**
   1.438 -		 * @brief Binds a user entry to a particular auth method.
   1.439 -		 * This bind must be unique.
   1.440 -		 *
   1.441 -		 * @param id		AdminId index of the admin.
   1.442 -		 * @param auth		Auth method to use.
   1.443 -		 * @param ident		Identity string to bind to.
   1.444 -		 * @return			True on success, false if auth method was not found,
   1.445 -		 *					id was invalid, or ident was already taken.
   1.446 -		 */
   1.447 -		virtual bool BindAdminIdentity(AdminId id, const char *auth, const char *ident) =0;
   1.448 -
   1.449 -		/**
   1.450 -		 * @brief Sets whether or not a flag is enabled on an admin.
   1.451 -		 *
   1.452 -		 * @param id		AdminId index of the admin.
   1.453 -		 * @param flag		Admin flag to use.
   1.454 -		 * @param enabled	True to enable, false to disable.
   1.455 -		 */
   1.456 -		virtual void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled) =0;
   1.457 -
   1.458 -		/**
   1.459 -		 * @brief Returns whether or not a flag is enabled on an admin.
   1.460 -		 *
   1.461 -		 * @param id		AdminId index of the admin.
   1.462 -		 * @param flag		Admin flag to use.
   1.463 -		 * @param mode		Access mode to check.
   1.464 -		 * @return			True if enabled, false otherwise.
   1.465 -		 */
   1.466 -		virtual bool GetAdminFlag(AdminId id, AdminFlag flag, AccessMode mode) =0;
   1.467 -
   1.468 -		/**
   1.469 -		 * @brief Returns the bitstring of access flags on an admin.
   1.470 -		 *
   1.471 -		 * @param id		AdminId index of the admin.
   1.472 -		 * @param mode		Access mode to use.
   1.473 -		 * @return			A bit string containing which flags are enabled.
   1.474 -		 */
   1.475 -		virtual FlagBits GetAdminFlags(AdminId id, AccessMode mode) =0;
   1.476 -
   1.477 -		/**
   1.478 -		 * @brief Sets the bitstring of access flags on an admin.
   1.479 -		 *
   1.480 -		 * @param id		AdminId index of the admin.
   1.481 -		 * @param mode		Access mode to use (real affects both).
   1.482 -		 * @param bits		Bitstring to set.
   1.483 -		 */
   1.484 -		virtual void SetAdminFlags(AdminId id, AccessMode mode, FlagBits bits) =0;
   1.485 -
   1.486 -		/**
   1.487 -		 * @brief Adds a group to an admin's inherited group list.  
   1.488 -		 * Any flags the group has will be added to the admin's effective flags.
   1.489 -		 *
   1.490 -		 * @param id		AdminId index of the admin.
   1.491 -		 * @param gid		GroupId index of the group.
   1.492 -		 * @return			True on success, false on invalid input or duplicate membership.
   1.493 -		 */
   1.494 -		virtual bool AdminInheritGroup(AdminId id, GroupId gid) =0;
   1.495 -
   1.496 -		/**
   1.497 -		 * @brief Returns the number of groups this admin is a member of.
   1.498 -		 * 
   1.499 -		 * @param id		AdminId index of the admin.
   1.500 -		 * @return			Number of groups this admin is a member of.
   1.501 -		 */
   1.502 -		virtual unsigned int GetAdminGroupCount(AdminId id) =0;
   1.503 -
   1.504 -		/**
   1.505 -		 * @brief Returns group information from an admin.
   1.506 -		 *
   1.507 -		 * @param id		AdminId index of the admin.
   1.508 -		 * @param index		Group number to retrieve, from 0 to N-1, where N
   1.509 -		 *					is the value of GetAdminGroupCount(id).
   1.510 -		 * @param name		Optional pointer to store the group's name.
   1.511 -		 * @return			A GroupId index and a name pointer, or
   1.512 -		 *					INVALID_GROUP_ID and NULL if an error occurred.
   1.513 -		 */
   1.514 -		virtual GroupId GetAdminGroup(AdminId id, unsigned int index, const char **name) =0;
   1.515 -		
   1.516 -		/**
   1.517 -		 * @brief Sets a password on an admin.
   1.518 -		 *
   1.519 -		 * @param id		AdminId index of the admin.
   1.520 -		 * @param password	String containing the password.
   1.521 -		 */
   1.522 -		virtual void SetAdminPassword(AdminId id, const char *password) =0;
   1.523 -
   1.524 -		/**
   1.525 -		 * @brief Gets an admin's password.
   1.526 -		 *
   1.527 -		 * @param id		AdminId index of the admin.
   1.528 -		 * @return			Password of the admin, or NULL if none.
   1.529 -		 */
   1.530 -		virtual const char *GetAdminPassword(AdminId id) =0;
   1.531 -		
   1.532 -		/**
   1.533 -		 * @brief Attempts to find an admin by an auth method and an identity.
   1.534 -		 *
   1.535 -		 * @param auth		Auth method to try.
   1.536 -		 * @param identity	Identity string to look up.
   1.537 -		 * @return			An AdminId index if found, INVALID_ADMIN_ID otherwise.
   1.538 -		 */
   1.539 -		virtual AdminId FindAdminByIdentity(const char *auth, const char *identity) =0;
   1.540 -
   1.541 -		/**
   1.542 -		 * @brief Invalidates an admin from the cache so its resources can be re-used.
   1.543 -		 *
   1.544 -		 * @param id		AdminId index to invalidate.
   1.545 -		 * @return			True on success, false otherwise.
   1.546 -		 */
   1.547 -		virtual bool InvalidateAdmin(AdminId id) =0;
   1.548 -
   1.549 -		/**
   1.550 -		 * @brief Converts a flag bit string to a bit array.
   1.551 -		 *
   1.552 -		 * @param bits		Bit string containing the flags.
   1.553 -		 * @param array		Array to write the flags to.  Enabled flags will be 'true'.
   1.554 -		 * @param maxSize	Maximum number of flags the array can store.
   1.555 -		 * @return			Number of flags written.
   1.556 -		 */
   1.557 -		virtual unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize) =0;
   1.558 -
   1.559 -		/**
   1.560 -		 * @brief Converts a flag array to a bit string.
   1.561 -		 *
   1.562 -		 * @param array		Array containing true or false for each AdminFlag.
   1.563 -		 * @param maxSize	Maximum size of the flag array.
   1.564 -		 * @return			A bit string composed of the array bits.
   1.565 -		 */
   1.566 -		virtual FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize) =0;
   1.567 -
   1.568 -		/**
   1.569 -		 * @brief Converts an array of flags to bits.
   1.570 -		 *
   1.571 -		 * @param array		Array containing flags that are enabled.
   1.572 -		 * @param numFlags	Number of flags in the array.
   1.573 -		 * @return			A bit string composed of the array flags.
   1.574 -		 */
   1.575 -		virtual FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags) =0;
   1.576 -
   1.577 -		/**
   1.578 -		 * @brief Converts a bit string to an array of flags.
   1.579 -		 *
   1.580 -		 * @param bits		Bit string containing the flags.
   1.581 -		 * @param array		Output array to write flags.
   1.582 -		 * @param maxSize	Maximum size of the flag array.
   1.583 -		 * @return			Number of flags written.
   1.584 -		 */
   1.585 -		virtual unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize) =0;
   1.586 -
   1.587 -		/**
   1.588 -		 * @brief Checks whether a user has access to a given set of flag bits.
   1.589 -		 * Note: This is a wrapper around GetAdminFlags().
   1.590 -		 *
   1.591 -		 * @param id		AdminId index of admin.
   1.592 -		 * @param bits		Bitstring containing the permissions to check.
   1.593 -		 * @return			True if user has permission, false otherwise.
   1.594 -		 */
   1.595 -		virtual bool CheckAdminFlags(AdminId id, FlagBits bits) =0;
   1.596 -
   1.597 -		/**
   1.598 -		 * @brief Checks whether an AdminId can target another AdminId.
   1.599 -		 * 
   1.600 -		 * The hueristics for this check are as follows:
   1.601 -		 * 0. If the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
   1.602 -		 * 1. If the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
   1.603 -		 * 2. If the targeted AdminId is the same as the targeting AdminId,
   1.604 -		 *    (self) targeting succeeds.
   1.605 -		 * 3. If the targeting admin is root, targeting succeeds.
   1.606 -		 * 4. If the targeted admin has access higher (as interpreted by 
   1.607 -		 *    (sm_immunity_mode) than the targeting admin, then targeting fails.
   1.608 -		 * 5. If the targeted admin has specific immunity from the
   1.609 -		 *    targeting admin via group immunities, targeting fails.
   1.610 -		 * 6. Targeting succeeds.
   1.611 -		 *
   1.612 -		 * @param id		AdminId index of admin doing the targeting.  Can be INVALID_ADMIN_ID.
   1.613 -		 * @param target	AdminId index of the target admin.  Can be INVALID_ADMIN_ID.
   1.614 -		 * @return			True if this admin has permission to target the other admin.
   1.615 -		 */
   1.616 -		virtual bool CanAdminTarget(AdminId id, AdminId target) =0;
   1.617 -
   1.618 -		/**
   1.619 -		 * @brief Returns a flag from a named string.
   1.620 -		 *
   1.621 -		 * @param flagname	Case sensitive flag name string (like "kick").
   1.622 -		 * @param pAdmFlag	Pointer to store the found admin flag in.
   1.623 -		 * @return			True on success, false on failure.
   1.624 -		 */
   1.625 -		virtual bool FindFlag(const char *flagname, AdminFlag *pAdmFlag) =0;
   1.626 -
   1.627 -		/**
   1.628 -		 * @brief Reads a single character as a flag.
   1.629 -		 *
   1.630 -		 * @param c			Flag character.
   1.631 -		 * @param pAdmFlag	Pointer to store the admin flag.
   1.632 -		 * @return			True on success, false if invalid.
   1.633 -		 */
   1.634 -		virtual bool FindFlag(char c, AdminFlag *pAdmFlag) =0;
   1.635 -
   1.636 -		/**
   1.637 -		 * @brief Reads a string of flag letters and returns its access value.
   1.638 -		 *
   1.639 -		 * @param flags		Flag string.
   1.640 -		 * @param end		Pointer to store the last value read.  On success, 
   1.641 -		 *					this will store a pointer to the null terminator.
   1.642 -		 * @return			FlagBits value of the flags.
   1.643 -		 */
   1.644 -		virtual FlagBits ReadFlagString(const char *flags, const char **end) =0;
   1.645 -
   1.646 -		/**
   1.647 -		 * @brief Returns a "serial number" for an AdminId.  If the serial 
   1.648 -		 * number has changed for a given AdminId, it means the permissions 
   1.649 -		 * have changed.
   1.650 -		 *
   1.651 -		 * @param id		AdminId value.
   1.652 -		 * @return			Serial number, or 0 on failure.
   1.653 -		 */
   1.654 -		virtual unsigned int GetAdminSerialChange(AdminId id) =0;
   1.655 -
   1.656 -		/**
   1.657 -		 * @brief Checks whether an admin can use the given command name.
   1.658 -		 *
   1.659 -		 * If the command does not exist, this will return true.
   1.660 -		 *
   1.661 -		 * @param client	Client index.
   1.662 -		 * @param cmd		Command name.
   1.663 -		 * @return			True on success, false on failure.
   1.664 -		 */
   1.665 -		virtual bool CanAdminUseCommand(int client, const char *cmd) =0;
   1.666 -
   1.667 -		/**
   1.668 -		 * @brief Returns the name of a group.
   1.669 -		 *
   1.670 -		 * @param gid		Group Id.
   1.671 -		 * @return			Group name, or NULL on failure.
   1.672 -		 */
   1.673 -		virtual const char *GetGroupName(GroupId gid) =0;
   1.674 -
   1.675 -		/**
   1.676 -		 * @brief Sets the immunity level of a group.
   1.677 -		 * 
   1.678 -		 * @param gid		Group Id.
   1.679 -		 * @param level		Immunity level value.
   1.680 -		 * @return			Old immunity level.
   1.681 -		 */
   1.682 -		virtual unsigned int SetGroupImmunityLevel(GroupId gid, unsigned int level) =0;
   1.683 -
   1.684 -		/**
   1.685 -		 * @brief Retrieves the immunity level of a group.
   1.686 -		 *
   1.687 -		 * @param gid		Group Id.
   1.688 -		 * @return			Immunity level value.
   1.689 -		 */
   1.690 -		virtual unsigned int GetGroupImmunityLevel(GroupId gid) =0;
   1.691 -
   1.692 -		/**
   1.693 -		 * @brief Sets the immunity level of an admin.
   1.694 -		 *
   1.695 -		 * @param id		Admin Id.
   1.696 -		 * @param level		Immunity level value.
   1.697 -		 * @return			Old immunity level.
   1.698 -		 */
   1.699 -		virtual unsigned int SetAdminImmunityLevel(AdminId id, unsigned int level) =0;
   1.700 -
   1.701 -		/**
   1.702 -		 * @brief Retrieves the immunity level of an admin.
   1.703 -		 *
   1.704 -		 * @param id		Admin Id.
   1.705 -		 * @return			Immunity level value.
   1.706 -		 */
   1.707 -		virtual unsigned int GetAdminImmunityLevel(AdminId id) =0;
   1.708 -
   1.709 -		/**
   1.710 -		 * @brief Computers access to an override.
   1.711 -		 *
   1.712 -		 * @param client		Client index.
   1.713 -		 * @param cmd			Override name.
   1.714 -		 * @param flags			Default flags.
   1.715 -		 * @param override_only	If false, if a command matches the override, 
   1.716 -		 *						then its flags will override the default.
   1.717 -		 * @return				True if the client has access, false otherwise.
   1.718 -		 */
   1.719 -		virtual bool CheckAccess(int client, 
   1.720 -			const char *cmd, 
   1.721 -			FlagBits flags, 
   1.722 -			bool override_only) =0;
   1.723 -	};
   1.724 -}
   1.725 -
   1.726 -#endif //_INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
   1.727 -