diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dchat/Room.hpp | 24 |
1 files changed, 20 insertions, 4 deletions
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<odhtdb::Database> database, std::shared_ptr<odhtdb::Hash> id, std::shared_ptr<odhtdb::OwnedByteArray> encryptionKey); + Room(Rooms *rooms, std::shared_ptr<odhtdb::Hash> id, std::shared_ptr<odhtdb::OwnedByteArray> encryptionKey); std::shared_ptr<User> addUser(const odhtdb::Signature::PublicKey &userPublicKey, const odhtdb::DataView groupId); // Returns null if user doesn't exist in room std::shared_ptr<User> getUserByPublicKey(const odhtdb::Signature::PublicKey &userPublicKey); void publishMessage(const std::string &msg); - std::shared_ptr<odhtdb::Database> database; + Rooms *rooms; std::shared_ptr<odhtdb::Hash> id; std::shared_ptr<odhtdb::OwnedByteArray> encryptionKey; std::string name; @@ -42,8 +44,6 @@ namespace dchat void *userdata; }; - class Rooms; - struct RoomAddMessageRequest { std::shared_ptr<Room> room; @@ -60,12 +60,22 @@ namespace dchat std::string newNickname; }; + struct RoomChangeNameRequest + { + std::shared_ptr<Room> room; + std::shared_ptr<User> 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<void(std::shared_ptr<Rooms> rooms, const char *errMsg)>; using CreateRoomCallbackFunc = std::function<void(std::shared_ptr<Room> room)>; using RoomAddUserCallbackFunc = std::function<void(std::shared_ptr<Room> room, std::shared_ptr<User> user)>; using RoomAddMessageCallbackFunc = std::function<void(const RoomAddMessageRequest &request)>; using UserChangeNicknameCallbackFunc = std::function<void(const UserChangeNicknameRequest &request)>; + using ChangeRoomNameCallbackFunc = std::function<void(const RoomChangeNameRequest &request)>; 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<odhtdb::Database> database; private: @@ -98,5 +111,8 @@ namespace dchat bool loggedIn; odhtdb::MapHash<std::shared_ptr<odhtdb::Signature::KeyPair>> roomLocalUser; odhtdb::MapHash<std::shared_ptr<odhtdb::OwnedByteArray>> roomEncryptionKey; + + std::string currentUsername; + std::string currentUserPassword; }; }
\ No newline at end of file |