summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhttpresource.c9
-rwxr-xr-xresponsememblk.c57
-rwxr-xr-xresponsememblk.h1
3 files changed, 60 insertions, 7 deletions
diff --git a/httpresource.c b/httpresource.c
index 76f7956..854cf96 100755
--- a/httpresource.c
+++ b/httpresource.c
@@ -352,14 +352,13 @@ int cHttpResource::processRequest() {
}
//thlo for testing purpose
-/*
- if (mPath.compare("/modifyTimer") == 0) {
+
+ if (mPath.compare("/activateTimer") == 0) {
mResponse = new cResponseMemBlk(this);
- ((cResponseMemBlk*)mResponse)->receiveModTimerReq();
+ ((cResponseMemBlk*)mResponse)->receiveActTimerReq();
return OKAY;
}
-*/
- //thlo for testing purpose
+
if (mPath.compare("/addTimer") == 0) {
mResponse = new cResponseMemBlk(this);
((cResponseMemBlk*)mResponse)->receiveAddTimerReq();
diff --git a/responsememblk.c b/responsememblk.c
index d53fdc1..273890a 100755
--- a/responsememblk.c
+++ b/responsememblk.c
@@ -345,7 +345,7 @@ int cResponseMemBlk::receiveResume() {
<< " resume= " << entry.mResume
<< endl;
- sendError(400, "Bad Request", NULL, "006 Failed to find the recording.");
+ sendError(400, "Bad Request", NULL, "007 Failed to find the recording.");
return OKAY;
}
@@ -382,6 +382,7 @@ int cResponseMemBlk::sendResumeXml () {
cResumeEntry entry;
string id;
+ // obsolete?
parseResume(entry, id);
vector<sQueryAVP> avps;
@@ -400,7 +401,6 @@ int cResponseMemBlk::sendResumeXml () {
cRecording *rec = Recordings.GetByName(entry.mFilename.c_str());
if (rec == NULL) {
- //Error 404
*(mLog->log())<< DEBUGPREFIX
<< " ERROR in sendResume: recording not found - filename= " << entry.mFilename << endl;
sendError(400, "Bad Request", NULL, "007 Failed to find the recording.");
@@ -750,6 +750,59 @@ void cResponseMemBlk::writeMPD(double duration, int bitrate, float seg_dur, int
sendHeaders(200, "OK", NULL, "application/x-mpegURL", mResponseMessage->size(), -1);
}
+void cResponseMemBlk::receiveActTimerReq() {
+ if (isHeadRequest())
+ return ;
+
+ *(mLog->log()) << DEBUGPREFIX << " cResponseMemBlk::receiveActTimerReq" << endl;
+
+ vector<sQueryAVP> avps;
+ mRequest->parseQueryLine(&avps);
+
+ string index_str = "";
+ int index =-1;
+
+ string activate_str = "";
+ bool activate = true; // the default is to activate the timer
+
+ if (mRequest->getQueryAttributeValue(&avps, "index", index_str) == OKAY) {
+ index = atoi(index_str.c_str());
+ *(mLog->log()) << DEBUGPREFIX << " index= " << index << endl;
+ }
+
+ if (mRequest->getQueryAttributeValue(&avps, "activate", activate_str) == OKAY) {
+ if (activate_str.compare("false") == 0) {
+ activate= false;
+ *(mLog->log()) << DEBUGPREFIX
+ << " activate= false " << endl;
+ }
+ }
+
+ if (Timers.BeingEdited()) {
+ *(mLog->log()) << DEBUGPREFIX << " cResponseMemBlk::receiveActTimerReq: Timers are being edited. returning " << endl;
+ sendError(503, "Service Unavailable", NULL, "001 Timers are being edited.");
+ return;
+ }
+
+ cTimer *to_act = Timers.Get(index);
+ if (to_act == NULL) {
+ sendError(400, "Bad Request", NULL, "010 No Timer found.");
+ return;
+ }
+
+ cTimer t = *to_act;
+ if (activate) {
+ t.SetFlags(tfActive);
+ }
+ else {
+ t.ClrFlags(tfActive);
+ }
+ *to_act = t;
+ Timers.SetModified();
+
+ sendHeaders(200, "OK", NULL, "text/plain", 0, -1);
+
+}
void cResponseMemBlk::receiveAddTimerReq() {
if (isHeadRequest())
diff --git a/responsememblk.h b/responsememblk.h
index 5f564c2..ab86aaf 100755
--- a/responsememblk.h
+++ b/responsememblk.h
@@ -74,6 +74,7 @@ class cResponseMemBlk : public cResponseBase {
void receiveExecRecCmdReq();
void receiveAddTimerReq();
+ void receiveActTimerReq();
void receiveDelTimerReq();
void receiveDelFileReq();