File: setup.ecpp

package info (click to toggle)
vdr-plugin-live 3.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,116 kB
  • sloc: cpp: 12,988; javascript: 3,220; makefile: 241; sh: 40
file content (369 lines) | stat: -rw-r--r-- 17,749 bytes parent folder | download
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<%pre>

#include <setup.h>
#include <stringhelpers.h>
#include <tools.h>
#include <users.h>
#include <live.h>
#include <livefeatures.h>

using namespace vdrlive;

</%pre>
<%args>
  std::string lastchannel;
  bool useauth = false;
  std::string login;
  std::string pass;
  std::string times;
  std::string channelGroupsGen;
  std::string channelGroups;
  std::string scheduleDuration;
  std::string startscreen;
  std::string theme;
  std::string localnetmask;
  std::string localnetmaskIPv6;
  std::string allowlocalhost;
  std::string showLogo;
  std::string showInfoBox;
  std::string useStreamdev;
  std::string markNewRec;
  std::string showIMDb;
  std::string showChannelsWithoutEPG;
  std::string streamdevport;
  std::string streamdevtype;
  int authchanged = 0;
</%args>
<%session scope="global">
  bool logged_in(false);
</%session>
<%include>page_init.eh</%include>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) {
  cToSvConcat targetUrl = "/login.html?redirect=";
  targetUrl.appendUrlEscaped(request.getQuery());
  return reply.redirect(targetUrl.data());
}
if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP))
    throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );

#define SELECTIF(x) reply.out() << ( (x) ? "selected=\"selected\"" : "" );
#define CHECKIF(x) reply.out() << ( (x) ? " checked=\"checked\"" : "" );

  std::string message;

  if ( request.getMethod() == "POST") {
    if (authchanged && useauth && (login.empty() || pass.empty()))
      message = tr("Please set login and password!");
    else
    {
      LiveSetup().SetLastChannel(lastchannel != "" ? parse_int<int>(lastchannel):0);
      LiveSetup().SetUseAuth(useauth);
      if (useauth) {
        LiveSetup().SetAdminLogin(login);
        if (pass != "")
          LiveSetup().SetAdminPassword(pass);
        LiveSetup().SetLocalNetMask(localnetmask);
        LiveSetup().SetLocalNetMaskIPv6(localnetmaskIPv6);
        LiveSetup().SetAllowLocalhost(!allowlocalhost.empty());
        LiveSetup().CheckLocalNet(request.getPeerIp());
      }
      LiveSetup().SetTimes(times);
// for multischedule
      LiveSetup().SetChannelGroupsGen(channelGroupsGen);
      LiveSetup().SetChannelGroups(channelGroups);
      LiveSetup().SetScheduleDuration(scheduleDuration);
// end multischedule
      LiveSetup().SetStartScreen(startscreen);
      LiveSetup().SetTheme(theme);
      LiveSetup().SetShowLogo(!showLogo.empty());
      LiveSetup().SetShowInfoBox(!showInfoBox.empty());
      LiveSetup().SetUseStreamdev(!useStreamdev.empty());
      LiveSetup().SetStreamdevPort(streamdevport.empty() ? 3000 : parse_int<int>(streamdevport));
      LiveSetup().SetStreamdevType(streamdevtype.empty() ? "PES" : streamdevtype);
      LiveSetup().SetMarkNewRec(!markNewRec.empty());

      LiveSetup().SetShowIMDb(!showIMDb.empty());
      LiveSetup().SetShowChannelsWithoutEPG(!showChannelsWithoutEPG.empty());
      LiveSetup().SaveSetup();

      message = tr("Setup saved.");
    }
  }
  pageTitle = tr("Setup");
  int ilastchannel = LiveSetup().GetLastChannel();
  if (ilastchannel == std::numeric_limits< int >::max())
    lastchannel = "";
  else
    lastchannel = std::string(cToSvInt(ilastchannel));

  login = LiveSetup().GetAdminLogin();
  useauth = LiveSetup().GetUseAuth();
  times = LiveSetup().GetTimes();
  channelGroups = LiveSetup().GetChannelGroups();
  channelGroupsGen = LiveSetup().GetChannelGroupsGen();
  scheduleDuration = LiveSetup().GetScheduleDuration();
  startscreen = LiveSetup().GetStartScreen();
  theme = LiveSetup().GetTheme();
  localnetmask = LiveSetup().GetLocalNetMask();
  localnetmaskIPv6 = LiveSetup().GetLocalNetMaskIPv6();
  allowlocalhost = LiveSetup().GetAllowLocalhost() ? "1" : "";
  showLogo = LiveSetup().GetShowLogo() ? "1" : "";
  showInfoBox = LiveSetup().GetShowInfoBox() ? "1" : "";
  useStreamdev = LiveSetup().GetUseStreamdev() ? "1" : "";
  streamdevport = std::string(cToSvInt(LiveSetup().GetStreamdevPort()));
  streamdevtype = LiveSetup().GetStreamdevType();
  markNewRec = LiveSetup().GetMarkNewRec() ? "1" : "";
  showIMDb = LiveSetup().GetShowIMDb() ? "1" : "";
  showChannelsWithoutEPG = LiveSetup().GetShowChannelsWithoutEPG() ? "1" : "";
</%cpp>
<& pageelems.doc_type &>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>VDR-Live - <$ pageTitle $></title>
    <& pageelems.stylesheets &>
    <& pageelems.ajax_js &>
    <script type="text/javascript"><!--
    function initform()
    {
      changeduseauth(document.getElementById("useauth"));
      changedChanGroups();
      if (document.getElementById("message").value != "")
        alert(document.getElementById("message").value);
    }
    function changeduseauth(selection)
    {
      document.getElementById("authsection").style.display = (selection.checked ? "revert-layer" : "none");
    }
    function setauthchanged(selection)
    {
      document.getElementById("authchanged").value = 1;
    }
    function changedChanGroups() {
      if (document.getElementById("channelGroupsGen_individual").checked) {
         document.getElementById("individual_channelGroups_section").style.display = "revert-layer"
      } else {
         document.getElementById("individual_channelGroups_section").style.display = "none"
      }
    }
    //--></script>
  </head>
  <body onload="initform()" onpagehide="saveScrollPosition('content')" onpageshow="restoreScrollPosition()">
    <& pageelems.logo &>
    <& menu active=("setup") &>
    <div id="content">
      <div class="spacebar"><# spacer with fade-out effect #></div>
      <form method="post" action="setup.html">
        <input type="hidden" name="authchanged" value="<$ authchanged $>" id="authchanged"/>
        <input type="hidden" name="message" value="<$ message $>" id="message"/>
        <table class="form" cellpadding="0" cellspacing="0">
          <tr class="head">
            <td  class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div class="caption"><$ tr("Setup") $></div></div></td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Use authentication") $>:</div></td>
            <td class="rightcol">
              <input type="checkbox" name="useauth" id="useauth" value="1"<{ CHECKIF(useauth); }> onclick="changeduseauth(this)"/>
              <div id="authsection" style="display: none">
              <table border="0" cellpadding="0" cellspacing="0" class="dependent">
              <tr>
                <td class="label"><div class="withmargin"><$ tr("Admin login") $>:</div></td>
                <td><input type="text" name="login" value="<$ login $>" id="login" onchange="setauthchanged(this)" /></td>
              </tr>
              <tr>
                <td class="label"><div class="withmargin"><$ tr("Admin password") $>:</div></td>
                <td><input  type="password" name="pass" value="<$ pass $>" id="pass" onchange="setauthchanged(this)" /></td>
              </tr>
              <tr>
                <td colspan="2" class="label"><div class="withmargin"><a href="users.html"><$ tr("User management") $></a></div></td>
              </tr>
              <tr>
                <td colspan="2" class="label"><div class="withmargin"><$ tr("Local net (no login required)") $></div></td>
              </tr>
              <tr>
                <td class="label"><div class="withmargin"><$ tr("IPv4 prefix") $>:</div></td>
                <td><input type="text" name="localnetmask" value="<$ localnetmask $>" id="localnetmask" />
                <& tooltip.help text=(tr("Example: 192.168.178.0/24")) &></td>
              </tr>
              <tr>
                <td class="label"><div class="withmargin"><$ tr("IPv6 prefix") $>:</div></td>
                <td><input type="text" name="localnetmaskIPv6" value="<$ localnetmaskIPv6 $>" id="localnetmaskIPv6" />
%               // the mootools unfortunately use "::" as separator for title and text,
%               // so we need to escape this by inserting an invisible space U+200B in-between
                <& tooltip.help text=(tr("Example: 2003:ec:6f23:ee00:&#x200B;:/64")) &></td>
              </tr>
              <tr>
                <td class="label"><div class="withmargin"><$ tr("Allow localhost") $>:</div></td>
                <td><input type="checkbox" name="allowlocalhost" value="1"<%cpp> CHECKIF(!allowlocalhost.empty()); </%cpp>/>
              </tr>
              </table>
              </div>
            </td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Show live logo image") $>:</div></td>
            <td class="rightcol">
              <input type="checkbox" name="showLogo" id="showLogo" value="1"<%cpp> CHECKIF(!showLogo.empty()); </%cpp>/>
            </td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Show dynamic VDR information box") $>:</div></td>
            <td class="rightcol">
              <input type="checkbox" name="showInfoBox" id="showInfoBox" value="1"<%cpp> CHECKIF(!showInfoBox.empty()); </%cpp>/>
            </td>
          </tr>
% if (LiveFeatures<features::streamdev_server>().Loaded()) {
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Allow video streaming") $>:</div></td>
            <td class="rightcol">
              <input type="checkbox" name="useStreamdev" id="useStreamdev" value="1"<{ CHECKIF(!useStreamdev.empty()); }>/>
            </td>
          </tr>
              <tr>
                <td class="label leftcol"><div class="withmargin"><$ tr("Streamdev server port") $>:</div></td>
                <td class="rightcol"><input type="text" name="streamdevport" id="streamdevport" value="<$ streamdevport $>" /></td>
              </tr>
              <tr>
                <td class="label leftcol"><div class="withmargin"><$ tr("Streamdev stream type") $>:</div></td>
                <td class="rightcol"><select name="streamdevtype" size="1" id="streamdevtype">
                  <option value="TS" <%cpp> SELECTIF(streamdevtype == "TS") </%cpp>>TS</option>
                  <option value="PES" <%cpp> SELECTIF(streamdevtype == "PES") </%cpp>>PES</option>
                  <option value="PS" <%cpp> SELECTIF(streamdevtype == "PS") </%cpp>>PS</option>
                  <option value="ES" <%cpp> SELECTIF(streamdevtype == "ES") </%cpp>>ES</option>
                  <option value="EXT" <%cpp> SELECTIF(streamdevtype == "EXT") </%cpp>>EXT</option>
                </select></td>
              </tr>
% }   // endif LiveFeatures<features::streamdev_server>().Loaded()
                                        <tr>
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Mark new recordings") $>:</div></td>
                                                <td class="rightcol">
                                                        <input type="checkbox" name="markNewRec" id="markNewRec" value="1"<%cpp> CHECKIF(!markNewRec.empty()); </%cpp>/>
                                                </td>
                                        </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Show link to IMDb in list views") $>:</div></td>
            <td class="rightcol">
              <input type="checkbox" name="showIMDb" id="showIMDb" value="1"<%cpp> CHECKIF(!showIMDb.empty()); </%cpp>/>
            </td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Last channel to display") $>:</div></td>
            <td class="rightcol"><input type="number" min="0" name="lastchannel" value="<$ lastchannel $>" id="lastchannel" /></td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Additional fixed times in 'What's on?'") $>:</div></td>
            <td class="rightcol"><input type="text" name="times" value="<$ times $>" id="times" />
              <& tooltip.help text=(tr("Format is HH:MM. Separate multiple times with a semicolon")) &></td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Channel groups for MultiSchedule") $>:</div></td>
            <td class="rightcol"><div class="options">
             <div class="dotted">
               <input id="channelGroupsGen_default" name="channelGroupsGen" value="default" <?? channelGroupsGen=="default"||channelGroupsGen.empty() ? "checked=\"checked\"" ?> type="radio" onclick="changedChanGroups()"/>
               <label for="channelGroupsGen_default"><$ tr("5 channels per group") $></label>
             </div>
             <div class="dotted">
               <input id="channelGroupsGen_vdr" name="channelGroupsGen" value="vdr" <?? channelGroupsGen=="vdr" ? "checked=\"checked\"" ?> type="radio" onclick="changedChanGroups()"/>
               <label for="channelGroupsGen_vdr"><$ tr("Channel groups as defined in VDR") $></label>
             </div>
             <div class="dotted">
               <input id="channelGroupsGen_flat" name="channelGroupsGen" value="flat" <?? channelGroupsGen=="flat" ? "checked=\"checked\"" ?> type="radio" onclick="changedChanGroups()"/>
               <label for="channelGroupsGen_flat"><$ tr("All channels in one group") $></label>
             </div>
             <div class="dotted">
               <input id="channelGroupsGen_individual" name="channelGroupsGen" value="individual" <?? channelGroupsGen=="individual" ? "checked=\"checked\"" ?> type="radio" onclick="changedChanGroups()"/>
               <label for="channelGroupsGen_individual"><$ tr("Individual channel groups") $></label>
             </div>
           </div>

           <div id="individual_channelGroups_section" style="display: none">
             <table border="0" cellpadding="0" cellspacing="0" class="dependent">
             <tr>
               <td class="label"><div class="withmargin"><$ tr("Channel groups") $>:</div></td>
               <td><input type="text" name="channelGroups" value="<$ channelGroups $>" id="channelGroups" />
               <& tooltip.help text=(tr("Separate channels with a comma ',', separate groups with a semi-colon ';'")) &></td>
             </tr>
             </table>
           </div>

            </td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Duration of MultiSchedule in hours") $>:</div></td>
            <td class="rightcol"><input type="number" min="1" max= "23" name="scheduleDuration" value="<$ scheduleDuration $>" id="scheduleDuration" />
              </td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Show channels without EPG") $>:</div></td>
            <td class="rightcol">
              <input type="checkbox" name="showChannelsWithoutEPG" id="showChannelsWithoutEPG" value="1"<%cpp> CHECKIF(!showChannelsWithoutEPG.empty()); </%cpp>/>
            </td>
          </tr>

          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Start page") $>:</div></td>
            <td class="rightcol"><select name="startscreen" size="1" id="startscreen">
              <option value="whatsonnow" <%cpp> SELECTIF(startscreen == "whatsonnow") </%cpp>><$ trVDR("What's on now?") $></option>
              <option value="whatsonnext" <%cpp> SELECTIF(startscreen == "whatsonnext") </%cpp>><$ trVDR("What's on next?") $></option>
              <option value="schedule" <%cpp> SELECTIF(startscreen == "schedule") </%cpp>><$ trVDR("Schedule") $></option>
              <option value="multischedule" <%cpp> SELECTIF(startscreen == "multischedule") </%cpp>><$ tr("MultiSchedule") $></option>
              <option value="recordings" <%cpp> SELECTIF(startscreen == "recordings") </%cpp>><$ trVDR("Recordings") $></option>
              <option value="timers" <%cpp> SELECTIF(startscreen == "timers") </%cpp>><$ trVDR("Timers") $></option>
            </select></td>
          </tr>
          <tr>
            <td class="label leftcol"><div class="withmargin"><$ tr("Theme") $>:</div></td>
            <td class="rightcol"><select name="theme" size="1" id="theme">
<%cpp>
{
  const std::string dirPath(Plugin::GetResourceDirectory() + "/themes");
  cReadDir d(dirPath.c_str());
  struct dirent* e;
  std::string parent("..");
  std::string current(".");
  std::string cvsDir("CVS");
  std::vector<std::string> themes;
  while ((e = d.Next())) {
    if ((current == e->d_name) || (parent == e->d_name) || (cvsDir == e->d_name)) {
      continue;
    }
    /* Check if entry is a directory: I do not rely on e->d_type
    ** here because on some systems it is always DT_UNKNOWN. Also
    ** testing for DT_DIR does not take into account symbolic
    ** links to directories.
    */
    struct stat buf;
    if ((stat((dirPath + "/" + e->d_name).c_str(), &buf) != 0) || (!S_ISDIR(buf.st_mode))) {
      continue;
    }
    themes.push_back(e->d_name);
  }
  // get theme names sorted for selection
  std::sort(themes.begin(), themes.end());
  for (auto name: themes)
  {
</%cpp>
              <option value="<$ name $>" <%cpp> SELECTIF(theme == name) </%cpp>><$ name $></option>
<%cpp>
  }
}
</%cpp>
            </select></td>
          </tr>
          <tr>
            <td class="buttonpanel leftcol rightcol bottomrow" colspan="2">
              <div class="withmargin">
              <button class="green" type="submit" name="save" ><$ tr("Save") $></button>
              </div>
            </td>
          </tr>
        </table>
      </form>
      <div class="spacebar"><# spacer with fade-out effect #></div>
    </div>
  </body>
</html>

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