aboutsummaryrefslogtreecommitdiff
path: root/include/dchat
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-01-12 20:38:50 +0100
committerdec05eba <dec05eba@protonmail.com>2019-01-12 20:38:51 +0100
commit156291b2c15895c41bd3d096d03a88433de49084 (patch)
treeafc3700c2bcc2712656a2dc36c70d56403e9cd38 /include/dchat
parentce82dfde0925ade8a589a0b88ef7183ebcf3430f (diff)
Fix crash when sending message with no previous message
Diffstat (limited to 'include/dchat')
-rw-r--r--include/dchat/Room.hpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/include/dchat/Room.hpp b/include/dchat/Room.hpp
index 9eef4de..6980bfc 100644
--- a/include/dchat/Room.hpp
+++ b/include/dchat/Room.hpp
@@ -26,6 +26,7 @@ namespace dchat
class Room
{
DISABLE_COPY(Room)
+ friend class Rooms;
public:
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
@@ -47,21 +48,26 @@ namespace dchat
std::shared_ptr<odhtdb::Hash> id;
std::shared_ptr<odhtdb::OwnedByteArray> encryptionKey;
std::string name;
- odhtdb::Signature::MapPublicKey<std::shared_ptr<User>> userByPublicKey;
- std::vector<std::shared_ptr<Group>> groups;
- std::vector<RoomMessage> messages;
std::shared_ptr<User> localUser;
- // Used for local users
- odhtdb::Signature::MapPublicKey<std::shared_ptr<odhtdb::Signature::KeyPair>> publicKeyToKeyPairMap;
std::string inviteKey;
void *userdata;
+
+ // TODO: Move to private when we have proper support for groups
+ std::vector<std::shared_ptr<Group>> groups;
+ private:
+ odhtdb::Signature::MapPublicKey<std::shared_ptr<User>> userByPublicKey;
+ // Used for local users
+ odhtdb::Signature::MapPublicKey<std::shared_ptr<odhtdb::Signature::KeyPair>> publicKeyToKeyPairMap;
+
+ std::vector<std::shared_ptr<RoomMessage>> messages;
};
struct RoomAddMessageRequest
{
std::shared_ptr<Room> room;
bool loadedFromCache;
- RoomMessage message;
+ std::shared_ptr<RoomMessage> message;
+ std::shared_ptr<RoomMessage> prevMessage;
};
struct UserChangeNicknameRequest
@@ -134,7 +140,8 @@ namespace dchat
friend Room;
DISABLE_COPY(Rooms)
public:
- // @callbackFuncs.connectCallbackFunc can't be null
+ // @callbackFuncs.connectCallbackFunc can't be null.
+ // @address is used in another thread so it may need to live beyond the scope which Rooms::connect is called from
static void connect(const char *address, u16 port, RoomCallbackFuncs callbackFuncs);
// Throws on failure
void loginUser(const std::string &username, const std::string &password);
@@ -164,4 +171,4 @@ namespace dchat
odhtdb::MapHash<std::shared_ptr<odhtdb::Signature::KeyPair>> waitingToJoinRoom;
std::recursive_mutex waitingToJoinRoomMutex;
};
-} \ No newline at end of file
+}