blob: bf2155374c5ed8b6c0102893bde13bc790b5dd51 (
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
|
#include "switchtimer.h"
cSwitchTimers SwitchTimers;
// -- cSwitchTimer -----------------------------------------------------------------
cSwitchTimer::cSwitchTimer(void) {
eventID = 0;
startTime = 0;
switchMinsBefore = 2;
announceOnly = 0;
}
cSwitchTimer::cSwitchTimer(const cEvent* Event) {
eventID = 0;
startTime = 0;
if (Event) {
eventID = Event->EventID();
channelID = Event->ChannelID();
startTime = Event->StartTime();
}
}
#if VDRVERSNUM >= 20305
cSwitchTimer& cSwitchTimer::operator= (const cSwitchTimer &SwitchTimer)
{
this->eventID = SwitchTimer.eventID;
this->startTime = SwitchTimer.startTime;
this->channelID = SwitchTimer.channelID;
this->switchMinsBefore = SwitchTimer.switchMinsBefore;
return *this;
}
#endif
bool cSwitchTimer::Parse(const char *s) {
char *line;
char *pos;
char *pos_next;
int parameter = 1;
int valuelen;
#define MAXVALUELEN (10 * MaxFileName)
char value[MAXVALUELEN];
startTime=0;
pos = line = strdup(s);
pos_next = pos + strlen(pos);
if (*pos_next == '\n') *pos_next = 0;
while (*pos) {
while (*pos == ' ')
pos++;
if (*pos) {
if (*pos != ':') {
pos_next = strchr(pos, ':');
if (!pos_next)
pos_next = pos + strlen(pos);
valuelen = pos_next - pos + 1;
if (valuelen > MAXVALUELEN)
valuelen = MAXVALUELEN;
strn0cpy(value, pos, valuelen);
pos = pos_next;
switch (parameter) {
case 1:
channelID = tChannelID::FromString(value);
break;
case 2:
eventID = atoi(value);
break;
case 3:
startTime = atol(value);
break;
default:
break;
}
}
parameter++;
}
if (*pos)
pos++;
}
free(line);
return (parameter >= 3) ? true : false;
}
bool cSwitchTimers::EventInSwitchList(const cEvent* event) {
if (!event) return false;
cMutexLock SwitchTimersLock(this);
cSwitchTimer* switchTimer = SwitchTimers.First();
while (switchTimer) {
if (switchTimer->eventID == event->EventID())
return true;
switchTimer = SwitchTimers.Next(switchTimer);
}
return false;
}
bool cSwitchTimers::ChannelInSwitchList(const cChannel* channel) {
if (!channel) return false;
cMutexLock SwitchTimersLock(this);
cSwitchTimer* switchTimer = SwitchTimers.First();
while (switchTimer) {
if (switchTimer->channelID == channel->GetChannelID())
return true;
switchTimer = SwitchTimers.Next(switchTimer);
}
return false;
}
void cSwitchTimers::DeleteSwitchTimer(const cEvent *event) {
if (!event) return;
cMutexLock SwitchTimersLock(this);
cSwitchTimer* switchTimer = SwitchTimers.First();
cSwitchTimer* delTimer = NULL;
while (switchTimer) {
if (switchTimer->eventID == event->EventID()) {
delTimer = switchTimer;
break;
}
switchTimer = SwitchTimers.Next(switchTimer);
}
if (delTimer) {
SwitchTimers.Del(delTimer, true);
}
}
|