📄 request.cpp
字号:
/** * Copyright (C) 2005 Savoir-Faire Linux inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#include "request.h"#include "guiserver.h"#include "subcall.h"ResponseMessageRequestCall::execute(){ if ( GUIServer::instance().outgoingCall(_sequenceId, _callId, _destination) ) { return message("150", "Trying"); } return message("500","Server Error");}ResponseMessageRequestAnswer::execute(){ if ( GUIServer::instance().answerCall(_callId) ) { return message("200", "OK"); } return message("500","Server Error");}ResponseMessageRequestRefuse::execute(){ if ( GUIServer::instance().refuseCall(_callId) ) { return message("200", "OK"); } return message("500","Server Error");}ResponseMessageRequestHold::execute(){ if ( GUIServer::instance().holdCall(_callId) ) { return message("200", "Held"); } return message("500","Server Error");}ResponseMessageRequestUnhold::execute(){ if ( GUIServer::instance().unholdCall(_callId) ) { return message("200", "Unheld"); } 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(); }}ResponseMessageRequestTransfer::execute(){ if ( GUIServer::instance().transferCall(_callId, _destination) ) { return message("200", "Transfered"); } return message("500","Server Error");}ResponseMessageRequestHangup::execute(){ if ( GUIServer::instance().hangupCall(_callId) ) { return message("200", "Hungup"); } return message("500", "Hangup Error");}ResponseMessageRequestHangupAll::execute(){ if ( GUIServer::instance().hangupAll() ) { return message("200", "All hungup"); } return message("500", "Hangup Error");}RequestDTMF::RequestDTMF(const std::string &sequenceId, const TokenList& argList) : RequestGlobalCall(sequenceId, argList){ TokenList::iterator iter = _argList.begin(); // check for the dtmf key bool argsAreValid = false; if (iter != _argList.end() && (*iter).length()==1) { _dtmfKey = *iter; _argList.pop_front(); argsAreValid = true; } if (!argsAreValid) { throw RequestConstructorException(); }}ResponseMessageRequestDTMF::execute(){ if ( GUIServer::instance().dtmfCall(_callId, _dtmfKey) ) { return message("200", "OK"); } return message("500", "DTMF Error");}RequestPlayDtmf::RequestPlayDtmf(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId, argList){ TokenList::iterator iter = _argList.begin(); // check for the dtmf key bool argsAreValid = false; if (iter != _argList.end() && (*iter).length()==1) { _dtmfKey = *iter; _argList.pop_front(); argsAreValid = true; } if (!argsAreValid) { throw RequestConstructorException(); }}ResponseMessageRequestPlayDtmf::execute(){ if ( GUIServer::instance().playDtmf(_dtmfKey[0]) ) { return message("200", "OK"); } return message("500", "DTMF Error");}ResponseMessageRequestPlayTone::execute(){ if ( GUIServer::instance().playTone() ) { return message("200", "OK"); } return message("500", "Tone Error");}ResponseMessageRequestStopTone::execute(){ if ( GUIServer::instance().stopTone() ) { return message("200", "OK"); } return message("500", "Tone Error");}ResponseMessageRequestMute::execute(){ GUIServer::instance().mute(); return message("200","Muted");}ResponseMessageRequestUnmute::execute(){ GUIServer::instance().unmute(); return message("200","Unmuted");}ResponseMessageRequestVersion::execute(){ return message("200",GUIServer::instance().version());}ResponseMessageRequestQuit::execute(){ // GUIServer::instance().hangupAll(); don't hangup call, so we can do a netcat session that call someone GUIServer::instance().stopTone(); GUIServer::instance().quit(); return message("200", "Quitting");}ResponseMessageRequestStop::execute(){ GUIServer::instance().hangupAll(); GUIServer::instance().stopTone(); GUIServer::instance().stop(); return message("200", "Stopping server");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -