From d8f69c760308222399b1c0b4afe5b5369f019978 Mon Sep 17 00:00:00 2001 From: marian Date: Fri, 11 Mar 2011 14:38:33 +0000 Subject: [PATCH] Show a notification message when failed to set media on active channel. git-svn-id: http://yate.null.ro/svn/yate/trunk@4175 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/ClientLogic.cpp | 46 ++++++++++++++++++++++++++++++++ share/skins/default/qt4client.ui | 1 + yatecbase.h | 10 +++++++ 3 files changed, 57 insertions(+) diff --git a/engine/ClientLogic.cpp b/engine/ClientLogic.cpp index ecb97390..ea680f31 100644 --- a/engine/ClientLogic.cpp +++ b/engine/ClientLogic.cpp @@ -5750,6 +5750,11 @@ bool DefaultLogic::handleClientChanUpdate(Message& msg, bool& stopLogic) if (silence) Client::self()->ringer(false,true); } + if (chan) { + bool mic = chan->muted() || (0 != chan->getSource()); + bool speaker = (0 != chan->getConsumer()); + notifyNoAudio(!(mic && speaker),mic,speaker,chan); + } break; case ClientChannel::OnHold: enableActions = true; @@ -6887,6 +6892,47 @@ bool DefaultLogic::handleFileTransferNotify(Message& msg, bool& stopLogic) return true; } +// Show/hide no audio notification (chan==0: initial check) +void DefaultLogic::notifyNoAudio(bool show, bool micOk, bool speakerOk, + ClientChannel* chan) +{ + if (!Client::valid()) + return; + Window* w = Client::self()->getWindow(s_wndMain); + if (!show) { + String id; + buildNotifAreaId(id,"noaudio",String::empty()); + Client::self()->delTableRow("messages",id,w); + return; + } + if (micOk && speakerOk) + return; + NamedList list(""); + NamedList* upd = buildNotifArea(list,"noaudio",String::empty(), + String::empty(),"Audio failure"); + String text; + if (chan) { + text << "Failed to open "; + if (!(micOk || speakerOk)) + text << "audio"; + else if (micOk) + text << "speaker"; + else + text << "microphone"; + text << ".\r\nPlease check your sound card"; + } + else + return; + upd->addParam("text",text); + setGenericNotif(*upd); + Client::self()->updateTableRows("messages",&list,false,w); + NamedList p(""); + const char* ok = String::boolText(show); + p.addParam("check:messages_show",ok); + p.addParam("show:frame_messages",ok); + Client::self()->setParams(&p,w); +} + // Add/set an account bool DefaultLogic::updateAccount(const NamedList& account, bool save, const String& replace, bool loaded) diff --git a/share/skins/default/qt4client.ui b/share/skins/default/qt4client.ui index 7da2ced9..e56759d5 100644 --- a/share/skins/default/qt4client.ui +++ b/share/skins/default/qt4client.ui @@ -1979,6 +1979,7 @@ QTextEdit { property:_yate_itemui=incomingcall:messages_okrejignore.ui property:_yate_itemui=incomingfile:messages_okrejignore.ui property:_yate_itemui=rosterreqfail:messages_generic.ui + property:_yate_itemui=noaudio:messages_generic.ui diff --git a/yatecbase.h b/yatecbase.h index 0c633591..8866c9e1 100644 --- a/yatecbase.h +++ b/yatecbase.h @@ -3120,6 +3120,16 @@ protected: */ virtual bool handleFileTransferNotify(Message& msg, bool& stopLogic); + /** + * Show/hide no audio notification + * @param show Show or hide notification + * @param micOk False if microphone open failed + * @param speakerOk False if speaker open failed + * @param chan Optional failed channel + */ + virtual void notifyNoAudio(bool show, bool micOk = false, bool speakerOk = false, + ClientChannel* chan = 0); + String m_selectedChannel; // The currently selected channel String m_transferInitiated; // Tranfer initiated id