File indexing completed on 2024-04-14 14:32:07

0001 //
0002 // C++ Implementation: cscriptapi
0003 //
0004 // Description: Scripting API - functions exported to the scripts.
0005 //
0006 /*
0007 Copyright 2010-2011 Tomas Mecir <kmuddy@kmuddy.com>
0008 
0009 This program is free software; you can redistribute it and/or
0010 modify it under the terms of the GNU General Public License as
0011 published by the Free Software Foundation; either version 2 of 
0012 the License, or (at your option) any later version.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #include "cscriptapi.h"
0024 #include "cactionmanager.h"
0025 #include "cvariablelist.h"
0026 
0027 cScriptAPI::cScriptAPI (int sess) : cActionBase ("scriptapi", sess)
0028 {
0029 }
0030 
0031 void cScriptAPI::message (QString msg)
0032 {
0033   invokeEvent ("message", sess(), msg);
0034 }
0035 
0036 void cScriptAPI::send (QString command)
0037 {
0038   invokeEvent ("command", sess(), command);
0039 }
0040 
0041 void cScriptAPI::sendraw (QString command)
0042 {
0043   invokeEvent ("send-command", sess(), command);
0044 }
0045 
0046 QString cScriptAPI::get (QString name)
0047 {
0048   return varList()->getValue (name);
0049 }
0050 
0051 void cScriptAPI::set (QString name, QString value)
0052 {
0053   varList()->set (name, value);
0054 }
0055 
0056 cVariableList *cScriptAPI::varList ()
0057 {
0058   cActionManager *am = cActionManager::self();
0059   return dynamic_cast<cVariableList *>(am->object ("variables", sess()));
0060 }
0061 
0062 #include "moc_cscriptapi.cpp"