summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthlo <smarttv640@gmail.com>2013-10-03 12:34:48 +0200
committerthlo <smarttv640@gmail.com>2013-10-03 12:34:48 +0200
commitda43351ba6ca31c3ad1cab41231ea7ff772b350f (patch)
tree948c95d51ea231f872f455e5015732b0e0e0123f
parentaaa2ea1a1d576dcad5397e4bc650a0efcdd860a4 (diff)
downloadvdr-plugin-smarttvweb-da43351ba6ca31c3ad1cab41231ea7ff772b350f.tar.gz
vdr-plugin-smarttvweb-da43351ba6ca31c3ad1cab41231ea7ff772b350f.tar.bz2
handling of commands.conf added. smarttvweb.conf parameter changed from reccmds to commands.
-rw-r--r--README.txt46
-rwxr-xr-xhttpresource.c17
-rwxr-xr-xresponsememblk.c83
-rwxr-xr-xresponsememblk.h2
-rwxr-xr-xsmarttvfactory.c17
-rwxr-xr-xsmarttvfactory.h11
-rw-r--r--smarttvweb.conf5
-rwxr-xr-xstvw_cfg.c6
-rwxr-xr-xstvw_cfg.h4
9 files changed, 167 insertions, 24 deletions
diff --git a/README.txt b/README.txt
index 01b3725..c6c4005 100644
--- a/README.txt
+++ b/README.txt
@@ -1,21 +1,43 @@
This VDR Project contains a server plugin and a Smart TV Widget.
-Folders:
-
-vdr-smarttvweb: Contains the vdr server plugin, incl. the web front end
-smarttv-client: Contains the source code of the Smart TV widget
-release: Contains Smart TV Widget files ready for deplyoment.
-
-Check http://projects.vdr-developer.org/projects/plg-smarttvweb/wiki for a description, installation instructions and configuration instructions.
-
-
History:
Widget Version 0.9.5:
* new widget.conf element playKeyBehavior, which is of Type Integer. 0: key value * 100 is target percentage, 1: key value is skip duration
-* new Server Select Menu item, which allows the re-selection of the VDR server
+* new Server Select Menu item, which allows the re-selection of the VDR server (note, the widget.conf is always )
* timezone correction
+* Rendering of an image for a recording, if the recording folder contains a preview_vdr.png file.
+* Toggle 3D viewing options (Side-by-Side and Top-to-Bottom)
+* Timer menu entry, which gives an overview of the timers and allows deletion of timers.
+* widget.conf configurable InfoOverlay timeout (new widget.conf entry <infoTimeout>)
+* YouTube entry becomes optional. Add <youtubemenu>true</youtubemenu> to your widget.conf
+* Image Viewer in Media Folder.
+* Improved server error feedback through widget GUI
+* Widget configurable Info Overlay timeout (<infoTimeout> element value).
+
+* Allow Verbose start for debugging.
+* Scrolling debug popup
+* Timer activation and deactivation
+* Key Binding helpoverlay using tools key
+* Code Improvements
+* Fixes in timer update handling (HTTP interactions)
+
+
+Plugin Version 0.9.9:
+* Provide server timestamp (To allow timezone check)
+* Provide server name to increase readability during server select
+* Provide time-sorted list of timers (/timers.xml)
+* Fixed deleteTimer function
+* Add function to activate and deactivate a timer.
+* Allow creation of partially overlapping timers.
+* First Version of Commands and Recording Commands (RecCmds) handling.
+* New API /deleteFile, which allows the deletion of a file from the media folder.
+
+
+Folders:
+vdr-smarttvweb: Contains the vdr server plugin, incl. the web front end
+smarttv-client: Contains the source code of the Smart TV widget
+release: Contains Smart TV Widget files ready for deplyoment.
-Plugin Version 0.9.8:
-* provide server timestamp
+Check http://projects.vdr-developer.org/projects/plg-smarttvweb/wiki for a description, installation instructions and configuration instructions.
diff --git a/httpresource.c b/httpresource.c
index 854cf96..7ab75af 100755
--- a/httpresource.c
+++ b/httpresource.c
@@ -326,6 +326,17 @@ int cHttpResource::processRequest() {
return OKAY;
}
+ if (mPath.compare("/cmds.xml") == 0) {
+ mResponse = new cResponseMemBlk(this);
+ ((cResponseMemBlk*)mResponse)->sendCmds();
+ return OKAY;
+ }
+ if (mPath.compare("/execcmd") == 0) {
+ mResponse = new cResponseMemBlk(this);
+ ((cResponseMemBlk*)mResponse)->receiveExecCmdReq();
+ return OKAY;
+ }
+
if (mPath.compare("/setResume.xml") == 0) {
mResponse = new cResponseMemBlk(this);
((cResponseMemBlk*)mResponse)->receiveResume();
@@ -670,6 +681,12 @@ int cHttpResource::handlePost() {
return OKAY;
}
+ if (mPath.compare("/execcmd") == 0) {
+ mResponse = new cResponseMemBlk(this);
+ ((cResponseMemBlk*)mResponse)->receiveExecCmdReq();
+ return OKAY;
+ }
+
if (mPath.compare("/deleteTimer.xml") == 0) {
mResponse = new cResponseMemBlk(this);
((cResponseMemBlk*)mResponse)->receiveDelTimerReq();
diff --git a/responsememblk.c b/responsememblk.c
index 5fe4118..2ac0a93 100755
--- a/responsememblk.c
+++ b/responsememblk.c
@@ -1277,6 +1277,20 @@ void cResponseMemBlk::sendRecCmds() {
sendHeaders(200, "OK", NULL, "application/xml", mResponseMessage->size(), -1);
}
+void cResponseMemBlk::sendCmds() {
+ *(mLog->log()) << DEBUGPREFIX << " sendCmds" << endl;
+
+ if (isHeadRequest())
+ return;
+
+ mResponseMessage = new string();
+ *mResponseMessage = mRequest->mFactory->getCmdCmdsMsg();
+ mResponseMessagePos = 0;
+ mRequest->mConnState = SERVING;
+
+ sendHeaders(200, "OK", NULL, "application/xml", mResponseMessage->size(), -1);
+}
+
void cResponseMemBlk::receiveExecRecCmdReq() {
vector<sQueryAVP> avps;
string guid;
@@ -1286,8 +1300,8 @@ void cResponseMemBlk::receiveExecRecCmdReq() {
if (isHeadRequest())
return;
- if (! mRequest->mFactory->getConfig()->getRecCmds()) {
- sendError(400, "Bad Request", NULL, "017 execreccmd disabled.");
+ if (! mRequest->mFactory->getConfig()->getCmds()) {
+ sendError(400, "Bad Request", NULL, "017 commands disabled.");
return;
}
@@ -1350,6 +1364,71 @@ void cResponseMemBlk::receiveExecRecCmdReq() {
return;
}
+void cResponseMemBlk::receiveExecCmdReq() {
+ vector<sQueryAVP> avps;
+ string cmd_str;
+ uint cmdid;
+
+ if (isHeadRequest())
+ return;
+
+ if (! mRequest->mFactory->getConfig()->getCmds()) {
+ sendError(400, "Bad Request", NULL, "017 commands disabled.");
+ return;
+ }
+ mRequest->parseQueryLine(&avps);
+
+ if (mRequest->getQueryAttributeValue(&avps, "cmd", cmd_str) != OKAY){
+ sendError(400, "Bad Request", NULL, "015 Mandatory cmd attribute not present.");
+ return ;
+ }
+ cmdid = atoi(cmd_str.c_str());
+
+ *(mLog->log())<< DEBUGPREFIX
+ << " receiveExecCmd cmd= " << cmdid
+ << endl;
+ vector<cCmd*>* r_cmds = mRequest->mFactory->getCmdCmds();
+
+ if ((cmdid <0 ) || ( cmdid > r_cmds->size())) {
+ *(mLog->log())<< DEBUGPREFIX
+ << " ERROR: cmd value out of range." << endl;
+ sendError(400, "Bad Request", NULL, "016 Command (cmd) value out of range.");
+ return ;
+ }
+ *(mLog->log())<< DEBUGPREFIX
+ << " cmdid= " << cmdid
+ << " t= " << ((*r_cmds)[cmdid])->mTitle
+ << " c= " << ((*r_cmds)[cmdid])->mCommand
+ << endl;
+
+ string cmd = ((*r_cmds)[cmdid])->mCommand;
+
+// dsyslog("executing command '%s'", cmd.c_str());
+ *(mLog->log())<< DEBUGPREFIX
+ << " exec cmd: " << cmd << endl;
+ cPipe p;
+ string result ="";
+ if (p.Open(cmd.c_str(), "r")) {
+ int c;
+ while ((c = fgetc(p)) != EOF) {
+ result += c;
+ } // while
+ p.Close();
+ } // if (p.open
+ else {
+ // esyslog("ERROR: can't open pipe for command '%s'", cmd);
+ *(mLog->log())<< DEBUGPREFIX
+ << " ERROR: cannot open pipe for cmd " << cmd << endl;
+ }
+ *(mLog->log())<< DEBUGPREFIX
+ << " Exec cmd result: " << result << endl;
+ //report result to widget
+ mRequest->mFactory->OsdStatusMessage(result.c_str());
+
+ sendHeaders(200, "OK", NULL, NULL, 0, -1);
+ return;
+}
+
uint64_t cResponseMemBlk::getVdrFileSize() {
// iter over all vdr files and get file size
struct stat statbuf;
diff --git a/responsememblk.h b/responsememblk.h
index ab86aaf..80e953d 100755
--- a/responsememblk.h
+++ b/responsememblk.h
@@ -71,7 +71,9 @@ class cResponseMemBlk : public cResponseBase {
int sendManifest (struct stat *statbuf, bool is_hls = true);
void sendTimersXml();
void sendRecCmds();
+ void sendCmds();
void receiveExecRecCmdReq();
+ void receiveExecCmdReq();
void receiveAddTimerReq();
void receiveActTimerReq();
diff --git a/smarttvfactory.c b/smarttvfactory.c
index 94242e6..c6b0524 100755
--- a/smarttvfactory.c
+++ b/smarttvfactory.c
@@ -109,7 +109,8 @@ void cCmd::trim(string &t) {
SmartTvServer::SmartTvServer(): cStatus(), mRequestCount(0), isInited(false), serverPort(PORT), mServerFd(-1),
mSegmentDuration(10), mHasMinBufferTime(40), mLiveChannels(20),
- clientList(), mConTvClients(), mRecCmds(), mRecMsg(), mActiveSessions(0), mHttpClientId(0), mConfig(NULL), mMaxFd(0),
+ clientList(), mConTvClients(), mRecCmds(), mCmdCmds(), mRecMsg(), mCmdMsg(), mActiveSessions(0), mHttpClientId(0),
+ mConfig(NULL), mMaxFd(0),
mManagedUrls(NULL){
}
@@ -121,6 +122,9 @@ SmartTvServer::~SmartTvServer() {
for (uint i =0; i < mRecCmds.size(); i++)
delete mRecCmds[i];
+
+ for (uint i =0; i < mCmdCmds.size(); i++)
+ delete mCmdCmds[i];
}
// Status methods
@@ -702,6 +706,16 @@ void SmartTvServer::initRecCmds() {
}
+void SmartTvServer::initCmdCmds() {
+ mRecMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ mRecMsg += "<cmdcmds>\n";
+ mRecMsg += processNestedItemList("", &Commands, &mCmdCmds);
+ mRecMsg += "</cmdcmds>\n";
+
+ *(mLog.log()) << "reccmds.conf parsed" << endl;
+
+}
+
void SmartTvServer::initServer(string dir) {
/* This function initialtes the listening socket for the server
* and sets isInited to true
@@ -724,6 +738,7 @@ void SmartTvServer::initServer(string dir) {
*(mLog.log()) << "LogFile= " << mConfig->getLogFile() << endl;
initRecCmds();
+ initCmdCmds();
#else
mConfig = new cSmartTvConfig(".");
diff --git a/smarttvfactory.h b/smarttvfactory.h
index ab46e2b..c5f03fa 100755
--- a/smarttvfactory.h
+++ b/smarttvfactory.h
@@ -48,8 +48,8 @@ class cStatus {
using namespace std;
-#define PLG_VERSION "0.9.9-pre"
-#define SERVER "SmartTvWeb/0.9.9-pre"
+#define PLG_VERSION "0.9.9"
+#define SERVER "SmartTvWeb/0.9.9"
struct sClientEntry {
string mac;
@@ -102,7 +102,9 @@ class SmartTvServer : public cStatus {
void pushCfgServerAddressToTv( string tv_addr);
string getRecCmdsMsg() { return mRecMsg; };
+ string getCmdCmdsMsg() { return mCmdMsg; };
vector<cCmd*>* getRecCmds() { return &mRecCmds; };
+ vector<cCmd*>* getCmdCmds() { return &mCmdCmds; };
void OsdStatusMessage(const char *Message);
@@ -114,6 +116,7 @@ class SmartTvServer : public cStatus {
void setNonBlocking(int fd);
void initRecCmds();
+ void initCmdCmds();
// status callbacks
void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On);
void TimerChange(const cTimer *Timer, eTimerChange Change);
@@ -133,7 +136,9 @@ class SmartTvServer : public cStatus {
vector<sClientEntry*> mConTvClients;
vector<cCmd*> mRecCmds;
+ vector<cCmd*> mCmdCmds;
string mRecMsg;
+ string mCmdMsg;
int mActiveSessions;
int mHttpClientId;
@@ -148,7 +153,9 @@ class SmartTvServer : public cStatus {
cManageUrls* mManagedUrls;
string mRecCmdMsg;
+ string mCmdCmdMsg;
vector<string> mRecCmdList;
+ vector<string> mCmdCmdList;
};
diff --git a/smarttvweb.conf b/smarttvweb.conf
index 10adaa7..7976687 100644
--- a/smarttvweb.conf
+++ b/smarttvweb.conf
@@ -29,5 +29,6 @@ GroupSeparators Ignore
# 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
+# Allow execution of reccmd.conf or commands.conf defined programs through the widget.
+# Ensure that only authorized hosts get access to the plugin (e.g. firewall protected).
+#Commands enable
diff --git a/stvw_cfg.c b/stvw_cfg.c
index b56bbe8..d0a330c 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(""), mServerPort(8000), mRecCmds(false) {
+ mLiveChannels(), mGroupSep(IGNORE), mServerAddress(""), mServerPort(8000), mCmds(false) {
#ifndef STANDALONE
mLogFile= "";
@@ -149,9 +149,9 @@ void cSmartTvConfig::readConfig() {
continue;
}
- if (strcmp(attr, "RecCmds") == 0) {
+ if (strcmp(attr, "Commands") == 0) {
if (strcmp(value, "enable") == 0)
- mRecCmds = true;
+ mCmds = true;
continue;
}
diff --git a/stvw_cfg.h b/stvw_cfg.h
index 9001fe7..a3fd01e 100755
--- a/stvw_cfg.h
+++ b/stvw_cfg.h
@@ -55,7 +55,7 @@ class cSmartTvConfig {
eGroupSep mGroupSep;
string mServerAddress;
int mServerPort;
- bool mRecCmds;
+ bool mCmds;
public:
cSmartTvConfig(string dir);
@@ -73,7 +73,7 @@ class cSmartTvConfig {
eGroupSep getGroupSep() { return mGroupSep; };
string getServerAddress() { return mServerAddress; };
int getServerPort() { return mServerPort; };
- bool getRecCmds() { return mRecCmds; };
+ bool getCmds() { return mCmds; };
};
#endif