diff --git a/src/gui/server/guiserverimpl.cpp b/src/gui/server/guiserverimpl.cpp index e8c1641ec6c09a5dc93e574ab1ece0364581a974..c9fc79525d6b5fe8fbb7eedcd7fce89e95b8194b 100644 --- a/src/gui/server/guiserverimpl.cpp +++ b/src/gui/server/guiserverimpl.cpp @@ -162,6 +162,19 @@ GUIServerImpl::refuseCall(const std::string& callId) } return false; } +bool +GUIServerImpl::transferCall(const std::string& callId, const std::string& to) +{ + try { + short id = getIdFromCallId(callId); + if (GuiFramework::transferCall(id, to)) { + return true; + } + } catch(...) { + return false; + } + return false; +} bool GUIServerImpl::holdCall(const std::string& callId) diff --git a/src/gui/server/guiserverimpl.h b/src/gui/server/guiserverimpl.h index 6f4e952462e16440107c3b0e10bc20e174cae8bb..0d16532d3607041a706d073ff82ed29354d2eaba 100644 --- a/src/gui/server/guiserverimpl.h +++ b/src/gui/server/guiserverimpl.h @@ -75,6 +75,7 @@ arg); bool holdCall(const std::string& callId); bool unholdCall(const std::string& callId); bool hangupCall(const std::string& callId); + bool transferCall(const std::string& callId, const std::string& to); bool dtmfCall(const std::string& callId, const std::string& dtmfKey); bool hangupAll(); bool getCurrentCallId(std::string& callId); diff --git a/src/gui/server/request.cpp b/src/gui/server/request.cpp index bf08c80669734e4705176de3842946ed52d7692e..8c2913791779fd6d2e6795d056cd0f514645ccb0 100644 --- a/src/gui/server/request.cpp +++ b/src/gui/server/request.cpp @@ -66,10 +66,30 @@ RequestUnhold::execute() return message("500","Server Error"); } +RequestTransfer::RequestTransfer(const std::string &sequenceId, + const TokenList& argList) : RequestGlobalCall(sequenceId, argList) +{ + TokenList::iterator iter = _argList.begin(); + + // check for the transfer destination + bool argsAreValid = false; + if (iter != _argList.end()) { + _destination = *iter; + _argList.pop_front(); + argsAreValid = true; + } + if (!argsAreValid) { + throw RequestConstructorException(); + } +} + ResponseMessage RequestTransfer::execute() { - return message("200","TODO"); + if ( GUIServer::instance().transferCall(_callId, _destination) ) { + return message("200", "OK"); + } + return message("500","Server Error"); } ResponseMessage diff --git a/src/gui/server/request.h b/src/gui/server/request.h index d8f131764f4053f4ebbbbb0630eefebd9d91e12a..4d2663f4071ec1e46d48420d2e4dc7df22b2b037 100644 --- a/src/gui/server/request.h +++ b/src/gui/server/request.h @@ -136,8 +136,10 @@ public: }; class RequestTransfer : public RequestGlobalCall { public: - RequestTransfer(const std::string &sequenceId, const TokenList& argList) : RequestGlobalCall(sequenceId,argList) {} + RequestTransfer(const std::string &sequenceId, const TokenList& argList); ResponseMessage execute(); +private: + std::string _destination; }; class RequestHangup : public RequestGlobalCall { public: diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 0dc578b259635e7e541b77cfb2fce8a0aca16ec2..3e1910d37b3d0013f27de91e316c7e877ce47564 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -405,7 +405,8 @@ ManagerImpl::answerCall (short id) call->setStatus(string(CONNECTED_STATUS)); call->setState(Answered); ringtone(false); - setCurrentCallId(id); + + switchCall(id); return call->answer(); } @@ -676,8 +677,8 @@ ManagerImpl::peerAnsweredCall (short id) call->setState(Answered); //if (isCurrentId(id)) { - setCurrentCallId(id); - _gui->peerAnsweredCall(id); + switchCall(id); + _gui->peerAnsweredCall(id); //} } @@ -1297,4 +1298,14 @@ ManagerImpl::getConfigList(const std::string& sequenceId, const std::string& nam return returnValue; } +void +ManagerImpl::switchCall(short id) +{ + short currentCallId = getCurrentCallId(); + if (currentCallId!=0 && id!=currentCallId) { + onHoldCall(currentCallId); + } + setCurrentCallId(id); +} + // EOF diff --git a/src/managerimpl.h b/src/managerimpl.h index 5ba2947b113e9eef1a4f9a90d984792d8e912214..88589f66703c9ec6ee08d3f6f8c922c19c0c89d1 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -379,6 +379,8 @@ private: Conf::ConfigTree _config; + void switchCall(short id); + #ifdef USE_ZEROCONF // DNSService contain every zeroconf services // configuration detected on the network