Commit 1fb571db authored by jpbl's avatar jpbl

trying to fix CallRequest

parent bf6b68be
......@@ -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;
......
......@@ -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"));
......
#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());
}
}
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment