Add caller decision controls and colored phone presence on desktop
This commit is contained in:
1 parent
77af45649c
commit
4ccd919ef8
3 files changed
+52
-5
No files matched your search
@@ -571,6 +571,14 @@ void MainWindow::setupBridgeCallbacks() {
|
||||
gui_bridge_set_call_ringing_cb([](uint64_t call_id) {
|
||||
if (s_mainWindow) s_mainWindow->onCallRinging(call_id);
|
||||
});
|
||||
gui_bridge_set_call_phone_busy_cb([](uint64_t call_id) {
|
||||
if (!s_mainWindow) return;
|
||||
auto* window = s_mainWindow->m_activeCalls.value(call_id, nullptr);
|
||||
if (!window || window->state() != CallWindow::Outgoing) return;
|
||||
SoundManager::instance()->stopLoop();
|
||||
window->setState(CallWindow::WaitDecision);
|
||||
window->show(); window->raise();
|
||||
});
|
||||
gui_bridge_set_call_accepted_cb([](uint64_t call_id) {
|
||||
if (s_mainWindow) s_mainWindow->onCallAccepted(call_id);
|
||||
});
|
||||
@@ -767,7 +775,7 @@ void MainWindow::onRadioCallRequested(const QString& channel, quint64 peer) {
|
||||
|
||||
/* Один диалог на незавершённое приглашение; принятая рация живёт своим обычным циклом. */
|
||||
void MainWindow::onRadioCallEvent(const uint8_t* data, int len) {
|
||||
if (!data || len != 27 || data[24] < RADIO_CALL_OUTGOING || data[24] > RADIO_CALL_FINISHED ||
|
||||
if (!data || len != 27 || data[24] < RADIO_CALL_OUTGOING || data[24] > RADIO_CALL_WAIT_DECISION ||
|
||||
data[25] > RADIO_CALL_AUDIO_ERROR || data[26] > 1) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_RADIO, "desktop invalid radio call event bytes=%d", len); return;
|
||||
}
|
||||
@@ -807,6 +815,13 @@ void MainWindow::onRadioCallEvent(const uint8_t* data, int len) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (state == RADIO_CALL_WAIT_DECISION && incoming) return;
|
||||
if (state == RADIO_CALL_WAIT_DECISION && m_radioCallId == id) {
|
||||
m_radioCallId = 0;
|
||||
SoundManager::instance()->stopLoop();
|
||||
if (m_radioCallWindow) m_radioCallWindow->close();
|
||||
m_radioCallWindow = nullptr;
|
||||
}
|
||||
if (m_radioCallId == id) return;
|
||||
if (m_radioCallId || !m_activeCalls.isEmpty()) { postRadioCall(id, RADIO_CALL_REJECT_BUSY); return; }
|
||||
QString name = m_db->getDisplayName(peer);
|
||||
@@ -830,6 +845,17 @@ void MainWindow::onRadioCallEvent(const uint8_t* data, int len) {
|
||||
bool ready = m_currentChannelId == channel && m_messageList->enableRadio();
|
||||
postRadioCall(id, ready ? RADIO_CALL_ACCEPT : RADIO_CALL_FAIL);
|
||||
});
|
||||
} else if (state == RADIO_CALL_WAIT_DECISION) {
|
||||
box->setInformativeText(QCoreApplication::translate("ChatGui", "Subscriber is on a phone call"));
|
||||
auto* proceed = box->addButton(QCoreApplication::translate("ChatGui", "Call anyway"), QMessageBox::AcceptRole);
|
||||
box->addButton(QCoreApplication::translate("ChatGui", "End call"), QMessageBox::RejectRole);
|
||||
connect(box, &QMessageBox::buttonClicked, this, [this, id, proceed](QAbstractButton* button) {
|
||||
if (m_radioCallId != id || button != proceed) return;
|
||||
m_radioCallAnswered = true;
|
||||
m_radioCallId = 0;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "desktop caller overrides phone busy id=%016llx", (unsigned long long)id);
|
||||
postRadioCall(id, RADIO_CALL_CONTINUE);
|
||||
});
|
||||
} else {
|
||||
box->addButton(QMessageBox::Cancel);
|
||||
box->setInformativeText(QCoreApplication::translate("ChatGui", "Checking subscriber availability…"));
|
||||
@@ -842,7 +868,7 @@ void MainWindow::onRadioCallEvent(const uint8_t* data, int len) {
|
||||
}
|
||||
});
|
||||
box->show(); box->raise(); box->activateWindow();
|
||||
SoundManager::instance()->playLoop(incoming ? "radio_incoming" : "call_connecting");
|
||||
if (state != RADIO_CALL_WAIT_DECISION) SoundManager::instance()->playLoop(incoming ? "radio_incoming" : "call_connecting");
|
||||
if (incoming) {
|
||||
if (m_trayIcon && (!isVisible() || isMinimized()))
|
||||
m_trayIcon->showMessage(QCoreApplication::translate("ChatGui", "Radio call"), box->text());
|
||||
|
||||
Reference in new issue
Block a user