else if (!strcmp(wvrequest, "timeredit")) success = jsonserver_timeredit(js, postData);
else if (!strcmp(wvrequest, "tunersstatus")) success = jsonserver_tunersstatus(js, postData);
else if (!strcmp(wvrequest, "epgsearchsame")) success = jsonserver_epgsearchsame(js, postData);
+ else if (!strcmp(wvrequest, "epgdownload")) success = jsonserver_epgdownload(js, postData);
if (!success) return 0; // the specific handler failed badly
js["Result"] = true;
return true;
}
+
+bool jsonserver_epgdownload(Json::Value& js, const char* postData)
+{
+ Log* log = Log::getInstance();
+ log->log("JSONServer", Log::DEBUG, "channelschedule '%s'", postData);
+
+ cSchedulesLock MutexLock;
+ const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
+
+ if (!Schedules)
+ {
+ log->log("JSONServer", Log::ERR, "Could not get Schedules object");
+ js["Result"] = false;
+ js["Error"] = "Internal schedules error (1)";
+ return true;
+ }
+
+ Json::Value jsevents(Json::arrayValue);
+
+ for (cChannel* channel = Channels.First(); channel; channel = Channels.Next(channel))
+ {
+ if (channel->GroupSep()) continue;
+
+ const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
+ if (!Schedule) continue;
+
+
+ for (const cEvent* event = Schedule->Events()->First(); event; event = Schedule->Events()->Next(event))
+ {
+ Json::Value oneEvent;
+ oneEvent["ChannelNumber"] = channel->Number();
+ oneEvent["ChannelID"] = (const char*)event->ChannelID().ToString();
+ oneEvent["ID"] = event->EventID();
+ oneEvent["Time"] = (Json::UInt)event->StartTime();
+ oneEvent["Duration"] = event->Duration();
+ oneEvent["Title"] = event->Title() ? event->Title() : "";
+ oneEvent["ShortText"] = event->ShortText() ? event->ShortText() : "";
+ oneEvent["HasTimer"] = event->HasTimer();
+ oneEvent["Description"] = event->Description() ? event->Description() : "";
+ jsevents.append(oneEvent);
+ }
+ }
+
+ js["Result"] = true;
+ js["Events"] = jsevents;
+ return true;
+}
bool jsonserver_timeredit(Json::Value& js, const char* postData);
bool jsonserver_tunersstatus(Json::Value& js, const char* postData);
bool jsonserver_epgsearchsame(Json::Value& js, const char* postData);
+bool jsonserver_epgdownload(Json::Value& js, const char* postData);
const cEvent* jsonserver_getEvent(Json::Value& js, int channelNumber, int eventID, int aroundTime);
cTimer* jsonserver_findTimer(const char* rChannelID, const char* rName, const char* rStartTime, const char* rStopTime, const char* rWeekDays);