SourceMod SDK  1.7
IAdminSystem.h
Go to the documentation of this file.
1 
32 #ifndef _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
33 #define _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
34 
35 #include <IShareSys.h>
36 
37 #define SMINTERFACE_ADMINSYS_NAME "IAdminSys"
38 #define SMINTERFACE_ADMINSYS_VERSION 8
39 
63 namespace SourceMod
64 {
68  enum AdminFlag
69  {
70  Admin_Reservation = 0,
71  Admin_Generic,
72  Admin_Kick,
73  Admin_Ban,
74  Admin_Unban,
75  Admin_Slay,
76  Admin_Changemap,
77  Admin_Convars,
78  Admin_Config,
79  Admin_Chat,
80  Admin_Vote,
81  Admin_Password,
82  Admin_RCON,
83  Admin_Cheats,
84  Admin_Root,
85  Admin_Custom1,
86  Admin_Custom2,
87  Admin_Custom3,
88  Admin_Custom4,
89  Admin_Custom5,
90  Admin_Custom6,
91  /* --- */
92  AdminFlags_TOTAL,
93  };
94 
95  #define ADMFLAG_RESERVATION (1<<0)
96  #define ADMFLAG_GENERIC (1<<1)
97  #define ADMFLAG_KICK (1<<2)
98  #define ADMFLAG_BAN (1<<3)
99  #define ADMFLAG_UNBAN (1<<4)
100  #define ADMFLAG_SLAY (1<<5)
101  #define ADMFLAG_CHANGEMAP (1<<6)
102  #define ADMFLAG_CONVARS (1<<7)
103  #define ADMFLAG_CONFIG (1<<8)
104  #define ADMFLAG_CHAT (1<<9)
105  #define ADMFLAG_VOTE (1<<10)
106  #define ADMFLAG_PASSWORD (1<<11)
107  #define ADMFLAG_RCON (1<<12)
108  #define ADMFLAG_CHEATS (1<<13)
109  #define ADMFLAG_ROOT (1<<14)
110  #define ADMFLAG_CUSTOM1 (1<<15)
111  #define ADMFLAG_CUSTOM2 (1<<16)
112  #define ADMFLAG_CUSTOM3 (1<<17)
113  #define ADMFLAG_CUSTOM4 (1<<18)
114  #define ADMFLAG_CUSTOM5 (1<<19)
115  #define ADMFLAG_CUSTOM6 (1<<20)
120  enum OverrideType
121  {
122  Override_Command = 1,
123  Override_CommandGroup,
124  };
125 
129  enum OverrideRule
130  {
131  Command_Deny = 0,
132  Command_Allow = 1,
133  };
134 
138  enum ImmunityType
139  {
140  Immunity_Default = 1,
141  Immunity_Global,
142  };
143 
147  enum AccessMode
148  {
149  Access_Real,
150  Access_Effective,
151  };
152 
156  typedef int GroupId;
157 
161  typedef int AdminId;
162 
166  #define INVALID_GROUP_ID -1
167 
171  #define INVALID_ADMIN_ID -1
172 
176  enum AdminCachePart
177  {
178  AdminCache_Overrides = 0,
179  AdminCache_Groups = 1,
180  AdminCache_Admins = 2,
181  };
182 
187  {
188  public:
189  virtual unsigned int GetInterfaceVersion()
190  {
191  return SMINTERFACE_ADMINSYS_VERSION;
192  }
193  public:
199  virtual void OnRebuildAdminCache(bool auto_rebuild) =0;
200 
204  virtual void OnRebuildGroupCache() =0;
205 
209  virtual void OnRebuildOverrideCache() =0;
210  };
211 
215  typedef unsigned int FlagBits;
216 
220  class IAdminSystem : public SMInterface
221  {
222  public:
223  const char *GetInterfaceName()
224  {
226  }
227  unsigned int GetInterfaceVersion()
228  {
229  return SMINTERFACE_ADMINSYS_VERSION;
230  }
231  public:
240  virtual void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags) =0;
241 
250  virtual bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags) =0;
251 
258  virtual void UnsetCommandOverride(const char *cmd, OverrideType type) =0;
259 
266  virtual GroupId AddGroup(const char *group_name) =0;
267 
274  virtual GroupId FindGroupByName(const char *group_name) =0;
275 
284  virtual void SetGroupAddFlag(GroupId id, AdminFlag flag, bool enabled) =0;
285 
293  virtual bool GetGroupAddFlag(GroupId id, AdminFlag flag) =0;
294 
302  virtual FlagBits GetGroupAddFlags(GroupId id) =0;
303 
317  virtual void SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled) =0;
318 
331  virtual bool GetGroupGenericImmunity(GroupId id, ImmunityType type) =0;
332 
339  virtual void AddGroupImmunity(GroupId id, GroupId other_id) =0;
340 
347  virtual unsigned int GetGroupImmunityCount(GroupId id) =0;
348 
356  virtual GroupId GetGroupImmunity(GroupId id, unsigned int number) =0;
357 
366  virtual void AddGroupCommandOverride(GroupId id,
367  const char *name,
368  OverrideType type,
369  OverrideRule rule) =0;
370 
380  virtual bool GetGroupCommandOverride(GroupId id,
381  const char *name,
382  OverrideType type,
383  OverrideRule *pRule) =0;
384 
392  virtual void DumpAdminCache(AdminCachePart part, bool rebuild) =0;
393 
399  virtual void AddAdminListener(IAdminListener *pListener) =0;
400 
406  virtual void RemoveAdminListener(IAdminListener *pListener) =0;
407 
414  virtual void RegisterAuthIdentType(const char *name) =0;
415 
423  virtual AdminId CreateAdmin(const char *name) =0;
424 
432  virtual const char *GetAdminName(AdminId id) =0;
433 
444  virtual bool BindAdminIdentity(AdminId id, const char *auth, const char *ident) =0;
445 
453  virtual void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled) =0;
454 
463  virtual bool GetAdminFlag(AdminId id, AdminFlag flag, AccessMode mode) =0;
464 
472  virtual FlagBits GetAdminFlags(AdminId id, AccessMode mode) =0;
473 
481  virtual void SetAdminFlags(AdminId id, AccessMode mode, FlagBits bits) =0;
482 
491  virtual bool AdminInheritGroup(AdminId id, GroupId gid) =0;
492 
499  virtual unsigned int GetAdminGroupCount(AdminId id) =0;
500 
511  virtual GroupId GetAdminGroup(AdminId id, unsigned int index, const char **name) =0;
512 
519  virtual void SetAdminPassword(AdminId id, const char *password) =0;
520 
527  virtual const char *GetAdminPassword(AdminId id) =0;
528 
536  virtual AdminId FindAdminByIdentity(const char *auth, const char *identity) =0;
537 
544  virtual bool InvalidateAdmin(AdminId id) =0;
545 
554  virtual unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize) =0;
555 
563  virtual FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize) =0;
564 
572  virtual FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags) =0;
573 
582  virtual unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize) =0;
583 
592  virtual bool CheckAdminFlags(AdminId id, FlagBits bits) =0;
593 
613  virtual bool CanAdminTarget(AdminId id, AdminId target) =0;
614 
622  virtual bool FindFlag(const char *flagname, AdminFlag *pAdmFlag) =0;
623 
631  virtual bool FindFlag(char c, AdminFlag *pAdmFlag) =0;
632 
641  virtual FlagBits ReadFlagString(const char *flags, const char **end) =0;
642 
651  virtual unsigned int GetAdminSerialChange(AdminId id) =0;
652 
662  virtual bool CanAdminUseCommand(int client, const char *cmd) =0;
663 
670  virtual const char *GetGroupName(GroupId gid) =0;
671 
679  virtual unsigned int SetGroupImmunityLevel(GroupId gid, unsigned int level) =0;
680 
687  virtual unsigned int GetGroupImmunityLevel(GroupId gid) =0;
688 
696  virtual unsigned int SetAdminImmunityLevel(AdminId id, unsigned int level) =0;
697 
704  virtual unsigned int GetAdminImmunityLevel(AdminId id) =0;
705 
716  virtual bool CheckAccess(int client,
717  const char *cmd,
718  FlagBits flags,
719  bool override_only) =0;
720 
728  virtual bool FindFlagChar(AdminFlag flag, char *c) =0;
729 
736  virtual bool IsValidAdmin(AdminId id) =0;
737 
746  virtual bool CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags) =0;
747  };
748 }
749 
750 #endif //_INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
751 
virtual void SetAdminPassword(AdminId id, const char *password)=0
Sets a password on an admin.
virtual GroupId GetGroupImmunity(GroupId id, unsigned int number)=0
Returns a group that this group is immune to given an index.
const char * GetInterfaceName()
Must return a string defining the interface's unique name.
Definition: IAdminSystem.h:223
virtual bool FindFlagChar(AdminFlag flag, char *c)=0
Reads a flag as the corresponding character.
virtual GroupId AddGroup(const char *group_name)=0
Adds a new group. Name must be unique.
virtual FlagBits ReadFlagString(const char *flags, const char **end)=0
Reads a string of flag letters and returns its access value.
virtual bool CheckAdminFlags(AdminId id, FlagBits bits)=0
Checks whether a user has access to a given set of flag bits. Note: This is a wrapper around GetAdmin...
virtual void UnsetCommandOverride(const char *cmd, OverrideType type)=0
Unsets a command override.
virtual bool GetGroupGenericImmunity(GroupId id, ImmunityType type)=0
DEPRECATED. Returns whether a group has an immunity level using backwards compatible types...
virtual bool IsValidAdmin(AdminId id)=0
Returns whether or not an admin id is valid.
virtual void OnRebuildOverrideCache()=0
Called when the global override cache needs to be rebuilt.
#define SMINTERFACE_ADMINSYS_NAME
Definition: IAdminSystem.h:37
virtual GroupId FindGroupByName(const char *group_name)=0
Finds a group by name.
virtual bool GetGroupAddFlag(GroupId id, AdminFlag flag)=0
Gets the set value of an add flag on a group's flag set.
virtual void AddGroupCommandOverride(GroupId id, const char *name, OverrideType type, OverrideRule rule)=0
Adds a group-specific override type.
Defines the Share System, responsible for shared resources and dependencies.
virtual void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled)=0
Sets whether or not a flag is enabled on an admin.
virtual GroupId GetAdminGroup(AdminId id, unsigned int index, const char **name)=0
Returns group information from an admin.
virtual unsigned int SetAdminImmunityLevel(AdminId id, unsigned int level)=0
Sets the immunity level of an admin.
Defines the base functionality required by a shared interface.
Definition: IShareSys.h:92
virtual FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags)=0
Converts an array of flags to bits.
virtual unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize)=0
Converts a flag bit string to a bit array.
Provides functions for manipulating the admin options cache.
Definition: IAdminSystem.h:220
virtual void RegisterAuthIdentType(const char *name)=0
Registers an authentication identity type. Note: Default types are "steam," "name," and "ip.".
virtual void RemoveAdminListener(IAdminListener *pListener)=0
Removes an admin interface listener.
virtual unsigned int GetGroupImmunityLevel(GroupId gid)=0
Retrieves the immunity level of a group.
virtual unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize)=0
Converts a bit string to an array of flags.
virtual void DumpAdminCache(AdminCachePart part, bool rebuild)=0
Tells the admin system to dump a portion of the cache. This calls into plugin forwards to rebuild the...
virtual FlagBits GetAdminFlags(AdminId id, AccessMode mode)=0
Returns the bitstring of access flags on an admin.
virtual void OnRebuildGroupCache()=0
Called when the group cache needs to be rebuilt.
unsigned int GetInterfaceVersion()
Must return an integer defining the interface's version.
Definition: IAdminSystem.h:227
virtual bool InvalidateAdmin(AdminId id)=0
Invalidates an admin from the cache so its resources can be re-used.
virtual void SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled)=0
DEPRECATED. Sets a group's immunity level using backwards compatible types.
virtual const char * GetAdminName(AdminId id)=0
Gets an admin's user name.
virtual bool CanAdminUseCommand(int client, const char *cmd)=0
Checks whether an admin can use the given command name.
virtual void AddAdminListener(IAdminListener *pListener)=0
Adds an admin interface listener.
virtual unsigned int SetGroupImmunityLevel(GroupId gid, unsigned int level)=0
Sets the immunity level of a group.
virtual const char * GetGroupName(GroupId gid)=0
Returns the name of a group.
virtual bool CheckAccess(int client, const char *cmd, FlagBits flags, bool override_only)=0
Computers access to an override.
virtual unsigned int GetGroupImmunityCount(GroupId id)=0
Returns the number of specific group immunities.
virtual const char * GetAdminPassword(AdminId id)=0
Gets an admin's password.
virtual bool CanAdminTarget(AdminId id, AdminId target)=0
Checks whether an AdminId can target another AdminId.
virtual void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags)=0
Adds a global command flag override. Any command registered with this name will assume the new flag...
virtual AdminId CreateAdmin(const char *name)=0
Creates a new user entry.
virtual bool GetAdminFlag(AdminId id, AdminFlag flag, AccessMode mode)=0
Returns whether or not a flag is enabled on an admin.
virtual FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize)=0
Converts a flag array to a bit string.
virtual bool FindFlag(const char *flagname, AdminFlag *pAdmFlag)=0
Returns a flag from a named string.
virtual bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags)=0
Returns a command override.
Definition: IAdminSystem.h:63
virtual AdminId FindAdminByIdentity(const char *auth, const char *identity)=0
Attempts to find an admin by an auth method and an identity.
Provides callbacks for admin cache operations.
Definition: IAdminSystem.h:186
virtual bool BindAdminIdentity(AdminId id, const char *auth, const char *ident)=0
Binds a user entry to a particular auth method. This bind must be unique.
virtual unsigned int GetAdminImmunityLevel(AdminId id)=0
Retrieves the immunity level of an admin.
virtual void SetAdminFlags(AdminId id, AccessMode mode, FlagBits bits)=0
Sets the bitstring of access flags on an admin.
virtual FlagBits GetGroupAddFlags(GroupId id)=0
Returns an array of flag bits that are added to a user from their group. Note: These are called "add ...
virtual void OnRebuildAdminCache(bool auto_rebuild)=0
Called when the admin cache needs to be rebuilt.
virtual bool AdminInheritGroup(AdminId id, GroupId gid)=0
Adds a group to an admin's inherited group list. Any flags the group has will be added to the admin's...
virtual bool CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags)=0
Returns whether or not a client has access to a given command.
virtual void SetGroupAddFlag(GroupId id, AdminFlag flag, bool enabled)=0
Adds or removes a flag from a group's flag set. Note: These are called "add flags" because they add t...
virtual unsigned int GetAdminSerialChange(AdminId id)=0
Returns a "serial number" for an AdminId. If the serial number has changed for a given AdminId...
virtual void AddGroupImmunity(GroupId id, GroupId other_id)=0
Adds immunity to a specific group.
virtual unsigned int GetAdminGroupCount(AdminId id)=0
Returns the number of groups this admin is a member of.
virtual bool GetGroupCommandOverride(GroupId id, const char *name, OverrideType type, OverrideRule *pRule)=0
Retrieves a group-specific command override.