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/Cache.hpp | 91 -------------------------------------- include/Channel.hpp | 103 ------------------------------------------- include/ChannelSidePanel.hpp | 19 -------- include/ChannelTopPanel.hpp | 13 ------ include/Chatbar.hpp | 13 +++--- include/FileUtil.hpp | 2 +- include/Gif.hpp | 51 ++++----------------- include/ImagePreview.hpp | 1 + include/Message.hpp | 27 ++++-------- include/MessageBoard.hpp | 40 ++++++++++------- include/ResourceCache.hpp | 3 ++ include/Room.hpp | 15 +++++++ include/RoomContainer.hpp | 26 +++++++++++ include/RoomSidePanel.hpp | 15 +++++++ include/RoomTopPanel.hpp | 13 ++++++ include/Rpc.hpp | 21 --------- include/StaticImage.hpp | 17 +++++++ include/StringUtils.hpp | 18 -------- include/StringView.hpp | 95 --------------------------------------- include/Suggestions.hpp | 5 ++- include/Text.hpp | 12 ++--- include/User.hpp | 92 -------------------------------------- include/UsersSidePanel.hpp | 5 +-- include/WebPagePreview.hpp | 11 ++--- 24 files changed, 158 insertions(+), 550 deletions(-) delete mode 100644 include/Cache.hpp delete mode 100644 include/Channel.hpp delete mode 100644 include/ChannelSidePanel.hpp delete mode 100644 include/ChannelTopPanel.hpp create mode 100644 include/Room.hpp create mode 100644 include/RoomContainer.hpp create mode 100644 include/RoomSidePanel.hpp create mode 100644 include/RoomTopPanel.hpp delete mode 100644 include/Rpc.hpp create mode 100644 include/StaticImage.hpp delete mode 100644 include/StringUtils.hpp delete mode 100644 include/StringView.hpp delete mode 100644 include/User.hpp (limited to 'include') diff --git a/include/Cache.hpp b/include/Cache.hpp deleted file mode 100644 index fc702a7..0000000 --- a/include/Cache.hpp +++ /dev/null @@ -1,91 +0,0 @@ -#pragma once - -#include "types.hpp" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace TinyProcessLib -{ - class Process; -} - -namespace dchat -{ - class Gif; - class WebPagePreview; - - struct ContentByUrlResult - { - enum class Type - { - CACHED, - DOWNLOADING, - FAILED_DOWNLOAD - }; - - enum class CachedType - { - NONE, - TEXTURE, - GIF, - WEB_PAGE_PREVIEW - }; - - ContentByUrlResult() : texture(nullptr), type(Type::DOWNLOADING), cachedType(CachedType::NONE) {} - ContentByUrlResult(sf::Texture *_texture, Type _type) : texture(_texture), type(_type), cachedType(CachedType::TEXTURE) {} - ContentByUrlResult(Gif *_gif, Type _type) : gif(_gif), type(_type), cachedType(CachedType::GIF) {} - ContentByUrlResult(WebPagePreview *_webPagePreview, Type _type) : webPagePreview(_webPagePreview), type(_type), cachedType(CachedType::WEB_PAGE_PREVIEW) {} - - // @texture is null if @type is DOWNLOADING or FAILED_DOWNLOAD - union - { - sf::Texture *texture; - Gif *gif; - WebPagePreview *webPagePreview; - }; - - Type type; - CachedType cachedType; - i64 lastAccessed; - }; - - class Cache - { - public: - Cache(); - ~Cache(); - - // Creates directory if it doesn't exist (recursively). Throws boost exception on failure - static boost::filesystem::path getDchatDir(); - - // Creates directory if it doesn't exist (recursively). Throws boost exception on failure - static boost::filesystem::path getImagesDir(); - - static void loadBindsFromFile(); - static void replaceBindsInFile(const std::unordered_map &binds); - - // Get cached content or download it. - // Default download file limit is 12MB - // Returns ContentByUrlResult describing texture status. - const ContentByUrlResult getContentByUrl(const std::string &url, int downloadLimitBytes = 12582912); - private: - struct ImageDownloadInfo - { - TinyProcessLib::Process *process; - std::string url; - }; - - std::thread downloadWaitThread; - std::thread checkContentAccessTimeThread; - std::vector imageDownloadProcesses; - std::vector imageDownloadProcessesQueue; - std::mutex imageDownloadMutex; - bool alive; - }; -} 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; - }; -} diff --git a/include/ChannelSidePanel.hpp b/include/ChannelSidePanel.hpp deleted file mode 100644 index 265ee67..0000000 --- a/include/ChannelSidePanel.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include - -namespace dchat -{ - class Channel; - - class ChannelSidePanel - { - public: - static void addChannel(Channel *channel); - static void removeAllChannels(); - - static void draw(sf::RenderWindow &window); - static float getWidth(); - static float getHeight(); - }; -} diff --git a/include/ChannelTopPanel.hpp b/include/ChannelTopPanel.hpp deleted file mode 100644 index 41fe9a2..0000000 --- a/include/ChannelTopPanel.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -namespace dchat -{ - class ChannelTopPanel - { - public: - static void draw(sf::RenderWindow &window); - static float getHeight(); - }; -} diff --git a/include/Chatbar.hpp b/include/Chatbar.hpp index 10bbebd..701220a 100644 --- a/include/Chatbar.hpp +++ b/include/Chatbar.hpp @@ -1,18 +1,20 @@ #pragma once -#include "StringView.hpp" #include "Text.hpp" -#include "Cache.hpp" #include #include #include #include +#include #include #include +#include namespace dchat { - class Channel; + class Cache; + class Room; + class MessageBoard; class Chatbar { @@ -21,8 +23,8 @@ namespace dchat bool isFocused() const; - void processEvent(const sf::Event &event, Cache &cache, Channel *channel); - void draw(sf::RenderWindow &window, Cache &cache); + void processEvent(const sf::Event &event, Cache *cache, std::shared_ptr room, MessageBoard *messageBoard); + void draw(sf::RenderWindow &window, Cache *cache); static sf::Vector2f getInputPosition(sf::RenderWindow &window); static sf::Vector2f getInputSize(sf::RenderWindow &window); @@ -30,6 +32,7 @@ namespace dchat static bool addBind(const std::string &key, const std::string &value, bool updateFile = true); static bool removeBind(const std::string &key, bool updateFile = true); + static void loadBindsFromFile(); static const std::unordered_map& getBinds(); private: void processChatCommand(const StringView &cmd); diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp index 097b607..420ed72 100644 --- a/include/FileUtil.hpp +++ b/include/FileUtil.hpp @@ -1,6 +1,6 @@ #pragma once -#include "StringView.hpp" +#include #include #include diff --git a/include/Gif.hpp b/include/Gif.hpp index ebcb5d4..6edef92 100644 --- a/include/Gif.hpp +++ b/include/Gif.hpp @@ -1,52 +1,19 @@ #pragma once -#include "StringView.hpp" -#include +#include #include -#include -#include -#include -#include -extern "C" -{ -#include -} namespace dchat { - class GifLoadException : public std::runtime_error - { - public: - GifLoadException(const std::string &errMsg) : std::runtime_error(errMsg) {} - }; - - class Gif + class SfmlGif : public Gif { public: - // Throws GifLoadException on error - Gif(const boost::filesystem::path &filepath); - Gif(StringView &&fileContent); - ~Gif(); - - sf::Vector2u getSize() const; - - void setPosition(const sf::Vector2f &position); - sf::Vector2f getPosition() const; - - void setScale(const sf::Vector2f &scale); - void setColor(sf::Color color); - void draw(sf::RenderTarget &target, const sf::RenderStates &renderStates = sf::RenderStates::Default); - - static bool isDataGif(const StringView &data); - private: - void init(); - private: - gif_animation gif; - StringView fileContent; - unsigned int currentFrame; - sf::Sprite sprite; + SfmlGif(StringView fileContent); + virtual ~SfmlGif(){} + + bool createTexture() override; + void updateTexture(void *textureData) override; + sf::Texture texture; - double timeElapsedCs; - sf::Clock frameTimer; }; -} +} \ No newline at end of file diff --git a/include/ImagePreview.hpp b/include/ImagePreview.hpp index 1d20fe8..0f42465 100644 --- a/include/ImagePreview.hpp +++ b/include/ImagePreview.hpp @@ -38,6 +38,7 @@ namespace dchat sf::Vector2u calculateImageSize(sf::Vector2u windowSize) const; private: + sf::Vector2f position; sf::Sprite sprite; sf::Vector2u size; sf::Clock lastSeenTimer; diff --git a/include/Message.hpp b/include/Message.hpp index 2327a0b..0541574 100644 --- a/include/Message.hpp +++ b/include/Message.hpp @@ -1,29 +1,20 @@ #pragma once -#include "User.hpp" +#include #include "Text.hpp" -#include -#include -#include namespace dchat { + struct RoomMessage; + class Message { public: - enum class Type - { - REGULAR, - EDITED - }; - - // If timestamp is 0, then timestamp is not used - Message(User *user, const std::string &text, u64 timestampSeconds = 0, bool plainText = false); - - const User *user; + Message(std::shared_ptr roomMessage, bool plainText); + + std::shared_ptr roomMessage; Text text; - const u64 timestampSeconds; - Type type; - odhtdb::Hash id; + + bool onlineUser; }; -} +} \ No newline at end of file diff --git a/include/MessageBoard.hpp b/include/MessageBoard.hpp index 1d1f523..c1eecb0 100644 --- a/include/MessageBoard.hpp +++ b/include/MessageBoard.hpp @@ -1,9 +1,8 @@ #pragma once -#include "Message.hpp" #include "types.hpp" -#include "../include/Cache.hpp" -#include "../include/Scrollbar.hpp" +#include "Message.hpp" +#include "Scrollbar.hpp" #include #include #include @@ -11,37 +10,41 @@ #include #include #include +#include namespace dchat { - class Channel; + class Room; + struct RoomMessage; + class Cache; + class User; class MessageBoard { - friend class Channel; public: - MessageBoard(Channel *channel); + MessageBoard(std::shared_ptr room); ~MessageBoard(); - void processEvent(const sf::Event &event, Cache &cache); - void draw(sf::RenderWindow &window, Cache &cache); - - Message* getLatestMessage(); - const std::vector& getMessages() const; + void processEvent(const sf::Event &event, Cache *cache); + void draw(sf::RenderWindow &window, Cache *cache); + + bool addMessage(Message *message); + void deleteMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser); + + void addOfflineUserMessage(std::string msg, bool plainText); + void addSystemUserMessage(std::string msg, bool plainText); private: usize findPositionToInsertMessageByTimestamp(Message *message); void updateStaticContentTexture(const sf::Vector2u &newSize); - bool addMessage(Message *message, const odhtdb::Hash &id); - void deleteMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser); - void drawDefault(sf::RenderWindow &window, Cache &cache); - void drawSimple(sf::RenderWindow &window, Cache &cache); + void drawDefault(sf::RenderWindow &window, Cache *cache); + void drawSimple(sf::RenderWindow &window, Cache *cache); private: - Channel *channel; + std::shared_ptr room; bool dirty; - std::vector messages; odhtdb::MapHash messageIdMap; + std::vector messages; double scroll; double scrollSpeed; double totalHeight; @@ -54,5 +57,8 @@ namespace dchat usize visibleMessageStartIndex; usize visibleMessageEndIndex; Scrollbar scrollbar; + + std::shared_ptr offlineUser; + std::shared_ptr systemUser; }; } diff --git a/include/ResourceCache.hpp b/include/ResourceCache.hpp index 75ebd88..ab7a921 100644 --- a/include/ResourceCache.hpp +++ b/include/ResourceCache.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -24,5 +25,7 @@ namespace dchat static sf::Texture* getTexture(const std::string &filepath); static sf::Shader* getShader(const std::string &filepath, sf::Shader::Type shaderType); + + static Cache* getCache(); }; } diff --git a/include/Room.hpp b/include/Room.hpp new file mode 100644 index 0000000..bcdadc0 --- /dev/null +++ b/include/Room.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace dchat +{ + class Room; + class Rooms; + + std::shared_ptr getCurrentRoom(); + void setCurrentRoom(std::shared_ptr room); + + std::shared_ptr getRooms(); + void setRooms(std::shared_ptr rooms); +} \ No newline at end of file diff --git a/include/RoomContainer.hpp b/include/RoomContainer.hpp new file mode 100644 index 0000000..fc3e8ae --- /dev/null +++ b/include/RoomContainer.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "MessageBoard.hpp" +#include "Chatbar.hpp" +#include +#include + +namespace dchat +{ + class Room; + class Cache; + + class RoomContainer + { + public: + RoomContainer(std::shared_ptr room); + + void processEvent(const sf::Event &event, Cache *cache); + void draw(sf::RenderWindow &window, Cache *cache); + + std::shared_ptr room; + MessageBoard messageBoard; + Chatbar chatbar; + bool offlineRoom; + }; +} \ No newline at end of file diff --git a/include/RoomSidePanel.hpp b/include/RoomSidePanel.hpp new file mode 100644 index 0000000..95000ba --- /dev/null +++ b/include/RoomSidePanel.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace dchat +{ + class RoomSidePanel + { + public: + static void draw(sf::RenderWindow &window); + static float getWidth(); + static float getHeight(); + }; +} diff --git a/include/RoomTopPanel.hpp b/include/RoomTopPanel.hpp new file mode 100644 index 0000000..1787753 --- /dev/null +++ b/include/RoomTopPanel.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace dchat +{ + class RoomTopPanel + { + public: + static void draw(sf::RenderWindow &window); + static float getHeight(); + }; +} diff --git a/include/Rpc.hpp b/include/Rpc.hpp deleted file mode 100644 index c8b47e0..0000000 --- a/include/Rpc.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include "types.hpp" -#include - -namespace dchat -{ - using RpcRecvCallbackFunc = std::function; - - class Rpc - { - public: - Rpc(u16 port); - void recv(RpcRecvCallbackFunc recvCallbackFunc); - bool send(const void *data, const usize size); - private: - zmq::context_t context; - zmq::socket_t socket; - }; -} \ No newline at end of file diff --git a/include/StaticImage.hpp b/include/StaticImage.hpp new file mode 100644 index 0000000..3ede61c --- /dev/null +++ b/include/StaticImage.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include + +namespace dchat +{ + class SfmlStaticImage : public StaticImage + { + public: + SfmlStaticImage(const boost::filesystem::path &path); + virtual ~SfmlStaticImage(){} + + sf::Texture texture; + }; +} \ No newline at end of file diff --git a/include/StringUtils.hpp b/include/StringUtils.hpp deleted file mode 100644 index 6b237dd..0000000 --- a/include/StringUtils.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include - -namespace dchat -{ - static std::string stringReplaceChar(const std::string &str, const std::string &from, const std::string &to) - { - std::string result = str; - size_t pos = 0; - while((pos = result.find(from, pos)) != std::string::npos) - { - result.replace(pos, from.size(), to); - pos += to.size(); - } - return result; - } -} diff --git a/include/StringView.hpp b/include/StringView.hpp deleted file mode 100644 index d320a85..0000000 --- a/include/StringView.hpp +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once - -#include "types.hpp" -#include -#include - -namespace dchat -{ - template - class BasicStringView - { - public: - BasicStringView() : data(nullptr), size(0) - { - - } - - BasicStringView(const BasicStringView &other) : data(other.data), size(other.size) - { - - } - - BasicStringView(const CharType *_data) : data(_data), size(strlen(_data)) - { - - } - - BasicStringView(const CharType *_data, usize _size) : data(_data), size(_size) - { - - } - - BasicStringView& operator = (const BasicStringView &other) - { - data = other.data; - size = other.size; - return *this; - } - - BasicStringView(BasicStringView &&other) - { - data = other.data; - size = other.size; - - other.data = nullptr; - other.size = 0; - } - - bool equals(const BasicStringView &other) const - { - if(size != other.size) return false; - return memcmp(data, other.data, size * sizeof(CharType)) == 0; - } - - bool operator == (const BasicStringView &other) const - { - return equals(other); - } - - bool operator != (const BasicStringView &other) const - { - return !equals(other); - } - - CharType operator [] (usize index) const - { - assert(index < size); - return data[index]; - } - - // Returns -1 if substr not found. - // TODO: Make this more efficient - usize find(const BasicStringView &substr, usize offset = 0) const - { - if(substr.size == 0) - return -1; - - if(offset + substr.size > size) - return -1; - - for(usize i = offset; i < size - (substr.size - 1); ++i) - { - if(memcmp(data + i, substr.data, substr.size * sizeof(CharType)) == 0) - return i; - } - return -1; - } - - const CharType *data; - usize size; - }; - - using StringView = BasicStringView; - using StringViewUtf32 = BasicStringView; -} diff --git a/include/Suggestions.hpp b/include/Suggestions.hpp index 56f3afa..b2d19f9 100644 --- a/include/Suggestions.hpp +++ b/include/Suggestions.hpp @@ -1,18 +1,19 @@ #pragma once #include "Text.hpp" -#include "Cache.hpp" #include #include #include namespace dchat { + class Cache; + class Suggestions { public: void show(const std::vector &texts); - void draw(sf::RenderWindow &window, Cache &cache); + void draw(sf::RenderWindow &window, Cache *cache); private: std::vector> texts; }; diff --git a/include/Text.hpp b/include/Text.hpp index 24ea02a..86814a3 100644 --- a/include/Text.hpp +++ b/include/Text.hpp @@ -1,17 +1,18 @@ #pragma once -#include "StringView.hpp" -#include "Cache.hpp" #include #include #include #include #include #include +#include #include namespace dchat { + class Cache; + struct TextElement { enum class Type @@ -59,13 +60,13 @@ namespace dchat // Warning: won't update until @draw is called float getHeight() const; - void processEvent(const sf::Event &event, Cache &cache); + void processEvent(const sf::Event &event, Cache *cache); // Performs culling. @updateGeometry is called even if text is not visible if text is dirty, because updateGeometry might change the dimension of the text and make is visible. // Returns true if text was drawn on screen (if text is within window borders) - bool draw(sf::RenderTarget &target, Cache &cache); + bool draw(sf::RenderTarget &target, Cache *cache); private: - void onMouseClick(const sf::Event::MouseButtonEvent &event, Cache &cache); + void onMouseClick(const sf::Event::MouseButtonEvent &event, Cache *cache); private: enum class CaretMoveDirection : u8 { @@ -110,5 +111,6 @@ namespace dchat int caretIndex; sf::Vector2f caretPosition; sf::Clock lastSeenTimer; + sf::Vector2u renderTargetSize; }; } diff --git a/include/User.hpp b/include/User.hpp deleted file mode 100644 index 7e99c60..0000000 --- a/include/User.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -#include "types.hpp" -#include -#include - -namespace dchat -{ - class User - { - public: - enum class Type - { - OTHER, - ONLINE_REMOTE_USER, - ONLINE_LOCAL_USER, - ONLINE_DISCORD_USER, - OFFLINE, - SYSTEM - }; - - User(Type type); - virtual ~User(){} - virtual const std::string& getName() const = 0; - virtual bool isOnlineUser() const { return false; } - - virtual bool isConnected(i64 timestampUtcSec) const { return true; } - - const Type type; - std::string avatarUrl; - }; - - class OnlineUser : public User - { - public: - OnlineUser(const std::string &name, Type type); - virtual ~OnlineUser(){} - - virtual const std::string& getName() const override; - virtual const odhtdb::Signature::PublicKey& getPublicKey() const = 0; - - bool isConnected(i64 timestampUtcSec) const override; - bool isOnlineUser() const override { return true; } - - std::string name; - u32 pingTimestampSec; - }; - - class OnlineRemoteUser : public OnlineUser - { - public: - OnlineRemoteUser(const std::string &name, const odhtdb::Signature::PublicKey &publicKey); - virtual const odhtdb::Signature::PublicKey& getPublicKey() const override; - - const odhtdb::Signature::PublicKey publicKey; - }; - - class OnlineLocalUser : public OnlineUser - { - public: - OnlineLocalUser(const std::string &name, const odhtdb::Signature::KeyPair &keyPair); - virtual const odhtdb::Signature::PublicKey& getPublicKey() const override; - - const odhtdb::Signature::KeyPair keyPair; - }; - - class OnlineDiscordUser : public OnlineUser - { - public: - OnlineDiscordUser(const std::string &discordUserName, u64 discordUserId, User *bridgeOwner); - virtual const odhtdb::Signature::PublicKey& getPublicKey() const override; - - u64 discordUserId; - User *bridgeOwner; - }; - - class OfflineUser : public User - { - public: - OfflineUser(const std::string &name); - virtual const std::string& getName() const override; - - const std::string name; - }; - - class SystemUser : public User - { - public: - SystemUser(); - virtual const std::string& getName() const override; - }; -} diff --git a/include/UsersSidePanel.hpp b/include/UsersSidePanel.hpp index 9e48ee6..b76eb5e 100644 --- a/include/UsersSidePanel.hpp +++ b/include/UsersSidePanel.hpp @@ -1,16 +1,15 @@ #pragma once -#include "Cache.hpp" #include namespace dchat { - class Channel; + class Cache; class UsersSidePanel { public: - static void draw(sf::RenderWindow &window, Cache &cache); + static void draw(sf::RenderWindow &window, Cache *cache); static float getWidth(); }; } diff --git a/include/WebPagePreview.hpp b/include/WebPagePreview.hpp index 6f6c0f0..fde653d 100644 --- a/include/WebPagePreview.hpp +++ b/include/WebPagePreview.hpp @@ -1,16 +1,17 @@ #pragma once -#include #include "Text.hpp" +#include +#include namespace dchat { - class WebPagePreview + class SfmlWebPagePreview : public WebPagePreview { public: - WebPagePreview(const sf::String &title, const sf::String &description); - + SfmlWebPagePreview(const std::string &title, const std::string &description); + Text title; Text description; }; -} +} \ No newline at end of file -- cgit v1.2.3