diff --git a/src/gui/official/CallManagerImpl.cpp b/src/gui/official/CallManagerImpl.cpp index abb00c0a575c2fee5f23bb93dfe6875efe39d348..9bcff55e42d224a20074fa55b601a65caa25513f 100644 --- a/src/gui/official/CallManagerImpl.cpp +++ b/src/gui/official/CallManagerImpl.cpp @@ -42,7 +42,7 @@ CallManagerImpl::unregisterCall(const QString &id) QMutexLocker guard(&mCallsMutex); std::map< QString, Call >::iterator pos = mCalls.find(id); if(pos == mCalls.end()) { - throw std::runtime_error("Trying to unregister an unregistred call"); + throw std::runtime_error(QString("Trying to unregister an unregistred call (%1)").arg(id).toStdString().c_str()); } mCalls.erase(pos); @@ -54,7 +54,7 @@ CallManagerImpl::getCall(const QString &id) QMutexLocker guard(&mCallsMutex); std::map< QString, Call >::iterator pos = mCalls.find(id); if(pos == mCalls.end()) { - throw std::runtime_error("Trying to retreive an unregistred call"); + throw std::runtime_error(QString("Trying to retreive an unregistred call (%1)").arg(id).toStdString().c_str()); } return pos->second; diff --git a/src/gui/official/SFLPhoneApp.cpp b/src/gui/official/SFLPhoneApp.cpp index 5bf8200ec9fa2297f192d3b4bb9019992aca5ffb..d5b394ae528bb2a3a1499418af7c839a0b1c36ff 100644 --- a/src/gui/official/SFLPhoneApp.cpp +++ b/src/gui/official/SFLPhoneApp.cpp @@ -20,7 +20,7 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv) PhoneLineManager::instance().setNbLines(NB_PHONELINES); Requester::instance().registerObject< Request >(QString("playtone")); Requester::instance().registerObject< Request >(QString("playdtmf")); - Requester::instance().registerObject< AccountRequest >(QString("call")); + Requester::instance().registerObject< CallRequest >(QString("call")); Requester::instance().registerObject< EventRequest >(QString("getevents")); Requester::instance().registerObject< CallStatusRequest >(QString("getcallstatus")); Requester::instance().registerObject< PermanentRequest >(QString("answer")); diff --git a/src/gui/official/SFLRequest.cpp b/src/gui/official/SFLRequest.cpp index 9df1bce98a4c8d8084938b12ec3933fee330a583..060878319c6d5cd95ce99b26a2455bc4a8aaec61 100644 --- a/src/gui/official/SFLRequest.cpp +++ b/src/gui/official/SFLRequest.cpp @@ -1,9 +1,11 @@ +#include <iostream> #include <memory> #include <sstream> #include <string> #include <QString> #include "globals.h" +#include "CallManager.hpp" #include "CallStatus.hpp" #include "CallStatusFactory.hpp" #include "PhoneLine.hpp" @@ -128,7 +130,7 @@ PermanentRequest::onEntry(Call call, void PermanentRequest::onSuccess(Call call, - const QString &, + const QString &, const QString &message) { PhoneLine *line = PhoneLineManager::instance().getLine(call); @@ -182,3 +184,69 @@ TemporaryRequest::onSuccess(Call call, call.id().toStdString().c_str()); } } + +CallRequest::CallRequest(const QString &sequenceId, + const QString &command, + const std::list< QString > &args) + : AccountRequest(sequenceId, command, args) +{ + + std::list< QString >::const_iterator pos = args.begin(); + pos++; + mCallId = *pos; +} + +void +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(); + } + else { + _debug("We received an error on a call " + "that doesn't have a phone line (%s).\n", + mCallId.toStdString().c_str()); + } +} + +void +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); + } + else { + _debug("We received a status on a call related request " + "that doesn't have a phone line (%s).\n", + mCallId.toStdString().c_str()); + } +} + +void +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); + } + else { + _debug("We received a success on a call related request " + "that doesn't have a phone line (%s).\n", + mCallId.toStdString().c_str()); + } +} diff --git a/src/gui/official/SFLRequest.hpp b/src/gui/official/SFLRequest.hpp index 62b800043b825785ede96fdfe0e19368447cb0f8..3d7ff71eda1b3d8373263bb88d542fe5391f7c45 100644 --- a/src/gui/official/SFLRequest.hpp +++ b/src/gui/official/SFLRequest.hpp @@ -77,6 +77,44 @@ public: }; +class CallRequest : public AccountRequest +{ + public: + CallRequest(const QString &sequenceId, + const QString &command, + const std::list< QString > &args); + + /** + * This function will be called when the request + * receive its answer, if the request didn't successfully + * ended. + */ + virtual void onError(Account account, + const QString &code, + const QString &message); + + /** + * This function will be called when the request + * receive an answer, but there's other answers to come. + */ + virtual void onEntry(Account account, + const QString &code, + const QString &message); + + /** + * This function will be called when the request + * receive its answer, if the request successfully + * ended. + */ + virtual void onSuccess(Account account, + const QString &code, + const QString &message); + +private: + QString mCallId; +}; + + class PermanentRequest : public CallRelatedRequest { public: