File indexing completed on 2024-09-08 03:45:13
0001 /*************************************************************************** 0002 cscript.cpp - one script 0003 ------------------- 0004 begin : So dec 7 2002 0005 copyright : (C) 2002 by Tomas Mecir 0006 email : kmuddy@kmuddy.com 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #include "cscript.h" 0019 0020 #include <qdir.h> 0021 #include <kconfig.h> 0022 #include <kconfiggroup.h> 0023 0024 cScript::cScript (int _sess) : sess(_sess) 0025 { 0026 //set some defaults... 0027 name = ""; //name must be set before script can be executed... 0028 comment = ""; 0029 command = ""; 0030 workdir = QDir::homePath (); 0031 prefix = ""; 0032 suffix = ""; 0033 enableinput = true; 0034 enablestdout = true; 0035 sendstdout = true; 0036 enablestderr = false; 0037 sendstderr = false; 0038 sendusercommands = false; 0039 useadvcomm = false; 0040 allowparams = true; 0041 singleinstance = false; 0042 shellexpansion = true; 0043 noflowcontrol = false; 0044 allowvars = false; 0045 onlyifmatch = true; 0046 } 0047 0048 cScript::~cScript() 0049 { 0050 //nothing here 0051 } 0052 0053 cSaveableField *cScript::newInstance () 0054 { 0055 return new cScript (sess); 0056 } 0057 0058 void cScript::load (KConfig *config, const QString &group) 0059 { 0060 KConfigGroup g = config->group (group); 0061 name = g.readEntry ("Name", ""); 0062 comment = g.readEntry ("Comment", ""); 0063 command = g.readEntry ("Command", ""); 0064 workdir = g.readEntry ("Workdir", QDir::homePath ()); 0065 prefix = g.readEntry ("Prefix", ""); 0066 suffix = g.readEntry ("Suffix", ""); 0067 enableinput = g.readEntry ("Enable input", true); 0068 enablestdout = g.readEntry ("Enable output", true); 0069 sendstdout = g.readEntry ("Send output", true); 0070 enablestderr = g.readEntry ("Include stderr", false); 0071 sendstderr = g.readEntry ("Send stderr", false); 0072 sendusercommands = g.readEntry ("Send user commands", false); 0073 useadvcomm = g.readEntry ("Use advanced communication", false); 0074 allowparams = g.readEntry ("Allow parameters", true); 0075 singleinstance = g.readEntry ("Single instance", false); 0076 shellexpansion = g.readEntry ("Shell expansion", true); 0077 noflowcontrol = g.readEntry ("No flow control", false); 0078 allowvars = g.readEntry ("Communicate variables", false); 0079 0080 setText (g.readEntry ("Text", "")); 0081 setType (g.readEntry ("Type", (int)substring)); 0082 onlyifmatch = g.readEntry ("Only if match", true); 0083 } 0084