From 417202343b64947e80dbe14b4ab456cc6442e88c Mon Sep 17 00:00:00 2001 From: thlo Date: Sun, 1 Sep 2013 21:09:15 +0200 Subject: New enable flag for RecCmds and new Port parameter in smarttvweb.conf. Bug fixes. --- httpclient.c | 3 +-- httpresource.c | 19 ++++++++++++++++++- responsememblk.c | 9 ++++++++- smarttvfactory.c | 9 +++++++-- smarttvweb.conf | 5 +++++ stvw_cfg.c | 14 ++++++++++++-- stvw_cfg.h | 4 ++++ 7 files changed, 55 insertions(+), 8 deletions(-) diff --git a/httpclient.c b/httpclient.c index a3fb192..722a659 100644 --- a/httpclient.c +++ b/httpclient.c @@ -364,7 +364,6 @@ string cHttpYtPushClient::getMsgBody(int) { //------------------------------ cHttpCfgPushClient::cHttpCfgPushClient(int f, int id, int port, SmartTvServer* fac, string peer) : cHttpClientBase(f, id, port, fac, peer) { - createRequestMessage(""); } @@ -403,5 +402,5 @@ cHttpMesgPushClient::~cHttpMesgPushClient() { } string cHttpMesgPushClient::getMsgBody(int) { - return "{\"type\":\"MESG\",payload:" + mMesg +"}";; + return "{\"type\":\"MESG\",payload:\"" + mMesg +"\"}";; } diff --git a/httpresource.c b/httpresource.c index fcb7f82..24645bf 100755 --- a/httpresource.c +++ b/httpresource.c @@ -352,6 +352,14 @@ int cHttpResource::processRequest() { } //thlo for testing purpose +/* + if (mPath.compare("/modifyTimer") == 0) { + mResponse = new cResponseMemBlk(this); + ((cResponseMemBlk*)mResponse)->receiveModTimerReq(); + return OKAY; + } +*/ + //thlo for testing purpose if (mPath.compare("/addTimer") == 0) { mResponse = new cResponseMemBlk(this); ((cResponseMemBlk*)mResponse)->receiveAddTimerReq(); @@ -453,13 +461,22 @@ int cHttpResource::processRequest() { } } - if (mPath.find("/web/") == 0) { + if (mPath.find("/web/", 0, 5) == 0) { mPath = mFactory->getConfigDir() + mPath; *(mLog->log())<< DEBUGPREFIX << " Found web request. serving " << mPath << endl; ok_to_serve = true; } + if (mPath.find("/live/", 0, 6) == 0) { + *(mLog->log())<< DEBUGPREFIX + << " Found live request. serving " << mPath << endl; + //mResponse = new cResponseLive(this, mPath.substr(6)); + //((cResponseVdrDir*)mResponse)->sendMediaSegment( &statbuf); + return OKAY; + + } + if (mPath.compare(0, strlen(VideoDirectory), VideoDirectory) == 0) { *(mLog->log())<< DEBUGPREFIX << " Found video dir request. serving " << mPath << endl; diff --git a/responsememblk.c b/responsememblk.c index f77f950..292dabb 100755 --- a/responsememblk.c +++ b/responsememblk.c @@ -1172,7 +1172,6 @@ void cResponseMemBlk::sendRecCmds() { void cResponseMemBlk::receiveExecRecCmdReq() { vector avps; - mRequest->parseQueryLine(&avps); string guid; string cmd_str; uint cmdid; @@ -1180,6 +1179,14 @@ void cResponseMemBlk::receiveExecRecCmdReq() { if (isHeadRequest()) return; + if (! mRequest->mFactory->getConfig()->getRecCmds()) { + sendError(400, "Bad Request", NULL, "017 execreccmd disabled."); + return; + + } + mRequest->parseQueryLine(&avps); + + if (mRequest->getQueryAttributeValue(&avps, "guid", guid) != OKAY){ sendError(400, "Bad Request", NULL, "002 No guid in query line"); return; diff --git a/smarttvfactory.c b/smarttvfactory.c index b281a61..94242e6 100755 --- a/smarttvfactory.c +++ b/smarttvfactory.c @@ -713,9 +713,14 @@ void SmartTvServer::initServer(string dir) { #ifndef STANDALONE mConfig = new cSmartTvConfig(dir); + serverPort = mConfig->getServerPort(); mLog.init(mConfig->getLogFile()); - esyslog("SmartTvWeb: Logfile created"); - + + if (mConfig->getLogFile() != "") { + string msg = "SmartTvWeb: Logfile created File= " + mConfig->getLogFile(); + // esyslog("SmartTvWeb: Logfile created"); + esyslog(msg.c_str()); + } *(mLog.log()) << "LogFile= " << mConfig->getLogFile() << endl; initRecCmds(); diff --git a/smarttvweb.conf b/smarttvweb.conf index 07920dc..10adaa7 100644 --- a/smarttvweb.conf +++ b/smarttvweb.conf @@ -26,3 +26,8 @@ GroupSeparators Ignore # Bind the web server to a specific IP address. Otherwise, the Web Server is listening on ALL interfaces. #ServerAddress 127.0.0.1 +# Bind the web server to a specific port. Default is Port 8000. +#ServerPort 8000 + +# Allow execution of reccmd.conf defined programs through the widget. Ensure that only authorized hosts get access to the plugin (e.g. firewall protected). +#RecCmds enable diff --git a/stvw_cfg.c b/stvw_cfg.c index 75b8de6..2c805ea 100755 --- a/stvw_cfg.c +++ b/stvw_cfg.c @@ -33,7 +33,7 @@ cSmartTvConfig::cSmartTvConfig(string d): mConfigDir(d), mLog(NULL), mCfgFile(NULL), mLogFile(), mMediaFolder(), mSegmentDuration(), mHasMinBufferTime(), mHasBitrateCorrection(), - mLiveChannels(), mGroupSep(IGNORE), mServerAddress("") { + mLiveChannels(), mGroupSep(IGNORE), mServerAddress(""), mServerPort(8000), mRecCmds(false) { #ifndef STANDALONE mLogFile= ""; @@ -140,7 +140,17 @@ void cSmartTvConfig::readConfig() { if (strcmp(attr, "ServerAddress") == 0) { mServerAddress = value; - // cout << " Found mLiveChannels= " <