* @param add If true, the capability is being added, otherwise its being removed
*/
virtual void OnCapAddDel(Capability* cap, bool add) = 0;
+
+ /** Called whenever the value of a cap changes.
+ * @param cap Capability whose value changed
+ */
+ virtual void OnCapValueChange(Capability* cap) { }
};
class Manager : public DataProvider
* @return Capability object pointer if found, NULL otherwise
*/
virtual Capability* Find(const std::string& name) const = 0;
+
+ /** Notify manager when a value of a cap changed
+ * @param cap Cap whose value changed
+ */
+ virtual void NotifyValueChange(Capability* cap) = 0;
};
/** Represents a client capability.
friend class ManagerImpl;
+ protected:
+ /** Notify the manager that the value of the capability changed.
+ * Must be called if the value of the cap changes for any reason.
+ */
+ void NotifyValueChange()
+ {
+ if (IsRegistered())
+ manager->NotifyValueChange(this);
+ }
+
public:
/** Constructor, initializes the capability.
* Caps are active by default.
return NULL;
}
+ void NotifyValueChange(Capability* cap) CXX11_OVERRIDE
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Cap %s changed value", cap->GetName().c_str());
+ FOREACH_MOD_CUSTOM(evprov, Cap::EventListener, OnCapValueChange, (cap));
+ }
+
Protocol GetProtocol(LocalUser* user) const
{
return ((capext.get(user) & CAP_302_BIT) ? CAP_302 : CAP_LEGACY);