From c47ec545d87e622aa950e653e4f91721d79bb049 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 21 May 2018 13:58:47 +0200 Subject: Add command to change avatar and channel name Fix bug where application crashes when deleting message, improve url parsing for messages --- include/Channel.hpp | 8 +++++++- include/Command.hpp | 3 +++ include/Message.hpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Channel.hpp b/include/Channel.hpp index 26b5286..5f5699e 100644 --- a/include/Channel.hpp +++ b/include/Channel.hpp @@ -26,7 +26,9 @@ namespace dchat ADD_MESSAGE, EDIT_MESSAGE, DELETE_MESSAGE, - NICKNAME_CHANGE + NICKNAME_CHANGE, + CHANGE_AVATAR, + CHANGE_CHANNEL_NAME }; class Channel @@ -49,6 +51,7 @@ namespace dchat // 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 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); @@ -57,6 +60,9 @@ namespace dchat 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); void processEvent(const sf::Event &event, Cache &cache); void draw(sf::RenderWindow &window, Cache &cache); diff --git a/include/Command.hpp b/include/Command.hpp index fe8a947..fe08664 100644 --- a/include/Command.hpp +++ b/include/Command.hpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace dchat { @@ -13,5 +14,7 @@ namespace dchat public: static bool add(const std::string &cmd, CommandHandlerFunc handlerFunc); static bool call(const std::string &cmd, const std::vector &args); + + static const std::unordered_map& getCommands(); }; } diff --git a/include/Message.hpp b/include/Message.hpp index a2d67e8..2327a0b 100644 --- a/include/Message.hpp +++ b/include/Message.hpp @@ -18,7 +18,7 @@ namespace dchat }; // If timestamp is 0, then timestamp is not used - Message(User *user, const std::string &text, u64 timestampSeconds = 0); + Message(User *user, const std::string &text, u64 timestampSeconds = 0, bool plainText = false); const User *user; Text text; -- cgit v1.2.3