feat(Settings): add an developer option to disable call recorder

This commit is contained in:
Ronan Abhamon 2018-04-17 15:16:25 +02:00
parent 83e4b4737a
commit eb15c571a2
10 changed files with 70 additions and 10 deletions

View file

@ -1188,6 +1188,10 @@ your friend&apos;s SIP address or username.</translation>
<source>chatEnabledLabel</source>
<translation>Chat enabled</translation>
</message>
<message>
<source>callRecorderEnabledLabel</source>
<translation>Call recorder enabled</translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>

View file

@ -1186,6 +1186,10 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>chatEnabledLabel</source>
<translation>Chat activé</translation>
</message>
<message>
<source>callRecorderEnabledLabel</source>
<translation>Enregistrement d&apos;appel activé</translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>

View file

@ -1186,6 +1186,10 @@
<source>chatEnabledLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>callRecorderEnabledLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>

View file

@ -1188,6 +1188,10 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin.</translation>
<source>chatEnabledLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>callRecorderEnabledLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>

View file

@ -23,19 +23,21 @@
#include <QDateTime>
#include <QTimer>
#include "../../app/App.hpp"
#include "../../utils/LinphoneUtils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "app/App.hpp"
#include "components/core/CoreManager.hpp"
#include "utils/LinphoneUtils.hpp"
#include "utils/Utils.hpp"
#include "CallModel.hpp"
#define AUTO_ANSWER_OBJECT_NAME "auto-answer-timer"
#define DTMF_SOUND_DELAY 200
// =============================================================================
using namespace std;
// =============================================================================
namespace {
constexpr char cAutoAnswerObjectName[] = "auto-answer-timer";
constexpr int cDtmfSoundDelay = 200;
}
CallModel::CallModel (shared_ptr<linphone::Call> call) {
Q_CHECK_PTR(call);
@ -54,7 +56,7 @@ CallModel::CallModel (shared_ptr<linphone::Call> call) {
QTimer *timer = new QTimer(this);
timer->setInterval(settings->getAutoAnswerDelay());
timer->setSingleShot(true);
timer->setObjectName(AUTO_ANSWER_OBJECT_NAME);
timer->setObjectName(cAutoAnswerObjectName);
QObject::connect(timer, &QTimer::timeout, this, &CallModel::acceptWithAutoAnswerDelay);
timer->start();
@ -328,7 +330,7 @@ void CallModel::updateIsInConference () {
// -----------------------------------------------------------------------------
void CallModel::stopAutoAnswerTimer () const {
QTimer *timer = findChild<QTimer *>(AUTO_ANSWER_OBJECT_NAME, Qt::FindDirectChildrenOnly);
QTimer *timer = findChild<QTimer *>(cAutoAnswerObjectName, Qt::FindDirectChildrenOnly);
if (timer) {
timer->stop();
timer->deleteLater();
@ -550,7 +552,7 @@ void CallModel::sendDtmf (const QString &dtmf) {
const char key = dtmf.constData()[0].toLatin1();
qInfo() << QStringLiteral("Send dtmf: `%1`.").arg(key);
mCall->sendDtmf(key);
CoreManager::getInstance()->getCore()->playDtmf(key, DTMF_SOUND_DELAY);
CoreManager::getInstance()->getCore()->playDtmf(key, cDtmfSoundDelay);
}
// -----------------------------------------------------------------------------

View file

@ -281,6 +281,17 @@ void SettingsModel::setAutoAnswerVideoStatus (bool status) {
// -----------------------------------------------------------------------------
bool SettingsModel::getCallRecorderEnabled () const {
return !!mConfig->getInt(UI_SECTION, "call_recorder_enabled", 1);
}
void SettingsModel::setCallRecorderEnabled (bool status) {
mConfig->setInt(UI_SECTION, "call_recorder_enabled", status);
emit callRecorderEnabledChanged(status);
}
// -----------------------------------------------------------------------------
bool SettingsModel::getChatEnabled () const {
return !!mConfig->getInt(UI_SECTION, "chat_enabled", 1);
}
@ -290,6 +301,8 @@ void SettingsModel::setChatEnabled (bool status) {
emit chatEnabledChanged(status);
}
// -----------------------------------------------------------------------------
QString SettingsModel::getFileTransferUrl () const {
return Utils::coreStringToAppString(
CoreManager::getInstance()->getCore()->getFileTransferServer()

View file

@ -69,6 +69,8 @@ class SettingsModel : public QObject {
Q_PROPERTY(bool autoAnswerVideoStatus READ getAutoAnswerVideoStatus WRITE setAutoAnswerVideoStatus NOTIFY autoAnswerVideoStatusChanged);
Q_PROPERTY(int autoAnswerDelay READ getAutoAnswerDelay WRITE setAutoAnswerDelay NOTIFY autoAnswerDelayChanged);
Q_PROPERTY(bool callRecorderEnabled READ getCallRecorderEnabled WRITE setCallRecorderEnabled NOTIFY callRecorderEnabledChanged);
Q_PROPERTY(bool chatEnabled READ getChatEnabled WRITE setChatEnabled NOTIFY chatEnabledChanged);
Q_PROPERTY(QString fileTransferUrl READ getFileTransferUrl WRITE setFileTransferUrl NOTIFY fileTransferUrlChanged);
@ -211,6 +213,9 @@ public:
int getAutoAnswerDelay () const;
void setAutoAnswerDelay (int delay);
bool getCallRecorderEnabled () const;
void setCallRecorderEnabled (bool status);
bool getChatEnabled () const;
void setChatEnabled (bool status);
@ -364,6 +369,8 @@ signals:
void autoAnswerVideoStatusChanged (bool status);
void autoAnswerDelayChanged (int delay);
void callRecorderEnabledChanged (bool status);
void chatEnabledChanged (bool status);
void fileTransferUrlChanged (const QString &url);

View file

@ -177,6 +177,7 @@ Rectangle {
enabled: incall.call.recording
icon: 'record'
useStates: false
visible: SettingsModel.callRecorderEnabled
onClicked: {
var call = incall.call
@ -185,6 +186,12 @@ Rectangle {
: call.stopRecording()
}
onVisibleChanged: {
if (!visible) {
call.stopRecording()
}
}
TooltipArea {
text: !recordingSwitch.enabled
? qsTr('startRecordingLabel')

View file

@ -236,6 +236,7 @@ Window {
enabled: call.recording
icon: 'record'
useStates: false
visible: SettingsModel.callRecorderEnabled
onClicked: !enabled
? call.startRecording()

View file

@ -99,6 +99,20 @@ TabContainer {
}
}
}
FormLine {
visible: SettingsModel.developerSettingsEnabled
FormGroup {
label: qsTr('callRecorderEnabledLabel')
Switch {
checked: SettingsModel.callRecorderEnabled
onClicked: SettingsModel.callRecorderEnabled = !checked
}
}
}
}
Form {