aboutsummaryrefslogtreecommitdiff
path: root/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-09-19 18:08:57 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-09-19 18:08:57 +0900
commit35ef29ead1da906e4978dcd908e7c1513ac9bfd3 (patch)
tree0e784f13ec837b9dd6f40e07423e0a3eb8012256 /connection.cpp
parentc5c26ff4a09eecaa6d8e1507087566ccf0fd96b4 (diff)
parent0b11b06379fe668063ea5658a261f53f1dcf117a (diff)
downloadlibquotient-35ef29ead1da906e4978dcd908e7c1513ac9bfd3.tar.gz
libquotient-35ef29ead1da906e4978dcd908e7c1513ac9bfd3.zip
Merge branch 'master' into cache-state-to-json
Diffstat (limited to 'connection.cpp')
-rw-r--r--connection.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/connection.cpp b/connection.cpp
index 785e0e43..efc40fe9 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -220,7 +220,10 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias)
void Connection::leaveRoom(Room* room)
{
- callApi<LeaveRoomJob>(room->id());
+ auto job = callApi<LeaveRoomJob>(room->id());
+ connect( job, &BaseJob::success, [=] () {
+ emit leftRoom(room);
+ });
}
RoomMessagesJob* Connection::getMessages(Room* room, const QString& from) const
@@ -248,7 +251,7 @@ User* Connection::user(const QString& userId)
{
if( d->userMap.contains(userId) )
return d->userMap.value(userId);
- User* user = createUser(userId);
+ auto* user = createUser(this, userId);
d->userMap.insert(userId, user);
return user;
}
@@ -307,7 +310,7 @@ Room* Connection::provideRoom(const QString& id)
return d->roomMap.value(id);
// Not yet in the map, create a new one.
- Room* room = createRoom(id);
+ auto* room = createRoom(this, id);
if (room)
{
d->roomMap.insert( id, room );
@@ -319,15 +322,11 @@ Room* Connection::provideRoom(const QString& id)
return room;
}
-User* Connection::createUser(const QString& userId)
-{
- return new User(userId, this);
-}
+std::function<Room*(Connection*, const QString&)> Connection::createRoom =
+ [](Connection* c, const QString& id) { return new Room(c, id); };
-Room* Connection::createRoom(const QString& roomId)
-{
- return new Room(this, roomId);
-}
+std::function<User*(Connection*, const QString&)> Connection::createUser =
+ [](Connection* c, const QString& id) { return new User(id, c); };
QByteArray Connection::generateTxnId()
{