diff --git a/audio/ToxicIncomingCall.pcm b/audio/ToxicIncomingCall.pcm new file mode 100644 index 000000000..8239c74cf Binary files /dev/null and b/audio/ToxicIncomingCall.pcm differ diff --git a/res.qrc b/res.qrc index 4ef12f901..5f3cfe467 100644 --- a/res.qrc +++ b/res.qrc @@ -123,6 +123,7 @@ ui/fileTransferInstance/emptyRGreenFileButton.png ui/fileTransferInstance/emptyRRedFileButton.png audio/notification.pcm + audio/ToxicIncomingCall.pcm img/settings/general.png img/settings/identity.png img/settings/privacy.png diff --git a/widget/widget.cpp b/widget/widget.cpp index dfa25fffe..708c23fd4 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -145,6 +145,7 @@ Widget::Widget(QWidget *parent) connect(core, &Core::groupMessageReceived, this, &Widget::onGroupMessageReceived); connect(core, &Core::groupNamelistChanged, this, &Widget::onGroupNamelistChanged); connect(core, &Core::emptyGroupCreated, this, &Widget::onEmptyGroupCreated); + connect(core, &Core::avInvite, this, &Widget::playRingtone); connect(core, SIGNAL(messageSentResult(int,QString,int)), this, SLOT(onMessageSendResult(int,QString,int))); connect(core, SIGNAL(groupSentResult(int,QString,int)), this, SLOT(onGroupSendResult(int,QString,int))); @@ -535,6 +536,26 @@ void Widget::newMessageAlert() alSourcePlay(core->alMainSource); } +void Widget::playRingtone() +{ + QApplication::alert(this); + + static QFile sndFile1(":audio/ToxicIncomingCall.pcm"); // for whatever reason this plays slower/downshifted from what any other program plays the file as... but whatever + static QByteArray sndData1; + if (sndData1.isEmpty()) + { + sndFile1.open(QIODevice::ReadOnly); + sndData1 = sndFile1.readAll(); + sndFile1.close(); + } + + ALuint buffer; + alGenBuffers(1, &buffer); + alBufferData(buffer, AL_FORMAT_MONO16, sndData1.data(), sndData1.size(), 44100); + alSourcei(core->alMainSource, AL_BUFFER, buffer); + alSourcePlay(core->alMainSource); +} + void Widget::onFriendRequestReceived(const QString& userId, const QString& message) { FriendRequestDialog dialog(this, userId, message); diff --git a/widget/widget.h b/widget/widget.h index c9d4e6388..b7abc60fa 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -104,6 +104,7 @@ private slots: void setStatusBusy(); void onMessageSendResult(int friendId, const QString& message, int messageId); void onGroupSendResult(int groupId, const QString& message, int result); + void playRingtone(); private: void hideMainForms();