Skip to content
Snippets Groups Projects
Commit a395bfe0 authored by jpbl's avatar jpbl
Browse files

mute is now a normal request

parent 7d2bb150
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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
......
......@@ -133,6 +133,7 @@ PhoneLineManagerImpl::closeSession()
emit lineStatusSet("");
emit bufferStatusSet("");
emit actionSet("");
emit globalStatusSet("Disconnected.");
}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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,
......
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment