yhook: introduce new format for plain output; key=value

Origin commit data
------------------
Branch: ni/coolstream
Commit: 4c679613d6
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-02-20 (Sat, 20 Feb 2016)

Origin message was:
------------------
- yhook: introduce new format for plain output; key=value

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2016-02-20 12:06:58 +01:00
parent 9d14197e2b
commit 75139c0af9
3 changed files with 19 additions and 10 deletions

View File

@@ -1058,7 +1058,7 @@ std::string CControlAPI::_GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel *
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
void CControlAPI::GetBouquetCGI(CyhookHandler *hh) { void CControlAPI::GetBouquetCGI(CyhookHandler *hh) {
TOutType outType = hh->outStart(); TOutType outType = hh->outStart(true /*old mode*/);
std::string result = ""; std::string result = "";
if (!(hh->ParamList.empty())) { if (!(hh->ParamList.empty())) {
@@ -1211,7 +1211,7 @@ void CControlAPI::GetBouquetsCGI(CyhookHandler *hh) {
bool encode = false; bool encode = false;
std::string result = ""; std::string result = "";
TOutType outType = hh->outStart(); TOutType outType = hh->outStart(true /*old mode*/);
if (hh->ParamList["showhidden"] == "false") if (hh->ParamList["showhidden"] == "false")
show_hidden = false; show_hidden = false;
@@ -1357,7 +1357,7 @@ void CControlAPI::epgDetailList(CyhookHandler *hh) {
} }
// ------ generate output ------ // ------ generate output ------
TOutType outType = hh->outStart(); TOutType outType = hh->outStart(true /*old mode*/);
std::string result = ""; std::string result = "";
NeutrinoAPI->eList.clear(); NeutrinoAPI->eList.clear();
@@ -1457,7 +1457,7 @@ void CControlAPI::SendFoundEvents(CyhookHandler *hh, bool xml_format)
if (xml_format) // to stay backward compatible :/ if (xml_format) // to stay backward compatible :/
hh->ParamList["format"] = "xml"; hh->ParamList["format"] = "xml";
TOutType outType = hh->outStart(); TOutType outType = hh->outStart(true /*old mode*/);
/* TODO: maybe add following options as in tuxbox neutrino /* TODO: maybe add following options as in tuxbox neutrino
hh->ParamList["epgitem"] hh->ParamList["epgitem"]
@@ -2996,7 +2996,7 @@ void CControlAPI::ConfigCGI(CyhookHandler *hh) {
std::string result = ""; std::string result = "";
std::string configFileName = hh->ParamList["config"]; std::string configFileName = hh->ParamList["config"];
TOutType outType = hh->outStart(); TOutType outType = hh->outStart(true /*old mode*/);
if (hh->ParamList["action"] == "submit") if (hh->ParamList["action"] == "submit")
load = false; load = false;
@@ -3133,7 +3133,7 @@ void CControlAPI::FileCGI(CyhookHandler *hh) {
if (hh->ParamList["action"] == "list") { // directory list: action=list&path=<path> if (hh->ParamList["action"] == "list") { // directory list: action=list&path=<path>
DIR *dirp; DIR *dirp;
TOutType outType = hh->outStart(); TOutType outType = hh->outStart(true /*old mode*/);
std::string path = hh->ParamList["path"]; std::string path = hh->ParamList["path"];
if ((dirp = opendir(path.c_str()))) { if ((dirp = opendir(path.c_str()))) {
@@ -3259,7 +3259,7 @@ void CControlAPI::getDirCGI(CyhookHandler *hh) {
std::string item = ""; std::string item = "";
bool isFirstLine = true; bool isFirstLine = true;
TOutType outType = hh->outStart(); TOutType outType = hh->outStart(true /*old mode*/);
//Shows all 7 directories stored in the moviebrowser.conf //Shows all 7 directories stored in the moviebrowser.conf
if (hh->ParamList["dir"] == "moviedir" || hh->ParamList["dir"] == "allmoviedirs" ) { if (hh->ParamList["dir"] == "moviedir" || hh->ParamList["dir"] == "allmoviedirs" ) {

View File

@@ -28,6 +28,7 @@ CyhookHandler::CyhookHandler()
Method = M_UNKNOWN; Method = M_UNKNOWN;
httpStatus = HTTP_NIL; httpStatus = HTTP_NIL;
outType = plain; outType = plain;
outSingle = false;
LastModified=0; LastModified=0;
} }
@@ -405,7 +406,8 @@ TOutType CyhookHandler::checkOutput() {
return outType; return outType;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
TOutType CyhookHandler::outStart() { TOutType CyhookHandler::outStart(bool single) {
outSingle = single; // for compatibility
// get outType // get outType
outType = plain; // plain outType = plain; // plain
if (ParamList["format"] == "json") if (ParamList["format"] == "json")
@@ -440,7 +442,13 @@ std::string CyhookHandler::outPair(std::string _key, std::string _content, bool
result += "\n"; result += "\n";
break; break;
default: default:
if (outSingle)
result = _content; result = _content;
else
{
result = _key + "=" + _content;
result += "\n";
}
break; break;
} }
return result; return result;

View File

@@ -139,6 +139,7 @@ public:
std::string Sendfile; // Path & Name (local os style) of file to send std::string Sendfile; // Path & Name (local os style) of file to send
bool keep_alive; bool keep_alive;
bool cached; // cached by mod_cache bool cached; // cached by mod_cache
bool outSingle;
// Input // Input
CStringList ParamList; // local copy of ParamList (Request) CStringList ParamList; // local copy of ParamList (Request)
@@ -199,7 +200,7 @@ public:
int _outIndent; int _outIndent;
TOutType outType; // Outputtpe = plain (default)|xml|json TOutType outType; // Outputtpe = plain (default)|xml|json
TOutType outStart(); TOutType outStart(bool single = false);
TOutType checkOutput(); TOutType checkOutput();
std::string outIndent(); std::string outIndent();
std::string outPair(std::string _key, std::string _content, bool _next); std::string outPair(std::string _key, std::string _content, bool _next);