From 57687e1b99972dccd0d2d449e7213ff2da126597 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 13 Feb 2018 09:57:59 +0100 Subject: [PATCH] Handle fetching a participant device's state from database. --- src/db/main-db.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 5db7cccb3..08a768615 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -2421,13 +2421,19 @@ list> MainDb::getChatRooms () const { // Fetch devices. { const long long &participantId = d->resolveId(row, 0); - static const string query = "SELECT sip_address.value FROM chat_room_participant_device, sip_address" + static const string query = "SELECT sip_address.value, state FROM chat_room_participant_device, sip_address" " WHERE chat_room_participant_id = :participantId" " AND participant_device_sip_address_id = sip_address.id"; soci::rowset rows = (session->prepare << query, soci::use(participantId)); - for (const auto &row : rows) - dParticipant->addDevice(IdentityAddress(row.get(0))); + for (const auto &row : rows) { + shared_ptr device = dParticipant->addDevice(IdentityAddress(row.get(0))); + ParticipantDevice::State state = static_cast(getBackend() == Backend::Mysql + ? row.get(1, 0) + : static_cast(row.get(1, 0)) + ); + device->setState(state); + } } if (participant->getAddress() == chatRoomId.getLocalAddress().getAddressWithoutGruu())