nhttpd: some json changes for epg

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1688 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Branch: ni/coolstream
Commit: 6c6c0a6999
Author: yjogol <yjogol2@online.de>
Date: 2011-09-14 (Wed, 14 Sep 2011)



------------------
This commit was generated by Migit
This commit is contained in:
yjogol
2011-09-14 09:04:25 +00:00
parent 0f627b9e56
commit 794e515d34

View File

@@ -1186,14 +1186,16 @@ void CControlAPI::GetBouquetsCGI(CyhookHandler *hh) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string CControlAPI::channelEPGformated(CyhookHandler *hh, int bouquetnr, t_channel_id channel_id, int max, long stoptime) { std::string CControlAPI::channelEPGformated(CyhookHandler *hh, int bouquetnr, t_channel_id channel_id, int max, long stoptime) {
std::string result = ""; std::string result = "";
std::string channelData = "";
sectionsd_getEventsServiceKey(channel_id, NeutrinoAPI->eList); sectionsd_getEventsServiceKey(channel_id, NeutrinoAPI->eList);
result += hh->outPair("channel_id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id), true); channelData += hh->outPair("channel_id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id), true);
result += hh->outPair("channel_short_id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id & 0xFFFFFFFFFFFFULL), true); channelData += hh->outPair("channel_short_id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id & 0xFFFFFFFFFFFFULL), true);
result += hh->outPair("channel_name", hh->outValue(NeutrinoAPI->GetServiceName(channel_id)), true); channelData += hh->outPair("channel_name", hh->outValue(NeutrinoAPI->GetServiceName(channel_id)), false);
if(hh->outType == json) if(hh->outType == json)
result = hh->outCollection("channelData", result); channelData = hh->outCollection("channelData", channelData);
int i = 0; int i = 0;
CChannelEventList::iterator eventIterator; CChannelEventList::iterator eventIterator;
bool isFirstLine = true;
for (eventIterator = NeutrinoAPI->eList.begin(); eventIterator != NeutrinoAPI->eList.end(); eventIterator++, i++) { for (eventIterator = NeutrinoAPI->eList.begin(); eventIterator != NeutrinoAPI->eList.end(); eventIterator++, i++) {
if ((max != -1 && i >= max) || (stoptime != -1 && eventIterator->startTime >= stoptime)) if ((max != -1 && i >= max) || (stoptime != -1 && eventIterator->startTime >= stoptime))
break; break;
@@ -1225,11 +1227,15 @@ std::string CControlAPI::channelEPGformated(CyhookHandler *hh, int bouquetnr, t_
} }
} }
prog += hh->outPair("description", hh->outValue(eventIterator->description), false); prog += hh->outPair("description", hh->outValue(eventIterator->description), false);
result += hh->outArrayItem("prog", prog, true); if(isFirstLine)
isFirstLine = false;
else
result += hh->outNext();
result += hh->outArrayItem("prog", prog, false);
} }
if(hh->outType == json) if(hh->outType == json)
result = hh->outArray("progData", result); result = hh->outArray("progData", result);
result = channelData + hh->outNext() + result;
return result; return result;
} }
@@ -1308,7 +1314,7 @@ void CControlAPI::epgDetailList(CyhookHandler *hh) {
// list one channel, no bouquetnr given // list one channel, no bouquetnr given
result = channelEPGformated(hh, 0, channel_id, max, stoptime); result = channelEPGformated(hh, 0, channel_id, max, stoptime);
result = hh->outArray("epglist", result); result = hh->outCollection("epglist", result);
// write footer // write footer
if (outType == json) { if (outType == json) {
hh->WriteLn(json_out_success(result)); hh->WriteLn(json_out_success(result));