From 5b9d9e9ac4804f5cc7101b88f19948480df597b5 Mon Sep 17 00:00:00 2001 From: thlo Date: Sat, 25 May 2013 12:13:34 +0200 Subject: serverName.xml added. Skeleton for getRecCmds.xml added. --- httpresource.c | 13 +++++++++++++ responsememblk.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- responsememblk.h | 5 +++++ 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/httpresource.c b/httpresource.c index 08a3e08..e29358b 100755 --- a/httpresource.c +++ b/httpresource.c @@ -315,6 +315,12 @@ int cHttpResource::processRequest() { return OKAY; } + if (mPath.compare("/reccmds") == 0) { + mResponse = new cResponseMemBlk(this); + ((cResponseMemBlk*)mResponse)->sendRecCmds(); + return OKAY; + } + if (mPath.compare("/setResume.xml") == 0) { mResponse = new cResponseMemBlk(this); ((cResponseMemBlk*)mResponse)->receiveResume(); @@ -348,6 +354,13 @@ int cHttpResource::processRequest() { } #endif + if (mPath.compare("/serverName.xml") == 0) { + mResponse = new cResponseMemBlk(this); + ((cResponseMemBlk*)mResponse)->sendServerNameXml( ); + return OKAY; + } + + if (mPath.compare("/yt-bookmarklet.js") == 0) { mResponse = new cResponseMemBlk(this); ((cResponseMemBlk*)mResponse)->sendYtBookmarkletJs(); diff --git a/responsememblk.c b/responsememblk.c index 9a81727..b8d62e8 100644 --- a/responsememblk.c +++ b/responsememblk.c @@ -1061,6 +1061,38 @@ void cResponseMemBlk::sendTimersXml() { #endif } + +void cResponseMemBlk::sendRecCmds() { + *(mLog->log()) << DEBUGPREFIX << " --------------- sendRecCmds ---------------" << endl; + string msg = writeCommands("Recording Commands", &RecordingCommands, " "); + *(mLog->log()) << DEBUGPREFIX << " --------------- sendRecCmds ---------------" << endl; + + if (isHeadRequest()) + return; + + /* mResponseMessage = new string(); + *mResponseMessage = ""; + mResponseMessagePos = 0; + */ + sendHeaders(200, "OK", NULL, "text/plain", 0, -1); + +} + + +string cResponseMemBlk::writeCommands(const char *title, cList *commands, string pref) { + // *(mLog->log()) << DEBUGPREFIX << " title" << endl; + string res = "-\n"; + for (cNestedItem *Cmd = commands->First(); Cmd; Cmd = commands->Next(Cmd)) { + const char *s = Cmd->Text(); + if (Cmd->SubItems()) + res += writeCommands(s, Cmd->SubItems(), (pref + "+")); + else + *(mLog->log()) << DEBUGPREFIX << pref << "title= " << s << endl; + } + return res; +} + + uint64_t cResponseMemBlk::getVdrFileSize() { // iter over all vdr files and get file size struct stat statbuf; @@ -1369,8 +1401,31 @@ int cResponseMemBlk::sendMediaXml (struct stat *statbuf) { return OKAY; } +void cResponseMemBlk::sendServerNameXml () { + if (isHeadRequest()) + return ; + char f[400]; + mResponseMessage = new string(); + *mResponseMessage = ""; + + mResponseMessagePos = 0; + + mRequest->mConnState = SERVING; + + *mResponseMessage += "\n"; + *mResponseMessage += "\n"; + + *mResponseMessage += ""; + gethostname(f, sizeof(f)); + *mResponseMessage += f; + *mResponseMessage += "\n"; + + *mResponseMessage += "" + mRequest->getOwnIp() +"\n"; + *mResponseMessage += "\n"; + sendHeaders(200, "OK", NULL, "application/xml", mResponseMessage->size(), -1); +} int cResponseMemBlk::sendVdrStatusXml (struct stat *statbuf) { @@ -1402,7 +1457,7 @@ int cResponseMemBlk::sendVdrStatusXml (struct stat *statbuf) { strftime(timebuf, sizeof(timebuf), "%Y-%m-%dT%H:%M:%S", localtime(&now)); // ISO 8601 snprintf(f, sizeof(f), "%s\n", timebuf); *mResponseMessage += f; - + *mResponseMessage += "\n"; snprintf(f, sizeof(f), "%d", free); *mResponseMessage += f; diff --git a/responsememblk.h b/responsememblk.h index 34d98b1..206c33c 100644 --- a/responsememblk.h +++ b/responsememblk.h @@ -30,6 +30,8 @@ #include #include "responsebase.h" +#include + using namespace std; struct sFileEntry { @@ -58,6 +60,7 @@ class cResponseMemBlk : public cResponseBase { int sendChannelsXml (struct stat *statbuf); int sendResumeXml (); int sendVdrStatusXml (struct stat *statbuf); + void sendServerNameXml (); int sendYtBookmarkletJs(); int sendBmlInstHtml(); @@ -66,7 +69,9 @@ class cResponseMemBlk : public cResponseBase { int sendMediaXml (struct stat *statbuf); int sendManifest (struct stat *statbuf, bool is_hls = true); void sendTimersXml(); + void sendRecCmds(); + string writeCommands(const char *title, cList *commands, string pref); void receiveAddTimerReq(); void receiveDelTimerReq(); -- cgit v1.2.3