mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-02-07 15:08:24 +00:00
feat(Settings): add an option to play chat sound notification when receiving an incoming message
Co-authored-by: Ronan Abhamon <ronan.abhamon@belledonne-communications.com>
This commit is contained in:
parent
f9a5871fe5
commit
38f4870d46
14 changed files with 87 additions and 2 deletions
|
|
@ -1187,6 +1187,10 @@ Server URL ist nicht konfiguriert.</translation>
|
|||
<source>callRecorderEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1192,6 +1192,10 @@ your friend's SIP address or username.</translation>
|
|||
<source>callRecorderEnabledLabel</source>
|
||||
<translation>Call recorder enabled</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1190,6 +1190,10 @@ Cliquez ici : <a href="%1">%1</a>
|
|||
<source>callRecorderEnabledLabel</source>
|
||||
<translation>Enregistrement d'appel activé</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1187,6 +1187,10 @@
|
|||
<source>callRecorderEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1192,6 +1192,10 @@ Tiesiog, įveskite savo draugo SIP adresą ar naudotojo vardą.</translation>
|
|||
<source>callRecorderEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1190,6 +1190,10 @@
|
|||
<source>callRecorderEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1186,6 +1186,10 @@
|
|||
<source>chatEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1192,6 +1192,10 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin.</translation>
|
|||
<source>callRecorderEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatSoundNotificationEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -168,10 +168,28 @@ void CoreHandlers::onMessageReceived (
|
|||
|
||||
if (contentType == "text/plain" || contentType == "application/vnd.gsma.rcs-ft-http+xml") {
|
||||
emit messageReceived(message);
|
||||
core->playLocal("OUTPUT/desktop/share/sounds/linphone/incoming_chat.wav");
|
||||
|
||||
// 1. Do not notify if chat is not activated.
|
||||
if (!CoreManager::getInstance()->getSettingsModel()->getChatEnabled())
|
||||
return;
|
||||
|
||||
// 2. Notify with Notification popup.
|
||||
const App *app = App::getInstance();
|
||||
if (!app->hasFocus() && CoreManager::getInstance()->getSettingsModel()->getChatEnabled())
|
||||
if (!app->hasFocus())
|
||||
app->getNotifier()->notifyReceivedMessage(message);
|
||||
|
||||
// 3. Notify with sound.
|
||||
if (!CoreManager::getInstance()->getSettingsModel()->getChatSoundNotificationEnabled())
|
||||
return;
|
||||
|
||||
if (
|
||||
!app->hasFocus() ||
|
||||
!CoreManager::getInstance()->chatModelExists(
|
||||
Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly())
|
||||
)
|
||||
)
|
||||
// TODO: Provide a way to choose sound file.
|
||||
core->playLocal(linphone::Factory::get()->getSoundResourcesDir() + "/incoming_chat.wav");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,10 @@ shared_ptr<ChatModel> CoreManager::getChatModelFromSipAddress (const QString &si
|
|||
return chatModel;
|
||||
}
|
||||
|
||||
bool CoreManager::chatModelExists (const QString &sipAddress) {
|
||||
return mChatModels.contains(sipAddress);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CoreManager::init (QObject *parent, const QString &configPath) {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public:
|
|||
}
|
||||
|
||||
std::shared_ptr<ChatModel> getChatModelFromSipAddress (const QString &sipAddress);
|
||||
bool chatModelExists (const QString &sipAddress);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Video render lock.
|
||||
|
|
|
|||
|
|
@ -303,6 +303,17 @@ void SettingsModel::setChatEnabled (bool status) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getChatSoundNotificationEnabled () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "chat_sound_notification_enabled", 1);
|
||||
}
|
||||
|
||||
void SettingsModel::setChatSoundNotificationEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "chat_sound_notification_enabled", status);
|
||||
emit chatSoundNotificationEnabledChanged(status);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString SettingsModel::getFileTransferUrl () const {
|
||||
return Utils::coreStringToAppString(
|
||||
CoreManager::getInstance()->getCore()->getFileTransferServer()
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ class SettingsModel : public QObject {
|
|||
|
||||
Q_PROPERTY(bool chatEnabled READ getChatEnabled WRITE setChatEnabled NOTIFY chatEnabledChanged);
|
||||
|
||||
Q_PROPERTY(bool chatSoundNotificationEnabled READ getChatSoundNotificationEnabled WRITE setChatSoundNotificationEnabled NOTIFY chatSoundNotificationEnabledChanged);
|
||||
|
||||
Q_PROPERTY(QString fileTransferUrl READ getFileTransferUrl WRITE setFileTransferUrl NOTIFY fileTransferUrlChanged);
|
||||
|
||||
Q_PROPERTY(bool limeIsSupported READ getLimeIsSupported CONSTANT);
|
||||
|
|
@ -219,6 +221,9 @@ public:
|
|||
bool getChatEnabled () const;
|
||||
void setChatEnabled (bool status);
|
||||
|
||||
bool getChatSoundNotificationEnabled () const;
|
||||
void setChatSoundNotificationEnabled (bool status);
|
||||
|
||||
QString getFileTransferUrl () const;
|
||||
void setFileTransferUrl (const QString &url);
|
||||
|
||||
|
|
@ -373,6 +378,8 @@ signals:
|
|||
|
||||
void chatEnabledChanged (bool status);
|
||||
|
||||
void chatSoundNotificationEnabledChanged (bool status);
|
||||
|
||||
void fileTransferUrlChanged (const QString &url);
|
||||
|
||||
void mediaEncryptionChanged (MediaEncryption encryption);
|
||||
|
|
|
|||
|
|
@ -135,6 +135,18 @@ TabContainer {
|
|||
}
|
||||
}
|
||||
|
||||
FormLine {
|
||||
FormGroup {
|
||||
label: qsTr('chatSoundNotificationEnabledLabel')
|
||||
|
||||
Switch {
|
||||
checked: SettingsModel.chatSoundNotificationEnabled
|
||||
|
||||
onClicked: SettingsModel.chatSoundNotificationEnabled = !checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormLine {
|
||||
FormGroup {
|
||||
label: qsTr('fileServerLabel')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue