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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
From 042724e30d5690ab67a6c04aea48a16b9a3b085b Mon Sep 17 00:00:00 2001
From: Dieter Hametner
Date: Thu, 02 May 2013 23:37:41 +0000
Subject: Make LIVE compile and work with Tntnet and cxxtools version 2.2.
Thanks to Tommi Mäkitalo for his help on resolving the issues.
This problem was reported by Martin Gansser and by the user 'varas' in
the bugtracker as bug #1351. This commit fixes that bug.
---
diff --git a/pages/recordings.ecpp b/pages/recordings.ecpp
index 51018bb..80f145b 100644
--- a/pages/recordings.ecpp
+++ b/pages/recordings.ecpp
@@ -205,7 +205,11 @@ for (recIter = recItems.begin(); recIter != recItems.end(); ++recIter) {
<& rec_item_dir name=(recItem->Name()) level=(level) &>
<%cpp>
#if TNT_HAS_QUERYPARAMS
+#if TNT_QUERYPARAMS_NO_BOOL
+ tnt::QueryParams recItemParams(qparam);
+#else
tnt::QueryParams recItemParams(qparam, false);
+#endif
#else
cxxtools::QueryParams recItemParams(qparam, false);
#endif
diff --git a/tntconfig.cpp b/tntconfig.cpp
index 3a1fd14..3325776 100644
--- a/tntconfig.cpp
+++ b/tntconfig.cpp
@@ -3,7 +3,13 @@
#include <fstream>
#include <sstream>
#include <stdexcept>
+#include "tntfeatures.h"
+#if TNT_LOG_SERINFO
+#include <cxxtools/log.h>
+#include <cxxtools/xml/xmldeserializer.h>
+#else
#include <cxxtools/loginit.h>
+#endif
#include <tnt/sessionscope.h>
#include <tnt/httpreply.h>
#include <vdr/config.h>
@@ -181,19 +187,67 @@ namespace vdrlive {
#endif
#if TNT_CONFIG_INTERNAL
+ namespace {
+ std::string GetResourcePath()
+ {
+#if APIVERSNUM > 10729
+ string resourceDir(Plugin::GetResourceDirectory());
+ return resourceDir;
+#else
+ string configDir(Plugin::GetConfigDirectory());
+ return configDir;
+#endif
+ }
+
+ void MapUrl(tnt::Tntnet & app, const char *rule, const char * component, std::string const & instPath, const char * pathInfo, const char * mime_type)
+ {
+#if TNT_MAPURL_NAMED_ARGS
+ tnt::Mapping::args_type argMap;
+ argMap.insert(std::make_pair("mime-type", mime_type));
+#endif
+ app.mapUrl(rule, component)
+ .setPathInfo(instPath + pathInfo)
+#if TNT_MAPURL_NAMED_ARGS
+ .setArgs(argMap);
+#else
+ .pushArg(mime_type);
+#endif
+ }
+ }
+
void TntConfig::Configure(tnt::Tntnet& app) const
{
string const configDir(Plugin::GetConfigDirectory());
-#if APIVERSNUM > 10729
- string const resourceDir(Plugin::GetResourceDirectory());
-#endif
+#if TNT_LOG_SERINFO
+ cxxtools::SerializationInfo si;
+ std::istringstream logXmlConf(
+ "<logging>\n"
+ " <rootlogger>" + LiveSetup().GetTntnetLogLevel() + "</rootlogger>\n"
+ " <loggers>\n"
+ " <logger>\n"
+ " <category>cxxtools</category>\n"
+ " <level>" + LiveSetup().GetTntnetLogLevel() + "</level>\n"
+ " </logger>\n"
+ " <logger>\n"
+ " <category>tntnet</category>\n"
+ " <level>" + LiveSetup().GetTntnetLogLevel() + "</level>\n"
+ " </logger>\n"
+ " </loggers>\n"
+ "</logging>\n"
+ );
+ cxxtools::xml::XmlDeserializer d(logXmlConf);
+ d.deserialize(si);
+ log_init(si);
+#else
std::istringstream logConf(
"rootLogger=" + LiveSetup().GetTntnetLogLevel() + "\n"
"logger.tntnet=" + LiveSetup().GetTntnetLogLevel() + "\n"
"logger.cxxtools=" + LiveSetup().GetTntnetLogLevel() + "\n"
);
+
log_init(logConf);
+#endif
// +++ CAUTION +++ CAUTION +++ CAUTION +++ CAUTION +++ CAUTION +++
// ------------------------------------------------------------------------
@@ -229,13 +283,12 @@ namespace vdrlive {
// the following selects the theme specific 'theme.css' file
// inserted by 'tadi' -- verified with above, but not counterchecked yet!
- app.mapUrl("^/themes/([^/]*)/css.*/(.+\\.css)", "content")
-#if APIVERSNUM > 10729
- .setPathInfo(resourceDir + "/themes/$1/css/$2")
-#else
- .setPathInfo(configDir + "/themes/$1/css/$2")
-#endif
- .pushArg("text/css");
+ MapUrl(app,
+ "^/themes/([^/]*)/css.*/(.+\\.css)",
+ "content",
+ GetResourcePath(),
+ "/themes/$1/css/$2",
+ "text/css");
// the following rules provide a search scheme for images. The first
// rule where a image is found, terminates the search.
@@ -243,79 +296,82 @@ namespace vdrlive {
// 2. /img/<imgname>.<ext>
// deprecated: 3. <imgname>.<ext> (builtin images)
// inserted by 'tadi' -- verified with above, but not counterchecked yet!
- app.mapUrl("^/themes/([^/]*)/img.*/(.+)\\.(.+)", "content")
-#if APIVERSNUM > 10729
- .setPathInfo(resourceDir + "/themes/$1/img/$2.$3")
-#else
- .setPathInfo(configDir + "/themes/$1/img/$2.$3")
-#endif
- .pushArg("image/$3");
- app.mapUrl("^/themes/([^/]*)/img.*/(.+)\\.(.+)", "content")
-#if APIVERSNUM > 10729
- .setPathInfo(resourceDir + "/img/$2.$3")
-#else
- .setPathInfo(configDir + "/img/$2.$3")
-#endif
- .pushArg("image/$3");
+ MapUrl(app,
+ "^/themes/([^/]*)/img.*/(.+)\\.(.+)",
+ "content",
+ GetResourcePath(),
+ "/themes/$1/img/$2.$3",
+ "image/$3");
+
+ MapUrl(app,
+ "^/themes/([^/]*)/img.*/(.+)\\.(.+)",
+ "content",
+ GetResourcePath(),
+ "/img/$2.$3",
+ "image/$3");
// deprecated: file << "MapUrl ^/themes/([^/]*)/img.*/(.+)\\.(.+) $2@" << endl;
// Epg images
string const epgImgPath(LiveSetup().GetEpgImageDir());
if (!epgImgPath.empty()) {
// inserted by 'tadi' -- verified with above, but not counterchecked yet!
- app.mapUrl("^/epgimages/([^/]*)\\.([^./]+)", "content")
- .setPathInfo(epgImgPath + "/$1.$2")
- .pushArg("image/$2");
+ MapUrl(app,
+ "^/epgimages/([^/]*)\\.([^./]+)",
+ "content",
+ epgImgPath,
+ "/$1.$2",
+ "image/$2");
}
// select additional (not build in) javascript.
// WARNING: no path components with '.' in the name are allowed. Only
// the basename may contain dots and must end with '.js'
// inserted by 'tadi' -- verified with above, but not counterchecked yet!
- app.mapUrl("^/js(/[^.]*)([^/]*\\.js)", "content")
-#if APIVERSNUM > 10729
- .setPathInfo(resourceDir + "/js$1$2")
-#else
- .setPathInfo(configDir + "/js$1$2")
-#endif
- .pushArg("text/javascript");
+ MapUrl(app,
+ "^/js(/[^.]*)([^/]*\\.js)",
+ "content",
+ GetResourcePath(),
+ "/js$1$2",
+ "text/javascript");
// map to 'css/basename(uri)'
// inserted by 'tadi' -- verified with above, but not counterchecked yet!
- app.mapUrl("^/css.*/(.+)", "content")
-#if APIVERSNUM > 10729
- .setPathInfo(resourceDir + "/css/$1")
-#else
- .setPathInfo(configDir + "/css/$1")
-#endif
- .pushArg("text/css");
+ MapUrl(app,
+ "^/css.*/(.+)",
+ "content",
+ GetResourcePath(),
+ "/css/$1",
+ "text/css");
// map to 'img/basename(uri)'
// inserted by 'tadi' -- verified with above, but not counterchecked yet!
- app.mapUrl("^/img.*/(.+)\\.([^.]+)", "content")
-#if APIVERSNUM > 10729
- .setPathInfo(resourceDir + "/img/$1.$2")
-#else
- .setPathInfo(configDir + "/img/$1.$2")
-#endif
- .pushArg("image/$2");
+ MapUrl(app,
+ "^/img.*/(.+)\\.([^.]+)",
+ "content",
+ GetResourcePath(),
+ "/img/$1.$2",
+ "image/$2");
// Map favicon.ico into img directory
- app.mapUrl("^/favicon.ico$", "content")
-#if APIVERSNUM > 10729
- .setPathInfo(resourceDir + "/img/favicon.ico")
-#else
- .setPathInfo(configDir + "/img/favicon.ico")
-#endif
- .pushArg("image/x-icon");
+ MapUrl(app,
+ "^/favicon.ico$",
+ "content",
+ GetResourcePath(),
+ "/img/favicon.ico",
+ "image/x-icon");
// takes first path components without 'extension' when it does not
// contain '.'
// modified by 'tadi' -- verified with above, but not counterchecked yet!
app.mapUrl("^/([^./]+)(.*)?", "$1");
+#if TNT_GLOBAL_TNTCONFIG
+ tnt::TntConfig::it().sessionTimeout = 86400;
+ tnt::TntConfig::it().defaultContentType = string("text/html; charset=") + LiveI18n().CharacterEncoding();
+#else
tnt::Sessionscope::setDefaultTimeout(86400);
tnt::HttpReply::setDefaultContentType(string("text/html; charset=") + LiveI18n().CharacterEncoding());
+#endif
Setup::IpList const& ips = LiveSetup().GetServerIps();
int port = LiveSetup().GetServerPort();
diff --git a/tntfeatures.h b/tntfeatures.h
index 6de1f88..76d3757 100644
--- a/tntfeatures.h
+++ b/tntfeatures.h
@@ -17,6 +17,9 @@
// Query params are now in tntnet and not in cxxtools
#define TNT_HAS_QUERYPARAMS (TNTVERSION >= 16060)
+// Query params without boolean parameter
+#define TNT_QUERYPARAMS_NO_BOOL (TNTVERSION >= 22000)
+
// One can request the host part of the request url
#define TNT_HAS_GETHOST (TNTVERSION >= 16060)
@@ -26,4 +29,13 @@
// version of TNTNET that binds ipv6 addresses with IPV6_V6ONLY flag set to true
#define TNT_IPV6_V6ONLY (CXXTOOLVER >= 21000)
+// version of TNTNET with properties deserializer for logger configuration args.
+#define TNT_LOG_SERINFO (CXXTOOLVER >= 22000)
+
+// version of TNTNET wich expects name, value mappings for Url-Mapper arguments.
+#define TNT_MAPURL_NAMED_ARGS (TNTVERSION >= 22000)
+
+// version of TNTNET where configuration is global
+#define TNT_GLOBAL_TNTCONFIG (TNTVERSION >= 22000)
+
#endif // VDR_LIVE_TNTFEATURES_H
--
cgit v0.9.0.2-40-g7c79
|