Smt_Uint TBaseDevice::OnCmdHangupCall(Smt_Pdu &pdu) { Smt_Uint channel; pdu.GetUint(Key_IVR_ChannelID, &channel); if(!CheckUserAndChannel(channel))return Smt_Fail; HangupCall(channel); return Smt_Success; }
GenericOfferAnswerSession::~GenericOfferAnswerSession(void) { FUNCTRACKER; StopActiveObjectLwProc(); HangupCall(); }
ApiErrorCode GenericOfferAnswerSession::MakeCall(IN const string &destination_uri, IN const AbstractOffer &offer, IN const Credentials &credentials, IN OUT MapOfAny &key_value_map, IN csp::Time ring_timeout) { FUNCTRACKER; LogDebug("GenericOfferAnswerSession::MakeCall dst:" << destination_uri << ", type:" << offer.GetType() << ", subtype:" << offer.GetSubType() << ", offer:\n" << offer.body ); if (_callState != CALL_STATE_UNKNOWN) { LogWarn("GenericOfferAnswerSession::MakeCall - wrong state"); return API_FAILURE; } CALL_RESET_STATE(CALL_STATE_OFFERING); IwMessagePtr response = NULL_MSG; MsgMakeCallReq *msg = new MsgMakeCallReq(); msg->destination_uri = destination_uri; msg->localOffer = offer; msg->call_handler_inbound = _handlerPair.inbound; msg->stack_call_handle = _iwCallHandle; msg->optional_params = key_value_map; msg->credentials = credentials; _localOffer = offer; ApiErrorCode res = API_SUCCESS; // wait for ok or nack res = GetCurrRunningContext()->DoRequestResponseTransaction( _serviceHandleId, IwMessagePtr(msg), response, ring_timeout, "GenericOfferAnswerSession::MakeCall TXN"); if (res == API_TIMEOUT) { // just to be sure that timeout-ed call // eventually gets hanged up LogWarn("GenericOfferAnswerSession::MakeCall - Timeout."); HangupCall(); return API_TIMEOUT; } if (IW_FAILURE(res)) { LogWarn("GenericOfferAnswerSession::MakeCall - failure res:" << res); CALL_RESET_STATE(CALL_STATE_UNKNOWN); return API_SERVER_FAILURE; } switch (response->message_id) { case MSG_MAKE_CALL_OK: { break; } case MSG_MAKE_CALL_NACK: { CALL_RESET_STATE(CALL_STATE_UNKNOWN); return API_SERVER_FAILURE; break; } default: { throw; } } shared_ptr<MsgMakeCallOk> make_call_ok = dynamic_pointer_cast<MsgMakeCallOk>(response); LogDebug("GenericOfferAnswerSession::MakeCall remote:" << make_call_ok->remoteOffer.body); _remoteOffer = make_call_ok->remoteOffer; _iwCallHandle = make_call_ok->stack_call_handle; _dnis = destination_uri; _ani = make_call_ok->ani; if (!_localOffer.body.empty()) CALL_RESET_STATE(CALL_STATE_CONNECTED); else CALL_RESET_STATE(CALL_STATE_REMOTE_OFFERED); return res; }
ApiErrorCode GenericOfferAnswerSession::Answer(IN const AbstractOffer &offer, IN const MapOfAny &key_value_map, IN csp::Time ring_timeout) { FUNCTRACKER; LogDebug("enericOfferAnswerSession::Answer iwh:" << _iwCallHandle << " type=" << offer.type << ", body=" << offer.body); if (_callState != CALL_STATE_INITIAL_OFFERED && _callState != CALL_STATE_REMOTE_OFFERED ) { LogWarn("Answer:: wrong call state:" << _callState << ", iwh:" << _iwCallHandle); return API_WRONG_STATE; } _localOffer = offer; IwMessagePtr response = NULL_MSG; if (_uac) { MsgNewCallConnected *ack = new MsgNewCallConnected(); ack->stack_call_handle = _iwCallHandle; ack->localOffer = offer; ApiErrorCode res = GetCurrRunningContext()->SendMessage( _serviceHandleId, IwMessagePtr(ack)); CALL_RESET_STATE(CALL_STATE_CONNECTED); return res; } MsgCalOfferedAck *ack = new MsgCalOfferedAck(); ack->stack_call_handle = _iwCallHandle; ack->localOffer = offer; ApiErrorCode res = GetCurrRunningContext()->DoRequestResponseTransaction( _serviceHandleId, IwMessagePtr(ack), response, MilliSeconds(GetCurrRunningContext()->TransactionTimeout()), "Accept GenericOfferAnswerSession TXN"); if (IW_FAILURE(res)) { return res; } switch (response->message_id) { case MSG_CALL_CONNECTED: { shared_ptr<MsgNewCallConnected> make_call_sucess = dynamic_pointer_cast<MsgNewCallConnected>(response); _iwCallHandle = make_call_sucess->stack_call_handle; break; } default: { HangupCall(); return API_SERVER_FAILURE; } } CALL_RESET_STATE(CALL_STATE_CONNECTED); return res; }
ApiErrorCode GenericOfferAnswerSession::ReOffer( IN const AbstractOffer &localOffer, IN OUT MapOfAny &keyValueMap, IN csp::Time ringTimeout) { FUNCTRACKER; LogDebug("GenericOfferAnswerSession::ReOffer offer:\n" << localOffer.body); if (localOffer.body.empty()) { return API_WRONG_PARAMETER; } if (_callState != CALL_STATE_CONNECTED) { return API_WRONG_STATE; } CALL_RESET_STATE(CALL_STATE_IN_DIALOG_OFFERED); IwMessagePtr response = NULL_MSG; MsgCallReofferReq *msg = new MsgCallReofferReq(); msg->localOffer = localOffer; msg->stack_call_handle = _iwCallHandle; msg->optional_params = keyValueMap; ApiErrorCode res = API_SUCCESS; // wait for ok or nack res = GetCurrRunningContext()->DoRequestResponseTransaction( _serviceHandleId, IwMessagePtr(msg), response, ringTimeout, "GenericOfferAnswerSession::ReOffer TXN"); if (res == API_TIMEOUT) { // just to be sure that timeout-ed call // eventually gets hanged up LogWarn("GenericOfferAnswerSession::ReOffer - Timeout."); HangupCall(); return API_TIMEOUT; } if (IW_FAILURE(res)) { LogWarn("GenericOfferAnswerSession::ReOffer - failure res:" << res); HangupCall(); return API_SERVER_FAILURE; } switch (response->message_id) { case MSG_CALL_REOFFER_ACK: { _localOffer = localOffer; break; } default: { CALL_RESET_STATE(CALL_STATE_CONNECTED); return API_SERVER_FAILURE; } } shared_ptr<MsgCallReofferAck> make_call_ok = dynamic_pointer_cast<MsgCallReofferAck>(response); LogDebug("GenericOfferAnswerSession::ReOffer remote:" << make_call_ok->remoteOffer.body); _remoteOffer = make_call_ok->remoteOffer; CALL_RESET_STATE(CALL_STATE_CONNECTED); return res; }