summaryrefslogtreecommitdiff
path: root/pages/epginfo.ecpp
blob: 362e5f89b7e4364e6b713f62b9b35299ad6240bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<%pre>

#include <stdext.h>
#include <exception.h>
#include <setup.h>
#include <tools.h>
#include <epg_events.h>
#include <recman.h>

#if VDRVERSNUM < 20301
namespace vdrlive {
	class SchedulesLock
	{
		public:
			SchedulesLock() : m_schedulesLock() {}

			operator cSchedulesLock& () { return m_schedulesLock; }

		private:
			SchedulesLock(SchedulesLock const &schedulesLock) {}

			cSchedulesLock m_schedulesLock;
	};

	typedef std::tr1::shared_ptr<SchedulesLock> SchedulesLockPtr;
}
#endif

using namespace vdrlive;
using namespace std;

</%pre>
<%args>
	string epgid;
	string async;
</%args>
<%session scope="global">
	bool logged_in(false);
</%session>
<%request scope="page">
	EpgInfoPtr epgEvent;
</%request>
<%include>page_init.eh</%include>
<%cpp>
	if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");

	pageTitle = tr("Electronic program guide information");

	bool ajaxReq = !async.empty() && (lexical_cast<int>(async) != 0);

	bool aboutBox = false;

#if VDRVERSNUM >= 20301
	bool isEvent = false;
#else
	// One of these get initialized when needed. When freed by getting
	// out of scope they will release (if initialized) important
	// Semaphores/Locks.
	SchedulesLockPtr schedulesLockPtr;
#endif
	RecordingsManagerPtr recordings;

	if (!epgid.empty()) {

		const string recording("recording_");
		const string event("event_");
		const string aboutbox("aboutBox");

		// check for recording:
		if (epgid.compare(0, recording.length(), recording) == 0) {
			recordings = LiveRecordingsManager();
			const cRecording* recording = recordings->GetByMd5Hash(epgid);
			if (recording == 0) {
				throw HtmlError(tr("Couldn't find recording or no recordings available"));
			}
			epgEvent = EpgEvents::CreateEpgInfo(epgid, recording);
		}
		// check for event:
		else if (epgid.compare(0, event.length(), event) == 0) {
#if VDRVERSNUM >= 20301
			/* Need to lock here channels also, because CreateEpgInfo will lock
			 * it also and this will result in a wrong lock order */
			LOCK_CHANNELS_READ;
			LOCK_SCHEDULES_READ;
			epgEvent = EpgEvents::CreateEpgInfo(epgid, Schedules);
			isEvent = true;
#else
			schedulesLockPtr = SchedulesLockPtr(new SchedulesLock);
			if (!schedulesLockPtr) {
				throw HtmlError(tr("Error aquiring schedules lock"));
			}
			const cSchedules* schedules = cSchedules::Schedules(*schedulesLockPtr);
			if (!schedules) {
				throw HtmlError(tr("Error aquiring schedules"));
			}
			epgEvent = EpgEvents::CreateEpgInfo(epgid, schedules);
#endif
		}
		// check for aboutbox:
		else if (epgid.compare(0, aboutbox.length(), aboutbox) == 0) {
			aboutBox = true;
		}
	}
</%cpp>
<& pageelems.doc_type &>
<html>
	<head>
		<title>VDR-Live - <$ pageTitle $></title>
<%cpp>
	if (!ajaxReq) {
</%cpp>
		<& pageelems.stylesheets &>
		<& pageelems.ajax_js &>
<%cpp>
	}
</%cpp>
	</head>
	<body>
<%cpp>
	if (!ajaxReq) {
</%cpp>
		<& pageelems.logo &>
		<& menu &>
<%cpp>
	}
</%cpp>
		<div class="inhalt">
<%cpp>
	if (epgEvent) {
		string start(epgEvent->StartTime("%a,") + string(" ")
				+ epgEvent->StartTime(tr("%b %d %y")) + string(" ")
				+ epgEvent->StartTime(tr("%I:%M %p")));
		string tools_component;
		if (recordings) {
			tools_component = epgEvent->Archived().empty() ? "recordings.rec_tools" : "recordings.archived_disc" ;
		}
#if VDRVERSNUM >= 20301
		if (isEvent)
#else
		if (schedulesLockPtr)
#endif
			tools_component = "epginfo.epgTools";

</%cpp>
		<& pageelems.epg_tt_box boxId=(epgEvent->Id()) caption=(epgEvent->Caption()) tools_comp=(tools_component) time=(start) title=(epgEvent->Title()) short_descr=(epgEvent->ShortDescr()) long_descr=(epgEvent->LongDescr()) archived=(epgEvent->Archived()) elapsed=(epgEvent->Elapsed()) &>
<%cpp>
	}
	if (aboutBox) {
</%cpp>
		<& pageelems.about_tt_box &>
<%cpp>
	}
</%cpp>
		</div>
	</body>
</html>

<%include>page_exit.eh</%include>

<# ---------------------------------------------------------------------- #>

<%def epgTools>
<%args>
string id;
string title;
int detail;
</%args>
<& pageelems.epg_tool_box detail=(detail) epgid=(id) title=(title) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) &>
</%def>