From a395bfe0d507e8e8c7a936907dcf44ddfadb90a5 Mon Sep 17 00:00:00 2001 From: jpbl <jpbl> Date: Wed, 12 Oct 2005 19:41:55 +0000 Subject: [PATCH] mute is now a normal request --- src/gui/official/CallManagerImpl.cpp | 20 +++++-- src/gui/official/CallManagerImpl.hpp | 5 ++ src/gui/official/PhoneLineManagerImpl.cpp | 1 + src/gui/official/Request.cpp | 39 ++++++++---- src/gui/official/RequesterImpl.cpp | 10 +--- src/gui/official/SFLPhoneApp.cpp | 2 +- src/gui/official/SFLPhoneWindow.cpp | 2 +- src/gui/official/SFLRequest.cpp | 72 ++++++++++++++--------- 8 files changed, 98 insertions(+), 53 deletions(-) diff --git a/src/gui/official/CallManagerImpl.cpp b/src/gui/official/CallManagerImpl.cpp index e3463c3140..45241fec8f 100644 --- a/src/gui/official/CallManagerImpl.cpp +++ b/src/gui/official/CallManagerImpl.cpp @@ -18,9 +18,11 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <qobject.h> #include <stdexcept> #include "CallManagerImpl.hpp" +#include "DebugOutput.hpp" void CallManagerImpl::registerCall(const Call &call) @@ -38,15 +40,24 @@ CallManagerImpl::unregisterCall(const Call &call) void CallManagerImpl::unregisterCall(const QString &id) +{ + QMutexLocker guard(&mCallsMutex); + std::map< QString, Call >::iterator pos = mCalls.find(id); + if(pos != mCalls.end()) { + mCalls.erase(pos); + } +} + +bool +CallManagerImpl::exist(const QString &id) { QMutexLocker guard(&mCallsMutex); std::map< QString, Call >::iterator pos = mCalls.find(id); if(pos == mCalls.end()) { - //TODO - //throw std::runtime_error(QString("Trying to unregister an unregistred call (%1)").arg(id).toStdString().c_str()); + return false; } - mCalls.erase(pos); + return true; } Call @@ -55,8 +66,7 @@ CallManagerImpl::getCall(const QString &id) QMutexLocker guard(&mCallsMutex); std::map< QString, Call >::iterator pos = mCalls.find(id); if(pos == mCalls.end()) { - //TODO - //throw std::runtime_error(QString("Trying to retreive an unregistred call (%1)").arg(id).toStdString().c_str()); + throw std::runtime_error("Trying to retreive an unregistred call\n"); } return pos->second; diff --git a/src/gui/official/CallManagerImpl.hpp b/src/gui/official/CallManagerImpl.hpp index 78b4c27b2a..d6e7aec7e2 100644 --- a/src/gui/official/CallManagerImpl.hpp +++ b/src/gui/official/CallManagerImpl.hpp @@ -34,6 +34,11 @@ public: void unregisterCall(const Call &call); void unregisterCall(const QString &id); + /** + * Return true if the call is registered. + */ + bool exist(const QString &id); + /** * Return the call with the given id. If * there's no such call it will throw a diff --git a/src/gui/official/PhoneLineManagerImpl.cpp b/src/gui/official/PhoneLineManagerImpl.cpp index 6dbed0013d..d6291187cb 100644 --- a/src/gui/official/PhoneLineManagerImpl.cpp +++ b/src/gui/official/PhoneLineManagerImpl.cpp @@ -133,6 +133,7 @@ PhoneLineManagerImpl::closeSession() emit lineStatusSet(""); emit bufferStatusSet(""); + emit actionSet(""); emit globalStatusSet("Disconnected."); } diff --git a/src/gui/official/Request.cpp b/src/gui/official/Request.cpp index d55eca66e8..24ef1e232b 100644 --- a/src/gui/official/Request.cpp +++ b/src/gui/official/Request.cpp @@ -103,14 +103,23 @@ CallRelatedRequest::CallRelatedRequest(const QString &sequenceId, const QString &command, const std::list< QString > &args) : Request(sequenceId, command, args) -{} +{ + if(args.begin() != args.end()) { + mCallId = *args.begin(); + } +} void CallRelatedRequest::onError(const QString &code, const QString &message) { - onError(CallManager::instance().getCall(mCallId), - code, - message); + if(CallManager::instance().exist(mCallId)) { + onError(CallManager::instance().getCall(mCallId), + code, + message); + } + else { + DebugOutput::instance() << QObject::tr("CallRelatedRequest: Trying to retreive an unregistred call (%1)\n").arg(mCallId); + } } void @@ -120,9 +129,14 @@ CallRelatedRequest::onError(Call, const QString &, const QString &) void CallRelatedRequest::onEntry(const QString &code, const QString &message) { - onEntry(CallManager::instance().getCall(mCallId), - code, - message); + if(CallManager::instance().exist(mCallId)) { + onEntry(CallManager::instance().getCall(mCallId), + code, + message); + } + else { + DebugOutput::instance() << QObject::tr("CallRelatedRequest: Trying to retreive an unregistred call (%1)\n").arg(mCallId); + } } void @@ -132,9 +146,14 @@ CallRelatedRequest::onEntry(Call, const QString &, const QString &) void CallRelatedRequest::onSuccess(const QString &code, const QString &message) { - onSuccess(CallManager::instance().getCall(mCallId), - code, - message); + if(CallManager::instance().exist(mCallId)) { + onSuccess(CallManager::instance().getCall(mCallId), + code, + message); + } + else { + DebugOutput::instance() << QObject::tr("CallRelatedRequest: Trying to retreive an unregistred call (%1)\n").arg(mCallId); + } } void diff --git a/src/gui/official/RequesterImpl.cpp b/src/gui/official/RequesterImpl.cpp index 652a6b051c..a98f2c4de7 100644 --- a/src/gui/official/RequesterImpl.cpp +++ b/src/gui/official/RequesterImpl.cpp @@ -158,19 +158,13 @@ RequesterImpl::receiveAnswer(const QString &code, QString RequesterImpl::generateCallId() { - QString s("cCallID:"); - s += mCallIdCount; - mCallIdCount++; - return s; + return QString("cCallID:%1").arg(mCallIdCount++); } QString RequesterImpl::generateSessionId() { - QString s("cSessionID:"); - s += mSessionIdCount; - mSessionIdCount++; - return s; + return QString("cSessionID:").arg(mSequenceIdCount++); } QString diff --git a/src/gui/official/SFLPhoneApp.cpp b/src/gui/official/SFLPhoneApp.cpp index 570b93b74d..486c1c1d28 100644 --- a/src/gui/official/SFLPhoneApp.cpp +++ b/src/gui/official/SFLPhoneApp.cpp @@ -28,13 +28,13 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv) Requester::instance().registerObject< PermanentRequest >(QString("notavailable")); Requester::instance().registerObject< PermanentRequest >(QString("refuse")); Requester::instance().registerObject< PermanentRequest >(QString("hangup")); - Requester::instance().registerObject< TemporaryRequest >(QString("mute")); Requester::instance().registerObject< TemporaryRequest >(QString("unmute")); Requester::instance().registerObject< TemporaryRequest >(QString("hold")); Requester::instance().registerObject< TemporaryRequest >(QString("unhold")); Requester::instance().registerObject< TemporaryRequest >(QString("senddtmf")); Requester::instance().registerObject< Request >(QString("setspkrvolume")); Requester::instance().registerObject< Request >(QString("setmicvolume")); + Requester::instance().registerObject< Request >(QString("mute")); } void diff --git a/src/gui/official/SFLPhoneWindow.cpp b/src/gui/official/SFLPhoneWindow.cpp index 1d03bc170d..d6eec60b7e 100644 --- a/src/gui/official/SFLPhoneWindow.cpp +++ b/src/gui/official/SFLPhoneWindow.cpp @@ -198,7 +198,7 @@ SFLPhoneWindow::askResendStatus(QString message) int ret = QMessageBox::critical(NULL, tr("SFLPhone status error"), tr("The server returned an error for the lines status.\n" - "<i>\n%1\n</i>" + "\n%1\n\n" "Do you want to try to resend this command? If not,\n" "the application will close.").arg(message), QMessageBox::Retry | QMessageBox::Default, diff --git a/src/gui/official/SFLRequest.cpp b/src/gui/official/SFLRequest.cpp index cd929be937..4a69bc57bf 100644 --- a/src/gui/official/SFLRequest.cpp +++ b/src/gui/official/SFLRequest.cpp @@ -100,6 +100,7 @@ PermanentRequest::onError(Call call, const QString &, const QString &message) { + DebugOutput::instance() << QObject::tr("PermanentRequest: Error: %1").arg(toString()); PhoneLine *line = PhoneLineManager::instance().getLine(call); if(line) { PhoneLineLocker guard(line, false); @@ -207,18 +208,23 @@ CallRequest::onError(Account, const QString &, const QString &message) { - PhoneLine *line = - PhoneLineManager::instance().getLine(CallManager::instance().getCall(mCallId)); - if(line) { - PhoneLineLocker guard(line, false); - line->setLineStatus(message); - line->error(); + if(CallManager::instance().exist(mCallId)) { + PhoneLine *line = + PhoneLineManager::instance().getLine(CallManager::instance().getCall(mCallId)); + if(line) { + PhoneLineLocker guard(line, false); + line->setLineStatus(message); + line->error(); + } + else { + DebugOutput::instance() << + QObject::tr("We received an error on a call " + "that doesn't have a phone line (%1).\n") + .arg(mCallId); + } } else { - DebugOutput::instance() << - QObject::tr("We received an error on a call " - "that doesn't have a phone line (%1).\n") - .arg(mCallId); + DebugOutput::instance() << QObject::tr("CallRequest: Trying to retreive an unregistred call (%1)\n").arg(mCallId); } } @@ -227,17 +233,22 @@ CallRequest::onEntry(Account, const QString &, const QString &message) { - PhoneLine *line = - PhoneLineManager::instance().getLine(CallManager::instance().getCall(mCallId)); - if(line) { - PhoneLineLocker guard(line, false); - line->setLineStatus(message); + if(CallManager::instance().exist(mCallId)) { + PhoneLine *line = + PhoneLineManager::instance().getLine(CallManager::instance().getCall(mCallId)); + if(line) { + PhoneLineLocker guard(line, false); + line->setLineStatus(message); + } + else { + DebugOutput::instance() << + QObject::tr("We received a status on a call related request " + "that doesn't have a phone line (%1).\n") + .arg(mCallId); + } } else { - DebugOutput::instance() << - QObject::tr("We received a status on a call related request " - "that doesn't have a phone line (%1).\n") - .arg(mCallId); + DebugOutput::instance() << QObject::tr("CallRequest: Trying to retreive an unregistred call (%1)\n").arg(mCallId); } } @@ -246,16 +257,21 @@ CallRequest::onSuccess(Account, const QString &, const QString &message) { - PhoneLine *line = - PhoneLineManager::instance().getLine(CallManager::instance().getCall(mCallId)); - if(line) { - PhoneLineLocker guard(line, false); - line->setLineStatus(message); + if(CallManager::instance().exist(mCallId)) { + PhoneLine *line = + PhoneLineManager::instance().getLine(CallManager::instance().getCall(mCallId)); + if(line) { + PhoneLineLocker guard(line, false); + line->setLineStatus(message); + } + else { + DebugOutput::instance() << + QObject::tr("We received a success on a call related request " + "that doesn't have a phone line (%1).\n") + .arg(mCallId); + } } else { - DebugOutput::instance() << - QObject::tr("We received a success on a call related request " - "that doesn't have a phone line (%1).\n") - .arg(mCallId); + DebugOutput::instance() << QObject::tr("CallRequest: Trying to retreive an unregistred call (%1)\n").arg(mCallId); } } -- GitLab