aboutsummaryrefslogtreecommitdiff
path: root/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-03-26 11:45:46 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-03-26 11:45:46 +0900
commite9cdf6c887b80210dcb6d754c1db82d3fad2ec06 (patch)
tree775862ad49bb76d0db51c8093f8a7f983809feeb /connection.cpp
parente7e9330d665c1d8d2391707d27019a7f454cbcdf (diff)
downloadlibquotient-e9cdf6c887b80210dcb6d754c1db82d3fad2ec06.tar.gz
libquotient-e9cdf6c887b80210dcb6d754c1db82d3fad2ec06.zip
Connection::room() and Connection::invitation()
Diffstat (limited to 'connection.cpp')
-rw-r--r--connection.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/connection.cpp b/connection.cpp
index fb946392..df9fd35f 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -525,6 +525,29 @@ QUrl Connection::homeserver() const
return d->data->baseUrl();
}
+Room* Connection::room(const QString& roomId, JoinStates states) const
+{
+ Room* room = d->roomMap.value({roomId, false}, nullptr);
+ if (states.testFlag(JoinState::Join) &&
+ room && room->joinState() == JoinState::Join)
+ return room;
+
+ if (states.testFlag(JoinState::Invite))
+ if (Room* invRoom = invitation(roomId))
+ return invRoom;
+
+ if (states.testFlag(JoinState::Leave) &&
+ room && room->joinState() == JoinState::Leave)
+ return room;
+
+ return nullptr;
+}
+
+Room* Connection::invitation(const QString& roomId) const
+{
+ return d->roomMap.value({roomId, true}, nullptr);
+}
+
User* Connection::user(const QString& userId)
{
if( d->userMap.contains(userId) )