//OpenSCADA module UI.VCAEngine file: session.cpp /*************************************************************************** * Copyright (C) 2007-2021 by Roman Savochenko, * * * * 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; version 2 of the License. * * * * 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., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #include #include #include "vcaengine.h" #include "session.h" using namespace VCA; //************************************************ //* Session: Project's session * //************************************************ Session::Session( const string &iid, const string &iproj ) : mAlrmRes(true), mCalcRes(true), mDataRes(true), mId(iid), mPrjnm(iproj), mOwner("root"), mGrp("UI"), mUser(dataResSes()), mReqUser(dataResSes()), mReqLang(dataResSes()), mPer(100), mPerReal(0), mPermit(RWRWR_), mEnable(false), mStart(false), endrunReq(false), mBackgrnd(false), mConnects(0), mCalcClk(10), mReqTm(0), mUserActTm(0), mStyleIdW(-1) { mUser = "root"; mPage = grpAdd("pg_"); sec = SYS->security(); mReqTm = time(NULL); setUserActTm(); } Session::~Session( ) { modifClr(); for(map::iterator iN = mNotify.begin(); iN != mNotify.end(); ++iN) delete iN->second; } void Session::postEnable( int flag ) { if(flag&TCntrNode::NodeRestore) setEnable(true); } void Session::preDisable( int flag ) { if(enable()) setEnable(false); } void Session::setUser( const string &it ) { mUser = it; if(!enable()) mOwner = it; } void Session::setEnable( bool val ) { int64_t d_tm = 0; MtxAlloc res(mCalcRes, true); if(val == enable()) return; vector pg_ls; if(val) { mess_debug(nodePath().c_str(),_("Enabling the session.")); try { if(mess_lev() == TMess::Debug) d_tm = TSYS::curTime(); //Connecting and registering to the project mParent = mod->prjAt(mPrjnm); mParent.at().heritReg(this); //Getting data from the project mOwner = parent().at().owner(); mGrp = parent().at().grp(); mPermit = parent().at().permit(); setPeriod(parent().at().period()); //Loading the previous style string stVl = sessAttr("