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

better tone handling and better answering

parent 5402e58e
No related branches found
No related tags found
No related merge requests found
......@@ -268,14 +268,23 @@ PhoneLine::answer()
}
void
PhoneLine::hangup()
PhoneLine::hangup(bool sendrequest)
{
if(sendrequest) {
setAction(tr("Hanguping..."));
}
else {
setAction(tr("Hanguped."));
}
if(mCall) {
setAction("Hanguping...");
DebugOutput::instance() << tr("PhoneLine %1: Trying to Hangup.\n").arg(mLine);
mCall->hangup();
delete mCall;
mCall = NULL;
if(sendrequest) {
mCall->hangup();
}
else {
delete mCall;
mCall = NULL;
}
}
else {
clear();
......
......@@ -21,7 +21,7 @@ public:
void call(const QString &to);
void call();
void answer();
void hangup();
void hangup(bool sendrequest = true);
void hold();
void unhold();
......
......@@ -424,12 +424,13 @@ PhoneLineManagerImpl::hold()
mCurrentLineMutex.unlock();
if(selectedLine) {
mSession->stopTone();
selectedLine->hold();
}
}
void
PhoneLineManagerImpl::hangup()
PhoneLineManagerImpl::hangup(bool sendrequest)
{
mCurrentLineMutex.lock();
PhoneLine *selectedLine = mCurrentLine;
......@@ -438,7 +439,8 @@ PhoneLineManagerImpl::hangup()
mCurrentLineMutex.unlock();
if(selectedLine) {
selectedLine->hangup();
mSession->stopTone();
selectedLine->hangup(sendrequest);
lineStatusSet("");
}
}
......@@ -471,22 +473,24 @@ PhoneLineManagerImpl::unmute()
}
void
PhoneLineManagerImpl::hangup(const QString &callId)
PhoneLineManagerImpl::hangup(const QString &callId, bool sendrequest)
{
PhoneLine *selectedLine = getPhoneLine(callId);
if(selectedLine) {
mSession->stopTone();
PhoneLineLocker guard(selectedLine);
selectedLine->hangup();
selectedLine->hangup(sendrequest);
}
}
void
PhoneLineManagerImpl::hangup(unsigned int line)
PhoneLineManagerImpl::hangup(unsigned int line, bool sendrequest)
{
PhoneLine *selectedLine = getPhoneLine(line);
if(selectedLine) {
mSession->stopTone();
PhoneLineLocker guard(selectedLine);
selectedLine->hangup();
selectedLine->hangup(sendrequest);
}
}
......@@ -505,8 +509,8 @@ PhoneLineManagerImpl::clear()
void
PhoneLineManagerImpl::incomming(const QString &accountId,
const QString &peer,
const QString &callId)
const QString &callId,
const QString &peer)
{
Call call(mSession->id(), accountId, callId, true);
addCall(call, peer, "Incomming");
......
......@@ -95,7 +95,7 @@ public slots:
* This function will hanp up the current line
* If there's no current line, it will do nothing.
*/
void hangup();
void hangup(bool sendrequest = true);
/**
* This function will mute the microphone if muting
......@@ -118,14 +118,14 @@ public slots:
* argument. Be aware that the first line is 1, not
* zero.
*/
void hangup(unsigned int line);
void hangup(unsigned int line, bool sendrequest = true);
/**
* This function will hanp up the line with the
* following call ID. If there's no line with
* the call ID, it will do nothing.
*/
void hangup(const QString &callId);
void hangup(const QString &callId, bool sendrequest = true);
/**
* This function will make a call on the
......
......@@ -28,7 +28,7 @@ HangupEvent::execute()
if(id.length() > 0) {
DebugOutput::instance() << QObject::tr("Hangup Event received for call ID: %1.\n")
.arg(id);
PhoneLineManager::instance().hangup(id);
PhoneLineManager::instance().hangup(id, false);
}
else {
DebugOutput::instance() << QObject::tr("Hangup Event invalid (missing call ID): %1\n")
......
......@@ -20,6 +20,7 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv)
PhoneLineManager::instance().initialize();
PhoneLineManager::instance().setNbLines(NB_PHONELINES);
Requester::instance().registerObject< Request >(QString("playtone"));
Requester::instance().registerObject< Request >(QString("stoptone"));
Requester::instance().registerObject< Request >(QString("playdtmf"));
Requester::instance().registerObject< CallRequest >(QString("call"));
Requester::instance().registerObject< EventRequest >(QString("getevents"));
......
......@@ -49,6 +49,12 @@ Session::playTone() const
return Requester::instance().send(mId, "playtone", std::list< QString >());
}
QString
Session::stopTone() const
{
return Requester::instance().send(mId, "stoptone", std::list< QString >());
}
void
Session::connect() const
{
......
......@@ -83,6 +83,7 @@ class Session
void connect() const;
QString id() const;
QString stopTone() const;
QString playTone() const;
private:
......
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