From b4c7661a8eadd2cdbc4cee00e2549999868713f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 26 Oct 2021 12:15:17 -0400
Subject: [PATCH] calls: follow API changes (add accountId for calls and
 conferences)

Change-Id: I54f0c6c144bcf6774883f58ec3bc4fac4bc4ef49
---
 src/avadapter.cpp    | 54 ++++++++++++++++++++++++--------------------
 src/calladapter.cpp  |  3 ++-
 src/lrcinstance.cpp  |  6 -----
 src/lrcinstance.h    |  1 -
 src/videodevices.cpp | 10 ++++----
 5 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/src/avadapter.cpp b/src/avadapter.cpp
index 541216c33..9568fdba0 100644
--- a/src/avadapter.cpp
+++ b/src/avadapter.cpp
@@ -88,11 +88,12 @@ AvAdapter::shareEntireScreen(int screenNumber)
         return;
     QRect rect = screen->geometry();
 
-    auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(),
-                                                       rect.x(),
-                                                       rect.y(),
-                                                       rect.width() * screen->devicePixelRatio(),
-                                                       rect.height() * screen->devicePixelRatio());
+    auto resource = lrcInstance_->getCurrentCallModel()
+                        ->getDisplay(getScreenNumber(),
+                                     rect.x(),
+                                     rect.y(),
+                                     rect.width() * screen->devicePixelRatio(),
+                                     rect.height() * screen->devicePixelRatio());
     auto callId = lrcInstance_->getCurrentCallId();
     lrcInstance_->getCurrentCallModel()
         ->requestMediaChange(callId,
@@ -100,7 +101,8 @@ AvAdapter::shareEntireScreen(int screenNumber)
                              resource,
                              lrc::api::NewCallModel::MediaRequestType::SCREENSHARING,
                              false);
-    set_currentRenderingDeviceType(lrcInstance_->avModel().getCurrentRenderedDevice(callId).type);
+    set_currentRenderingDeviceType(
+        lrcInstance_->getCurrentCallModel()->getCurrentRenderedDevice(callId).type);
 }
 
 void
@@ -108,11 +110,11 @@ AvAdapter::shareAllScreens()
 {
     const auto arrangementRect = getAllScreensBoundingRect();
 
-    auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(),
-                                                       arrangementRect.x(),
-                                                       arrangementRect.y(),
-                                                       arrangementRect.width(),
-                                                       arrangementRect.height());
+    auto resource = lrcInstance_->getCurrentCallModel()->getDisplay(getScreenNumber(),
+                                                                    arrangementRect.x(),
+                                                                    arrangementRect.y(),
+                                                                    arrangementRect.width(),
+                                                                    arrangementRect.height());
     auto callId = lrcInstance_->getCurrentCallId();
     lrcInstance_->getCurrentCallModel()
         ->requestMediaChange(callId,
@@ -120,7 +122,8 @@ AvAdapter::shareAllScreens()
                              resource,
                              lrc::api::NewCallModel::MediaRequestType::SCREENSHARING,
                              false);
-    set_currentRenderingDeviceType(lrcInstance_->avModel().getCurrentRenderedDevice(callId).type);
+    set_currentRenderingDeviceType(
+        lrcInstance_->getCurrentCallModel()->getCurrentRenderedDevice(callId).type);
 }
 
 void
@@ -189,7 +192,7 @@ AvAdapter::shareFile(const QString& filePath)
                                  lrc::api::NewCallModel::MediaRequestType::FILESHARING,
                                  false);
         set_currentRenderingDeviceType(
-            lrcInstance_->avModel().getCurrentRenderedDevice(callId).type);
+            lrcInstance_->getCurrentCallModel()->getCurrentRenderedDevice(callId).type);
     }
 }
 
@@ -203,11 +206,11 @@ AvAdapter::shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned heig
     QTimer::singleShot(100, [=]() mutable {
         x = y = width = height = 0;
         xrectsel(&x, &y, &width, &height);
-        auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(),
-                                                           x,
-                                                           y,
-                                                           width < 128 ? 128 : width,
-                                                           height < 128 ? 128 : height);
+        auto resource = lrcInstance_->getCurrentCallModel()->getDisplay(getScreenNumber(),
+                                                                        x,
+                                                                        y,
+                                                                        width < 128 ? 128 : width,
+                                                                        height < 128 ? 128 : height);
         auto callId = lrcInstance_->getCurrentCallId();
         lrcInstance_->getCurrentCallModel()
             ->requestMediaChange(callId,
@@ -216,14 +219,14 @@ AvAdapter::shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned heig
                                  lrc::api::NewCallModel::MediaRequestType::SCREENSHARING,
                                  false);
         set_currentRenderingDeviceType(
-            lrcInstance_->avModel().getCurrentRenderedDevice(callId).type);
+            lrcInstance_->getCurrentCallModel()->getCurrentRenderedDevice(callId).type);
     });
 #else
-    auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(),
-                                                       x,
-                                                       y,
-                                                       width < 128 ? 128 : width,
-                                                       height < 128 ? 128 : height);
+    auto resource = lrcInstance_->getCurrentCallModel()->getDisplay(getScreenNumber(),
+                                                                    x,
+                                                                    y,
+                                                                    width < 128 ? 128 : width,
+                                                                    height < 128 ? 128 : height);
     auto callId = lrcInstance_->getCurrentCallId();
     lrcInstance_->getCurrentCallModel()
         ->requestMediaChange(callId,
@@ -231,7 +234,8 @@ AvAdapter::shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned heig
                              resource,
                              lrc::api::NewCallModel::MediaRequestType::SCREENSHARING,
                              false);
-    set_currentRenderingDeviceType(lrcInstance_->avModel().getCurrentRenderedDevice(callId).type);
+    set_currentRenderingDeviceType(
+        lrcInstance_->getCurrentCallModel()->getCurrentRenderedDevice(callId).type);
 #endif
 }
 
diff --git a/src/calladapter.cpp b/src/calladapter.cpp
index 153b7b40d..23765f800 100644
--- a/src/calladapter.cpp
+++ b/src/calladapter.cpp
@@ -682,7 +682,8 @@ CallAdapter::saveConferenceSubcalls()
     const auto& currentConvId = lrcInstance_->get_selectedConvUid();
     const auto& convInfo = lrcInstance_->getConversationFromConvUid(currentConvId);
     if (!convInfo.confId.isEmpty()) {
-        currentConfSubcalls_ = lrcInstance_->getConferenceSubcalls(convInfo.confId);
+        auto* callModel = lrcInstance_->getAccountInfo(accountId_).callModel.get();
+        currentConfSubcalls_ = callModel->getConferenceSubcalls(convInfo.confId);
     }
 }
 
diff --git a/src/lrcinstance.cpp b/src/lrcinstance.cpp
index cd947070c..2e42534a6 100644
--- a/src/lrcinstance.cpp
+++ b/src/lrcinstance.cpp
@@ -69,12 +69,6 @@ LRCInstance::LRCInstance(migrateCallback willMigrateCb,
     }
 };
 
-VectorString
-LRCInstance::getConferenceSubcalls(const QString& callId)
-{
-    return lrc_->getConferenceSubcalls(callId);
-}
-
 RenderManager*
 LRCInstance::renderer()
 {
diff --git a/src/lrcinstance.h b/src/lrcinstance.h
index 3433710a9..266b4bde6 100644
--- a/src/lrcinstance.h
+++ b/src/lrcinstance.h
@@ -122,7 +122,6 @@ public:
     void monitor(bool continous);
 
     bool hasActiveCall(bool withVideo = false);
-    VectorString getConferenceSubcalls(const QString& callId);
 
     QString get_selectedConvUid();
 
diff --git a/src/videodevices.cpp b/src/videodevices.cpp
index 9cdccbed0..3783bcff6 100644
--- a/src/videodevices.cpp
+++ b/src/videodevices.cpp
@@ -273,7 +273,7 @@ VideoDevices::setDefaultDevice(int index, bool useSourceModel)
     lrcInstance_->avModel().setDefaultDevice(deviceId);
 
     if (!callId.isEmpty())
-        lrcInstance_->avModel().switchInputTo(deviceId, callId);
+        lrcInstance_->getCurrentCallModel()->switchInputTo(deviceId, callId);
 
     updateData();
 }
@@ -435,6 +435,7 @@ void
 VideoDevices::onVideoDeviceEvent()
 {
     auto& avModel = lrcInstance_->avModel();
+    auto* callModel = lrcInstance_->getCurrentCallModel();
     auto defaultDevice = avModel.getDefaultDevice();
     QString callId = lrcInstance_->getCurrentCallId();
 
@@ -455,11 +456,12 @@ VideoDevices::onVideoDeviceEvent()
 
     auto cb = [this, currentDeviceListSize, deviceEvent, defaultDevice, callId] {
         auto& avModel = lrcInstance_->avModel();
+        auto* callModel = lrcInstance_->getCurrentCallModel();
         if (currentDeviceListSize == 0) {
-            avModel.switchInputTo({}, callId);
+            callModel->switchInputTo({}, callId);
             avModel.stopPreview(this->getDefaultDevice());
         } else if (deviceEvent == DeviceEvent::Removed) {
-            avModel.switchInputTo(defaultDevice, callId);
+            callModel->switchInputTo(defaultDevice, callId);
         }
 
         updateData();
@@ -475,7 +477,7 @@ VideoDevices::onVideoDeviceEvent()
         if (callId.isEmpty()) {
             Q_EMIT deviceAvailable();
         } else {
-            avModel.switchInputTo(defaultDevice, callId);
+            callModel->switchInputTo(defaultDevice, callId);
         }
 
         Q_EMIT deviceListChanged(currentDeviceListSize);
-- 
GitLab