diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dchat/Process.hpp | 8 | ||||
-rw-r--r-- | include/dchat/Room.hpp | 18 |
2 files changed, 20 insertions, 6 deletions
diff --git a/include/dchat/Process.hpp b/include/dchat/Process.hpp new file mode 100644 index 0000000..18aa2d9 --- /dev/null +++ b/include/dchat/Process.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include <string> + +namespace dchat +{ + std::string escapeCommand(const std::string &cmd); +}
\ No newline at end of file diff --git a/include/dchat/Room.hpp b/include/dchat/Room.hpp index 56b60e5..6681cdc 100644 --- a/include/dchat/Room.hpp +++ b/include/dchat/Room.hpp @@ -31,16 +31,16 @@ namespace dchat Room(Rooms *rooms, std::shared_ptr<odhtdb::Hash> id); // Throws exception on failure if we are not allowed to add the user to the group void addUser(const odhtdb::Signature::PublicKey &userPublicKey, std::shared_ptr<Group> group); - // Returns null if the user already exists in the room - std::shared_ptr<User> addUserLocally(const odhtdb::Signature::PublicKey &userPublicKey, std::shared_ptr<Group> group); - // Returns null if the group already exists in the room - std::shared_ptr<Group> addGroupLocally(const odhtdb::DataView groupId); + // Returns null if user doesn't exist in room std::shared_ptr<User> getUserByPublicKey(const odhtdb::Signature::PublicKey &userPublicKey); + // Returns null if group doesn't exist in room std::shared_ptr<Group> getGroupById(const odhtdb::DataView groupId); + void setAvatarUrl(const std::string &url); - void setNickname(const std::string &nickname); + void setUserNickname(const std::string &nickname); + bool setName(const std::string &name); void publishMessage(const std::string &msg); const odhtdb::Signature::MapPublicKey<std::shared_ptr<User>>& getUsers() const { return userByPublicKey; } @@ -57,6 +57,10 @@ namespace dchat // TODO: Move to private when we have proper support for groups std::vector<std::shared_ptr<Group>> groups; private: + // Returns null if the user already exists in the room + std::shared_ptr<User> addUserLocally(const odhtdb::Signature::PublicKey &userPublicKey, std::shared_ptr<Group> group); + // Returns null if the group already exists in the room + std::shared_ptr<Group> addGroupLocally(const odhtdb::DataView groupId); void setLocalUser(std::shared_ptr<User> user, std::shared_ptr<odhtdb::Signature::KeyPair> keyPair); private: odhtdb::Signature::MapPublicKey<std::shared_ptr<User>> userByPublicKey; @@ -116,6 +120,7 @@ namespace dchat uint32_t timestampSeconds; bool loadedFromCache; bool isLocalUser; + bool waitedToJoin; }; // if connection failed then @rooms is null and errMsg contains the error @@ -153,7 +158,8 @@ namespace dchat void registerUser(const std::string &username, const std::string &password); // Throws on failure std::shared_ptr<Room> createRoom(const std::string &name); - void requestJoinRoom(const std::string &inviteKey, const std::string &message); + // Throws on failure, returns true on success, returns false on expected failures (such as already being a member of the room) + bool requestJoinRoom(const std::string &inviteKey, const std::string &message); std::shared_ptr<odhtdb::Database> database; |