📄 requestconfig.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 "requestconfig.h"#include "guiserver.h"#include "subcall.h"ResponseMessageRequestGetEvents::execute(){ GUIServer::instance().getEvents(_sequenceId); return message("000", "OK");}ResponseMessageRequestZeroconf::execute(){ if (GUIServer::instance().getZeroconf(_sequenceId)) { return message("200", "OK"); } else { return message("501","Zeroconf not enabled or activated"); }}ResponseMessageRequestZeroconfEvent::execute(){ if (GUIServer::instance().attachZeroconfEvents(_sequenceId, *this)) { return message("000", "Zeroconf Events are running"); } else { return message("501","Zeroconf not enabled or activated"); }}RequestZeroconfEvent::~RequestZeroconfEvent() { GUIServer::instance().detachZeroconfEvents(*this);}voidRequestZeroconfEvent::update(){ TokenList tk; tk.push_back("New Zeroconf events - Not Implemented"); GUIServer::instance().sendMessage("100", _sequenceId, tk);}ResponseMessageRequestCallStatus::execute(){ GUIServer::instance().sendGetEventsEnd(); TokenList tk; tk.push_back("OK"); std::string code = "206"; GUIServer::instance().getCallStatus(_sequenceId); std::string callid; if (GUIServer::instance().getCurrentCallId(callid)) { tk.push_front(callid); } else { code = "205"; } return message(code, tk);}ResponseMessageRequestConfigGetAll::execute(){ if (GUIServer::instance().getConfigAll(_sequenceId)) { return message("200", "OK"); } else { return message("500","Server Error"); }}RequestConfigGet::RequestConfigGet(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList){ TokenList::iterator iter = _argList.begin(); bool argsAreValid = false; if (iter != _argList.end()) { _section = *iter; _argList.pop_front(); iter = _argList.begin(); if (iter != _argList.end()) { _name = *iter; _argList.pop_front(); argsAreValid = true; } } if (!argsAreValid) { throw RequestConstructorException(); }}ResponseMessageRequestConfigGet::execute(){ TokenList arg; if (GUIServer::instance().getConfig(_section, _name, arg)) { return message("200", arg); } else { // 402 seq10001 Variable unknown return message("402","Variable unknown"); }}RequestConfigSet::RequestConfigSet(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList){ TokenList::iterator iter = _argList.begin(); // get three strings arguments bool argsAreValid = false; if (iter != _argList.end()) { _section = *iter; _argList.pop_front(); iter = _argList.begin(); if (iter != _argList.end()) { _name = *iter; _argList.pop_front(); iter = _argList.begin(); if (iter != _argList.end()) { _value = *iter; _argList.pop_front(); argsAreValid = true; } else { _value = ""; argsAreValid = true; } } } if (!argsAreValid) { throw RequestConstructorException(); }}ResponseMessageRequestConfigSet::execute(){ if (GUIServer::instance().setConfig(_section, _name, _value)) { return message("200", "OK"); } else { return message("500","Server Error"); }}ResponseMessageRequestConfigSave::execute(){ if (GUIServer::instance().saveConfig()) { return message("200", "Config saved"); } else { return message("400","Error Unable to save the configuration"); }}RequestList::RequestList(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList){ TokenList::iterator iter = _argList.begin(); if (iter != _argList.end()) { _name = *iter; _argList.pop_front(); } else { throw RequestConstructorException(); }}ResponseMessageRequestList::execute(){ if (GUIServer::instance().getConfigList(_sequenceId, _name)) { return message("200", "OK"); } else { return message("500","Server Error"); }}RequestVolumeSpkr::RequestVolumeSpkr(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList){ TokenList::iterator iter = _argList.begin(); bool error = true; if (iter != _argList.end()) { _percent = atoi(iter->c_str()); if (_percent >= 0 && _percent <= 100) { _argList.pop_front(); error = false; } } if (error) { throw RequestConstructorException(); }}ResponseMessageRequestVolumeSpkr::execute(){ if (GUIServer::instance().setSpkrVolume(_percent)) { return message("200", "OK"); } else { return message("500","Server Error"); }}RequestVolumeMic::RequestVolumeMic(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList){ TokenList::iterator iter = _argList.begin(); bool error = true; if (iter != _argList.end()) { _percent = atoi(iter->c_str()); if (_percent >= 0 && _percent <= 100) { _argList.pop_front(); error = false; } } if (error) { throw RequestConstructorException(); }}ResponseMessageRequestVolumeMic::execute(){ if (GUIServer::instance().setMicVolume(_percent)) { return message("200", "OK"); } else { return message("500","Server Error"); }}ResponseMessageRequestRegister::execute(){ if (GUIServer::instance().registerVoIPLink()) { return message("200", "OK"); } else { return message("500","Registration sending failed"); }}ResponseMessageRequestUnregister::execute(){ if (GUIServer::instance().unregisterVoIPLink()) { return message("200", "OK"); } else { return message("500","Unregistration sending failed"); }}RequestSwitch::RequestSwitch(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList){ TokenList::iterator iter = _argList.begin(); if (iter != _argList.end()) { _switchName = *iter; } else { throw RequestConstructorException(); }}ResponseMessageRequestSwitch::execute(){ if (GUIServer::instance().setSwitch(_switchName)) { return message("200", "OK"); } else { return message("500","Server Error"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -