From 725ea566a2b6a12e0a02e4f570b6e99102e2d21b Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 8 Apr 2019 21:04:12 +0200 Subject: Refactor, remove a lot of code and use dchat core instead --- include/Channel.hpp | 103 ---------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 include/Channel.hpp (limited to 'include/Channel.hpp') diff --git a/include/Channel.hpp b/include/Channel.hpp deleted file mode 100644 index 58bbcc3..0000000 --- a/include/Channel.hpp +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once - -#include "MessageBoard.hpp" -#include "Chatbar.hpp" -#include "User.hpp" -#include "Channel.hpp" -#include "types.hpp" -#include "Suggestions.hpp" -#include "../bridge/DiscordService.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace dchat -{ - enum class ChannelDataType : u8 - { - ADD_MESSAGE, - EDIT_MESSAGE, - DELETE_MESSAGE, - NICKNAME_CHANGE, - CHANGE_AVATAR, - CHANGE_CHANNEL_NAME, - }; - - class Channel - { - public: - Channel(const std::string &name, const odhtdb::DatabaseNode &databaseNodeInfo = odhtdb::DatabaseNode(), User *localUser = nullptr, std::shared_ptr database = nullptr); - virtual ~Channel(); - Channel(const Channel& other) = delete; - Channel& operator = (const Channel &other) = delete; - - User* getLocalUser(); - SystemUser* getSystemUser(); - MessageBoard& getMessageBoard(); - - const std::string& getName() const; - const std::vector& getUsers() const; - OnlineUser* getUserByPublicKey(const odhtdb::Signature::PublicKey &publicKey); - const odhtdb::DatabaseNode& getNodeInfo() const; - Message* getLatestMessage(); - - // If timestamp is 0, then current time is used - void addLocalMessage(const std::string &msg, User *owner, u64 timestampSeconds = 0); - void addLocalMessage(const std::string &msg, User *owner, u64 timestampSeconds, const odhtdb::Hash &id); - void addLocalDiscordMessage(const std::string &discordUserName, u64 discordUserId, const std::string &msg, User *owner, u64 timestampSeconds, const odhtdb::Hash &id); - void addSystemMessage(const std::string &msg, bool plainText = true); - void addMessage(const std::string &msg); - void deleteLocalMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser); - void deleteMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser); - - void addUserLocally(User *user); - bool addUser(const odhtdb::Signature::PublicKey &userId, const odhtdb::DataView &groupId); - void replaceLocalUser(OnlineLocalUser *newOnlineLocalUser); - void changeNick(const std::string &newNick); - void setAvatar(const std::string &newAvatarUrl); - void setNameLocally(const std::string &name); - void setName(const std::string &name); - - // Returns -1 on failure - int getUserLowestPermissionLevel(OnlineUser *user) const; - - void processEvent(const sf::Event &event, Cache &cache); - void draw(sf::RenderWindow &window, Cache &cache); - - void update(); - // Returns 0 if we are offline - u32 getSyncedTimestampUtcInSec(); - - const std::vector& getBridgeServices() const; - DiscordService* getDiscordService(); - - static void setCurrent(Channel *channel); - static Channel* getCurrent(); - private: - void sendPing(u32 pingTimestampSec); - protected: - std::shared_ptr database; - odhtdb::DatabaseNode databaseNodeInfo; - std::string name; - MessageBoard messageBoard; - Chatbar chatbar; - Suggestions suggestions; - User *localUser; - SystemUser systemUser; - std::vector users; - std::unordered_map discordUserById; - odhtdb::Signature::MapPublicKey publicKeyOnlineUsersMap; - odhtdb::InfoHash pingKey; - sibs::ListenHandle pingListener; - sf::Clock pingTimer; - - std::vector bridgeServices; - }; -} -- cgit v1.2.3