From c80794a4a87bb9a0d0d224488202d7611bf08dcc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anthony=20L=C3=A9onard?=
 <anthony.leonard@savoirfairelinux.com>
Date: Mon, 6 Nov 2017 15:00:46 -0500
Subject: [PATCH] newcallmodel: remove unneeded argument
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

A boolean argument in toggleMedia() was passed specifying if the
chosen media was to be muted or not. This is not consistent with the
other toggle*() methods used to manage calls.

Moreover, it is not needed at all as we can retrieve the current state
of a media and toggle it from LRC itself, thus removing the need to do
it on each client.

Change-Id: I53528d925c8336b92afc47367adef971d11e9a25
Reviewed-by: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
---
 src/api/newcallmodel.h |  3 +--
 src/newcallmodel.cpp   | 10 +++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/api/newcallmodel.h b/src/api/newcallmodel.h
index f2a6d626..ff4bef18 100644
--- a/src/api/newcallmodel.h
+++ b/src/api/newcallmodel.h
@@ -132,9 +132,8 @@ public:
      * Toggle a media on a call
      * @param callId
      * @param media {AUDIO, VIDEO}
-     * @param flag is muted
      */
-    void toggleMedia(const std::string& callId, const NewCallModel::Media media, bool flag) const;
+    void toggleMedia(const std::string& callId, const NewCallModel::Media media) const;
     /**
      * Not implemented yet
      */
diff --git a/src/newcallmodel.cpp b/src/newcallmodel.cpp
index 506b3191..8d9787b8 100644
--- a/src/newcallmodel.cpp
+++ b/src/newcallmodel.cpp
@@ -230,7 +230,7 @@ NewCallModel::togglePause(const std::string& callId) const
 }
 
 void
-NewCallModel::toggleMedia(const std::string& callId, const NewCallModel::Media media, bool flag) const
+NewCallModel::toggleMedia(const std::string& callId, const NewCallModel::Media media) const
 {
     auto it = pimpl_->calls.find(callId);
     if (it == pimpl_->calls.end()) return;
@@ -240,15 +240,15 @@ NewCallModel::toggleMedia(const std::string& callId, const NewCallModel::Media m
     case NewCallModel::Media::AUDIO:
         CallManager::instance().muteLocalMedia(callId.c_str(),
                                                DRing::Media::Details::MEDIA_TYPE_AUDIO,
-                                               flag);
-        call->audioMuted = flag;
+                                               !call->audioMuted);
+        call->audioMuted = !call->audioMuted;
         break;
 
     case NewCallModel::Media::VIDEO:
         CallManager::instance().muteLocalMedia(callId.c_str(),
                                                DRing::Media::Details::MEDIA_TYPE_VIDEO,
-                                               flag);
-        call->videoMuted = flag;
+                                               !call->videoMuted);
+        call->videoMuted = !call->videoMuted;
         break;
 
     case NewCallModel::Media::NONE:
-- 
GitLab