mainview: get call state from API's enumeration

In order to make it work with the translations, call status is no longer passed as a string but as an integer (from enum lrc::api::call::Status).

Gitlab: #10
Change-Id: If8d8b7093fbf82e9b7732e6991eec647ad0d50b7
diff --git a/src/calladapter.cpp b/src/calladapter.cpp
index c4badc9..0ead73b 100644
--- a/src/calladapter.cpp
+++ b/src/calladapter.cpp
@@ -176,7 +176,7 @@
         }
     }
 
-    emit callStatusChanged(lrc::api::call::to_string(call.status), accountId, convInfo.uid);
+    emit callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid);
 
     emit updateConversationSmartList();
 }
@@ -342,9 +342,7 @@
              */
             const auto convInfo = LRCInstance::getConversationFromCallId(callId);
             if (!convInfo.uid.isEmpty()) {
-                emit callStatusChanged(lrc::api::call::to_string(call.status),
-                                       accountId,
-                                       convInfo.uid);
+                emit callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid);
             }
 
             switch (call.status) {
diff --git a/src/calladapter.h b/src/calladapter.h
index fbf5ffc..bd7871d 100644
--- a/src/calladapter.h
+++ b/src/calladapter.h
@@ -56,7 +56,7 @@
     Q_INVOKABLE void minimizeParticipant();
     Q_INVOKABLE void hangUpThisCall();
     Q_INVOKABLE bool isCurrentMaster() const;
-    Q_INVOKABLE int getCurrentLayoutType() const;
+    Q_INVOKABLE int  getCurrentLayoutType() const;
     Q_INVOKABLE void holdThisCallToggle();
     Q_INVOKABLE void muteThisCallToggle();
     Q_INVOKABLE void recordThisCallToggle();
@@ -72,7 +72,7 @@
     void showCallStack(const QString& accountId, const QString& convUid, bool forceReset = false);
     void closeCallStack(const QString& accountId, const QString& convUid);
     void closePotentialIncomingCallPageWindow(const QString& accountId, const QString& convUid);
-    void callStatusChanged(const QString& status, const QString& accountId, const QString& convUid);
+    void callStatusChanged(int index, const QString& accountId, const QString& convUid);
     void updateConversationSmartList();
     void updateParticipantsInfos(const QVariantList& infos,
                                  const QString& accountId,
@@ -84,7 +84,7 @@
     /*
      * For Call Overlay
      */
-    void updateTimeText(const QString& time);
+    void updateTimeText(const QString &time);
     void showOnHoldLabel(bool isPaused);
     void updateOverlay(bool isPaused,
                        bool isAudioOnly,
diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml
index 5b98007..1625b43 100644
--- a/src/mainview/MainView.qml
+++ b/src/mainview/MainView.qml
@@ -434,7 +434,7 @@
             callStackView.updateCorrspondingUI()
 
             if (callStackViewShouldShow) {
-                if (callStateStr == "Talking" || callStateStr == "Hold") {
+                if (callState === Call.Status.IN_PROGRESS || callState === Call.Status.PAUSED) {
                     ClientWrapper.utilsAdaptor.setCurrentCall(
                                 ClientWrapper.utilsAdaptor.getCurrAccId(),
                                 currentUID)
diff --git a/src/mainview/components/CallStackView.qml b/src/mainview/components/CallStackView.qml
index 1f46174..c4901c6 100644
--- a/src/mainview/components/CallStackView.qml
+++ b/src/mainview/components/CallStackView.qml
@@ -93,7 +93,7 @@
             callStackMainView.pop(itemToFind, StackView.Immediate)
         }
         if (currentCallStatus)
-            outgoingCallPage.callStatusPresentation = currentCallStatus
+            outgoingCallPage.callStatus = currentCallStatus
     }
 
     function showVideoCallPage(callId) {
@@ -158,7 +158,7 @@
 
         function onCallStatusChanged(status, accountId, convUid) {
             if (responsibleConvUid === convUid && responsibleAccountId === accountId) {
-                outgoingCallPage.callStatusPresentation = status
+                outgoingCallPage.callStatus = status
             }
         }
 
diff --git a/src/mainview/components/ConversationSmartListView.qml b/src/mainview/components/ConversationSmartListView.qml
index eb7cd0d..65177c1 100644
--- a/src/mainview/components/ConversationSmartListView.qml
+++ b/src/mainview/components/ConversationSmartListView.qml
@@ -24,7 +24,7 @@
 ListView {
     id: conversationSmartListView
 
-    signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr)
+    signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, int callState)
     signal needToSelectItems(string conversationUid)
     signal needToDeselectItems
     signal needToBackToWelcomePage
diff --git a/src/mainview/components/ConversationSmartListViewItemDelegate.qml b/src/mainview/components/ConversationSmartListViewItemDelegate.qml
index 74d07db..3538200 100644
--- a/src/mainview/components/ConversationSmartListViewItemDelegate.qml
+++ b/src/mainview/components/ConversationSmartListViewItemDelegate.qml
@@ -65,7 +65,7 @@
                 conversationSmartListView.needToAccessMessageWebView(
                             DisplayID == DisplayName ? "" : DisplayID,
                             DisplayName, UID, CallStackViewShouldShow,
-                            IsAudioOnly, CallStateStr)
+                            IsAudioOnly, CallState)
             }
         }
     }
@@ -137,7 +137,7 @@
             elide: Text.ElideRight
             elideWidth: LastInteractionDate ? (smartListItemDelegate.width - lastInteractionPreferredWidth - conversationSmartListUserImage.width-32) :
                                               smartListItemDelegate.width - lastInteractionPreferredWidth
-            text: InCall ? CallStateStr : (Draft ? Draft : LastInteraction)
+            text: InCall ? ClientWrapper.utilsAdaptor.getCallStatusStr(CallState) : (Draft ? Draft : LastInteraction)
         }
 
         font.hintingPreference: Font.PreferNoHinting
diff --git a/src/mainview/components/OutgoingCallPage.qml b/src/mainview/components/OutgoingCallPage.qml
index c3a4fd5..b0b2aa8 100644
--- a/src/mainview/components/OutgoingCallPage.qml
+++ b/src/mainview/components/OutgoingCallPage.qml
@@ -28,7 +28,7 @@
     id: outgoingCallPageRect
 
     property int buttonPreferredSize: 50
-    property string callStatusPresentation: "outgoing"
+    property int callStatus: 0
     property string contactImgSource: ""
     property string bestName: "Best Name"
     property string bestId: "Best Id"
@@ -160,7 +160,7 @@
                     horizontalAlignment: Text.AlignHCenter
                     verticalAlignment: Text.AlignVCenter
 
-                    text: callStatusPresentation + "..."
+                    text: ClientWrapper.utilsAdaptor.getCallStatusStr(callStatus) + "..."
                     color: Qt.lighter("white", 1.5)
                 }
             }
diff --git a/src/mainview/components/SidePanel.qml b/src/mainview/components/SidePanel.qml
index c861e98..350244e 100644
--- a/src/mainview/components/SidePanel.qml
+++ b/src/mainview/components/SidePanel.qml
@@ -31,7 +31,7 @@
     property int pendingRequestCount: 0
     property int totalUnreadMessagesCount: 0
 
-    signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr)
+    signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callState)
     signal accountComboBoxNeedToShowWelcomePage()
     signal conversationSmartListViewNeedToShowWelcomePage
     signal needToUpdateConversationForAddedContact
@@ -87,6 +87,7 @@
 
     function refreshAccountComboBox(index = -1) {
 
+
         /*
          * To make sure that the ui is refreshed for accountComboBox.
          * Note: when index in -1, it means to maintain the
@@ -242,7 +243,7 @@
             sidePanelRect.conversationSmartListNeedToAccessMessageWebView(
                         currentUserDisplayName, currentUserAlias,
                         currentUID, callStackViewShouldShow,
-                        isAudioOnly, callStateStr)
+                        isAudioOnly, callState)
         }
 
         onNeedToGrabFocus: {
diff --git a/src/smartlistmodel.cpp b/src/smartlistmodel.cpp
index c3957cb..db76a87 100644
--- a/src/smartlistmodel.cpp
+++ b/src/smartlistmodel.cpp
@@ -130,6 +130,7 @@
             if (role == Role::AccountId) {
                 return QVariant(itemAccId);
             }
+
             auto &itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId);
             item = itemAccountInfo.conversationModel->getConversationForUID(itemConvUid);
             return getConversationItemData(item, itemAccountInfo, role);
@@ -160,7 +161,7 @@
     roles[InCall] = "InCall";
     roles[IsAudioOnly] = "IsAudioOnly";
     roles[CallStackViewShouldShow] = "CallStackViewShouldShow";
-    roles[CallStateStr] = "CallStateStr";
+    roles[CallState] = "CallState";
     roles[SectionName] = "SectionName";
     roles[AccountId] = "AccountId";
     roles[Draft] = "Draft";
@@ -340,14 +341,13 @@
         }
         return QVariant(false);
     }
-    case Role::CallStateStr: {
+    case Role::CallState: {
         auto* convModel = LRCInstance::getCurrentConversationModel();
         const auto convInfo = convModel->getConversationForUID(item.uid);
         if (!convInfo.uid.isEmpty()) {
             auto* call = LRCInstance::getCallInfoForConversation(convInfo);
             if (call) {
-                auto statusString = call::to_string(call->status);
-                return QVariant(statusString);
+                return QVariant(static_cast<int>(call->status));
             }
         }
         return QVariant();
diff --git a/src/smartlistmodel.h b/src/smartlistmodel.h
index bdf3592..3128d70 100644
--- a/src/smartlistmodel.h
+++ b/src/smartlistmodel.h
@@ -55,7 +55,7 @@
         InCall,
         IsAudioOnly,
         CallStackViewShouldShow,
-        CallStateStr,
+        CallState,
         SectionName,
         AccountId,
         Draft
diff --git a/src/utils.cpp b/src/utils.cpp
index a43cf1b..2723ff3 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -1046,6 +1046,14 @@
     return call->id;
 }
 
+const QString
+UtilsAdapter::getCallStatusStr(int statusInt)
+{
+    const auto status = static_cast<lrc::api::call::Status>(statusInt);
+    return lrc::api::call::to_string(status);
+}
+
+
 // returns true if name is valid registered name
 bool
 UtilsAdapter::validateRegNameForm(const QString &regName)
diff --git a/src/utils.h b/src/utils.h
index f97d0d6..4ffc5f2 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -504,6 +504,7 @@
     Q_INVOKABLE void stopPreviewing();
     Q_INVOKABLE bool hasVideoCall();
     Q_INVOKABLE const QString getCallId(const QString &accountId, const QString &convUid);
+    Q_INVOKABLE const QString getCallStatusStr(int statusInt);
     Q_INVOKABLE QString getStringUTF8(QString string);
     Q_INVOKABLE bool validateRegNameForm(const QString &regName);
     Q_INVOKABLE QString getRecordQualityString(int value);