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
|
/*
* A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* File: pin.h
*
*/
#ifndef __PIN_H__
#define __PIN_H__
//***************************************************************************
// Includes
//***************************************************************************
#include <vdr/status.h>
#include <vdr/plugin.h>
#include "locks.h"
#include "def.h"
#include "talk.h"
//***************************************************************************
// Constants
//***************************************************************************
static const char *VERSION = "0.1.17";
static const char *DESCRIPTION = "Childlock plugin";
static const char *MAINMENUENTRY = tr("Childlock");
#define PROTECTION_FILE "protection.fsk"
// #define __DEBUG__
//***************************************************************************
// Pin Service
//***************************************************************************
class PinService
{
public:
enum Size
{
sizePinCode = 5
};
enum ListType
{
ltUnknown = na,
ltChannels,
ltBroadcasts,
ltPlugins,
ltMenuItems
};
class Translation : public cListObject
{
public:
char in[200+TB];
char out[200+TB];
};
};
class Translations : public cList<PinService::Translation>, PinService
{
public:
void append(const char* in, const char* out);
const char* lookup(const char* in);
};
//***************************************************************************
// Message Reciver
//***************************************************************************
class MessageReceiver : public cThread
{
public:
MessageReceiver();
~MessageReceiver();
int StartReceiver();
int StopReceiver();
protected:
void Action();
int wait();
// data
Talk* talk;
int pid;
bool active;
};
//***************************************************************************
// Pin Status Monitor
//***************************************************************************
class cPinStatusMonitor : public cStatus
{
protected:
// interface
virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber, bool LiveView);
virtual bool ChannelProtected(const cDevice *Device, const cChannel* Channel);
virtual bool ReplayProtected(const cRecording* Recording, const char* Name,
const char* Base, bool isDirectory, int menuView = false);
virtual void RecordingFile(const char* FileName);
virtual void TimerCreation(cTimer* Timer, const cEvent *Event);
virtual bool PluginProtected(cPlugin* Plugin, int menuView = false);
virtual bool MenuItemProtected(const char* Name, int menuView = false);
#if defined (APIVERSNUM) && (APIVERSNUM >= 20301)
virtual void UserAction(const eKeys key);
#else
virtual void UserAction(const eKeys key, const cOsdObject* Interact);
#endif
// internal stuff
const cEvent* GetEventOf(const cSchedules* schedules, const cChannel* Channel);
Translations translations;
};
//***************************************************************************
// Pin
//***************************************************************************
class cPin : public cOsdObject, public PinService
{
public:
cPin(void);
virtual ~cPin();
virtual void Show(void);
virtual eOSState ProcessKey(eKeys Key);
void clear();
private:
cOsd* osd;
int textWidth;
const char* pinTxt;
char code[sizePinCode+TB];
cSkinDisplayMessage* display;
int pinSetup;
};
//***************************************************************************
// Pin Plugin
//***************************************************************************
class cPinPlugin : public cPlugin, public PinService
{
public:
enum AutoProtectionMode
{
apmUnknown = na,
apmAlways,
apmIntelligent,
apmNever,
apmCount
};
cPinPlugin(void);
virtual ~cPinPlugin();
const char* CommandLineHelp(void) { return 0; }
bool ProcessArgs(int argc, char *argv[]) { return true; }
bool Start(void);
void Stop(void);
void Housekeeping(void) {}
virtual cMenuSetupPage *SetupMenu(void);
virtual bool SetupParse(const char *Name, const char *Value);
const char* Version(void) { return VERSION; }
const char* Description(void) { return trNOOP(DESCRIPTION); }
virtual bool Initialize(void);
virtual const char* MainMenuEntry(void) { return tr(MAINMENUENTRY); }
virtual cOsdObject* MainMenuAction(void);
void addChannel();
void delChannel();
int channelProtected(const char* name, long startTime = 0);
int pluginProtected(const char* name);
int menuItemProtected(const char* text);
int menuItemAppend(const char* text);
int broadcastProtected(const char* title);
void checkActivity();
int initPluginList();
void StorePin();
static cPinPlugin* getObject() { return object; }
// static config items
static char pinCode[sizePinCode+TB];
static bool skipChannelSilent;
static bool hideProtectedMenus;
static bool hideProtectedPlugins;
static bool hideProtectedRecordings;
static int pinResetTime;
static bool autoMenuOpen;
static int autoProtectionMode;
// other static stuff
static const char* autoProtectionModes[apmCount+1];
protected:
// data
cLockItems lockedChannels;
cLockedBroadcasts lockedBroadcasts;
cLockItems lockedPlugins;
cLockItems lockedMenuItems;
time_t lastAction;
cPinStatusMonitor* statusMonitor;
MessageReceiver* receiver;
static cPinPlugin* object; // the object
};
//***************************************************************************
#endif // __PIN_H__
|