refs #220, improved voice room handling by providing join/left flag and connection handling

This commit is contained in:
Klaus Basan
2014-06-05 13:21:08 +02:00
parent 58e97b6958
commit 6344923725
5 changed files with 37 additions and 30 deletions

View File

@@ -55,7 +55,8 @@ namespace BlackCore
void audioTestCompleted();
//! Voice rooms changed
void changedVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms);
//! \details the flag indicates, whether a room got connected or disconnected
void changedVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms, bool connected);
public slots:
//! Get voice rooms for COM1, COM2:

View File

@@ -372,12 +372,24 @@ namespace BlackCore
switch (newStatus)
{
case IVoice::Connected:
emit this->changedVoiceRooms(this->m_voice->getComVoiceRooms());
emit this->changedVoiceRooms(this->m_voice->getComVoiceRooms(), true);
break;
case IVoice::Disconnecting:
emit this->changedVoiceRooms(this->m_voice->getComVoiceRooms());
break;
case IVoice::Connecting:
break;
case IVoice::ConnectingFailed:
case IVoice::DisconnectedError:
{
const QString e = QString("Voice room %1 error").arg(comUnit);
qWarning(e.toUtf8().constData());
// no break here!
}
case IVoice::Disconnected:
// good chance to update aircraft
if (this->getIContextOwnAircraft()) m_voice->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
emit this->changedVoiceRooms(this->m_voice->getComVoiceRooms(), false);
break;
default:
break;

View File

@@ -33,7 +33,7 @@ namespace BlackCore
"audioTestCompleted", this, SIGNAL(audioTestCompleted()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
"changedVoiceRooms", this, SIGNAL(changedVoiceRooms(BlackMisc::Audio::CVoiceRoomList)));
"changedVoiceRooms", this, SIGNAL(changedVoiceRooms(BlackMisc::Audio::CVoiceRoomList, bool)));
Q_ASSERT(s);
Q_UNUSED(s);
}

View File

@@ -17,6 +17,7 @@ using namespace BlackMisc::Geo;
using namespace BlackMisc::Settings;
using namespace BlackMisc::Math;
using namespace BlackMisc::Audio;
using namespace BlackSound;
namespace BlackGui
{
@@ -70,7 +71,7 @@ namespace BlackGui
// Audio is optional
if (this->getIContextAudio())
{
this->connect(this->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitV1Component::updateAudioVoiceRoomsFromObject);
this->connect(this->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitV1Component::updateAudioVoiceRoomsFromObjects);
}
}
@@ -247,25 +248,6 @@ namespace BlackGui
this->ui->ds_CockpitCom2Standby->setValue(freq);
}
void CCockpitV1Component::updateCockpitFromObject(const CAircraft &ownAircraft)
{
// update GUI elements
// avoid unnecessary change events as far as possible
const CComSystem com1 = ownAircraft.getCom1System(); // aircraft just updated or set from context
const CComSystem com2 = ownAircraft.getCom2System();
const CTransponder transponder = ownAircraft.getTransponder();
// update the frequencies
this->updateComFrequencyDisplaysFromObjects(com1, com2);
// update transponder
qint32 tc = transponder.getTransponderCode();
if (tc != static_cast<qint32>(this->ui->ds_CockpitTransponder->value()))
this->ui->ds_CockpitTransponder->setValue(tc);
this->ui->cbp_CockpitTransponderMode->setSelectedTransponderMode(transponder.getTransponderMode());
}
void CCockpitV1Component::updateCockpitFromContext(const CAircraft &ownAircraft, const QString &originator)
{
if (originator == CCockpitV1Component::cockpitOriginator()) return; // comes from myself
@@ -330,12 +312,15 @@ namespace BlackGui
this->getIContextOwnAircraft()->setAudioVoiceRoomOverrideUrls(room1, room2);
}
void CCockpitV1Component::updateAudioVoiceRoomsFromObject(const CVoiceRoomList &selectedVoiceRooms)
void CCockpitV1Component::updateAudioVoiceRoomsFromObjects(const CVoiceRoomList &selectedVoiceRooms, bool connected)
{
Q_ASSERT(selectedVoiceRooms.size() == 2);
CVoiceRoom room1 = selectedVoiceRooms[0];
CVoiceRoom room2 = selectedVoiceRooms[1];
// KB_REMOVE
qDebug() << "selected rooms" << room1.isConnected() << room1.getVoiceRoomUrl() << room2.isConnected() << room2.getVoiceRoomUrl();
// remark
// isAudioPlaying() is not set, as this is only a temporary value when really "something is playing"
@@ -363,7 +348,19 @@ namespace BlackGui
this->ui->le_CockpitVoiceRoomCom2->setStyleSheet("");
this->ui->tvp_CockpitVoiceRoom2->clear();
}
if (changedUrl1 || changedUrl2) this->updateVoiceRoomMembers();
if (changedUrl1 || changedUrl2)
{
this->updateVoiceRoomMembers();
// notify
if (this->getIContextAudio())
{
CNotificationSounds::Notification sound = connected ?
CNotificationSounds::NotificationVoiceRoomJoined :
CNotificationSounds::NotificationVoiceRoomLeft;
this->getIContextAudio()->playNotification(static_cast<uint>(sound), true);
}
}
}
void CCockpitV1Component::updateVoiceRoomMembers()

View File

@@ -72,7 +72,7 @@ namespace BlackGui
void cockpitValuesChanged();
//! Update voice rooms from list
void updateAudioVoiceRoomsFromObject(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms);
void updateAudioVoiceRoomsFromObjects(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms, bool connected);
//! Update the voice room members
void updateVoiceRoomMembers();
@@ -85,9 +85,6 @@ namespace BlackGui
//! Own aircraft object
BlackMisc::Aviation::CAircraft getOwnAircraft() const;
//! Cockpit from aircraft object
void updateCockpitFromObject(const BlackMisc::Aviation::CAircraft &ownAircraft);
//! COM frequencies displays
void updateComFrequencyDisplaysFromObjects(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2);