From fe99723d0a6374ee20c52b0f96c45452026da519 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 Nov 2018 01:09:27 +0100 Subject: Add room change event, create room func --- include/dchat/Room.hpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'include/dchat/Room.hpp') diff --git a/include/dchat/Room.hpp b/include/dchat/Room.hpp index 4422a6f..4938aea 100644 --- a/include/dchat/Room.hpp +++ b/include/dchat/Room.hpp @@ -20,17 +20,19 @@ namespace dchat std::string text; }; + class Rooms; + class Room { DISABLE_COPY(Room) public: - Room(std::shared_ptr database, std::shared_ptr id, std::shared_ptr encryptionKey); + Room(Rooms *rooms, std::shared_ptr id, std::shared_ptr encryptionKey); std::shared_ptr addUser(const odhtdb::Signature::PublicKey &userPublicKey, const odhtdb::DataView groupId); // Returns null if user doesn't exist in room std::shared_ptr getUserByPublicKey(const odhtdb::Signature::PublicKey &userPublicKey); void publishMessage(const std::string &msg); - std::shared_ptr database; + Rooms *rooms; std::shared_ptr id; std::shared_ptr encryptionKey; std::string name; @@ -42,8 +44,6 @@ namespace dchat void *userdata; }; - class Rooms; - struct RoomAddMessageRequest { std::shared_ptr room; @@ -60,12 +60,22 @@ namespace dchat std::string newNickname; }; + struct RoomChangeNameRequest + { + std::shared_ptr room; + std::shared_ptr user; + uint32_t timestampSeconds; + bool loadedFromCache; + std::string newName; + }; + // if connection failed then @rooms is null and errMsg contains the error using ConnectBoostrapNodeCallbackFunc = std::function rooms, const char *errMsg)>; using CreateRoomCallbackFunc = std::function room)>; using RoomAddUserCallbackFunc = std::function room, std::shared_ptr user)>; using RoomAddMessageCallbackFunc = std::function; using UserChangeNicknameCallbackFunc = std::function; + using ChangeRoomNameCallbackFunc = std::function; struct RoomCallbackFuncs { ConnectBoostrapNodeCallbackFunc connectCallbackFunc; @@ -73,6 +83,7 @@ namespace dchat RoomAddUserCallbackFunc addUserCallbackFunc; RoomAddMessageCallbackFunc addMessageCallbackFunc; UserChangeNicknameCallbackFunc userChangeNicknameCallbackFunc; + ChangeRoomNameCallbackFunc changeRoomNameCallbackFunc; }; class Rooms @@ -85,6 +96,8 @@ namespace dchat void loginUser(const std::string &username, const std::string &password); // Throws on failure void registerUser(const std::string &username, const std::string &password); + // Throws on failure + void createRoom(const std::string &name); std::shared_ptr database; private: @@ -98,5 +111,8 @@ namespace dchat bool loggedIn; odhtdb::MapHash> roomLocalUser; odhtdb::MapHash> roomEncryptionKey; + + std::string currentUsername; + std::string currentUserPassword; }; } \ No newline at end of file -- cgit v1.2.3