#pragma once #include "Variable.h" #include #include #include #include #include #include #include "src/VirtualServer.h" #include "../Group.h" #define DEBUG_PERMISSION namespace ts { namespace music { class MusicBotManager; } namespace server { class VirtualServer; class DataClient { friend class VirtualServer; friend class QueryServer; friend class music::MusicBotManager; public: struct PropertyWrapper { std::shared_ptr handle; Properties* operator->() { return handle.get(); } const Properties* operator->() const { return handle.get(); } template std::result_of_t operator->*(F &&f) { return std::forward(f)(*handle); } template std::result_of_t operator->*(F &&f) const { return std::forward(f)(*handle); } /* template ts::PropertyWrapper operator[](T type) { return (*handle)[type]; } */ template ts::PropertyWrapper operator[](const T& type) { return (*handle)[type]; } }; DataClient(sql::SqlManager*, const std::shared_ptr&); virtual ~DataClient(); PropertyWrapper properties(){ return { this->_properties }; } /* main permission calculate function */ permission::v2::PermissionFlaggedValue calculate_permission( permission::PermissionType, ChannelId channel, bool granted = false, std::shared_ptr cache = nullptr ); std::vector> calculate_permissions( const std::deque&, ChannelId channel, bool granted = false, std::shared_ptr cache = nullptr ); virtual std::vector> assignedServerGroups(); virtual std::shared_ptr assignedChannelGroup(const std::shared_ptr &); virtual bool serverGroupAssigned(const std::shared_ptr &); virtual bool channelGroupAssigned(const std::shared_ptr &, const std::shared_ptr &); virtual std::string getDisplayName() { return this->properties()[property::CLIENT_NICKNAME]; } virtual std::string getLoginName() { return this->properties()[property::CLIENT_LOGIN_NAME]; } virtual void setDisplayName(std::string displayName) { this->properties()[property::CLIENT_NICKNAME] = displayName; } virtual ClientType getExternalType(){ uint8_t type = this->properties()[property::CLIENT_TYPE]; return (ClientType) type; } virtual ClientType getType(){ uint8_t type = this->properties()[property::CLIENT_TYPE_EXACT]; return (ClientType) type; } virtual std::string getUid() { return this->properties()[property::CLIENT_UNIQUE_IDENTIFIER]; } virtual std::string getAvatarId(); virtual ClientDbId getClientDatabaseId() { return this->properties()[property::CLIENT_DATABASE_ID]; } virtual bool loadDataForCurrentServer(); protected: sql::SqlManager* sql; std::shared_ptr server; std::shared_ptr clientPermissions = nullptr; std::shared_ptr _properties; std::shared_ptr currentChannel = nullptr; }; } }