Skip to content

Commit 364b82c

Browse files
committed
add support for vdr 2.3.1
1 parent 111ebef commit 364b82c

File tree

9 files changed

+245
-59
lines changed

9 files changed

+245
-59
lines changed

HISTORY

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,6 @@ VDR Plugin 'dbus2vdr' Revision History
233233

234234
2013-07-10: Version 14
235235
- add method "IsReplaying" to status interface
236+
237+
2015-09-30: Version 26
238+
- make compatible with vdr 2.3.1

channel.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace cDBusChannelsHelper
2929
" </interface>\n"
3030
"</node>\n";
3131

32-
static void AddChannel(GVariantBuilder *Array, cChannel *Channel)
32+
static void AddChannel(GVariantBuilder *Array, const cChannel *Channel)
3333
{
3434
if (Channel == NULL)
3535
return;
@@ -46,7 +46,14 @@ namespace cDBusChannelsHelper
4646

4747
static void Count(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
4848
{
49-
g_dbus_method_invocation_return_value(Invocation, g_variant_new("(i)", Channels.Count()));
49+
const cChannels *channels = NULL;
50+
#if VDRVERSNUM > 20300
51+
LOCK_CHANNELS_READ;
52+
channels = Channels;
53+
#else
54+
channels = &Channels;
55+
#endif
56+
g_dbus_method_invocation_return_value(Invocation, g_variant_new("(i)", channels->Count()));
5057
}
5158

5259
static void GetFromTo(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
@@ -60,10 +67,17 @@ namespace cDBusChannelsHelper
6067

6168
GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(is)"));
6269

63-
cChannel *c = Channels.Get(from_index);
70+
const cChannels *channels = NULL;
71+
#if VDRVERSNUM > 20300
72+
LOCK_CHANNELS_READ;
73+
channels = Channels;
74+
#else
75+
channels = &Channels;
76+
#endif
77+
const cChannel *c = channels->Get(from_index);
6478
while ((c != NULL) && (to_index >= from_index)) {
6579
cDBusChannelsHelper::AddChannel(array, c);
66-
c = Channels.Next(c);
80+
c = channels->Next(c);
6781
to_index--;
6882
}
6983

@@ -85,9 +99,16 @@ namespace cDBusChannelsHelper
8599

86100
GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(is)"));
87101

102+
const cChannels *channels = NULL;
103+
#if VDRVERSNUM > 20300
104+
LOCK_CHANNELS_READ;
105+
channels = Channels;
106+
#else
107+
channels = &Channels;
108+
#endif
88109
if ((option != NULL) && *option && !withGroupSeps) {
89110
if (isnumber(option)) {
90-
cChannel *channel = Channels.GetByNumber(strtol(option, NULL, 10));
111+
const cChannel *channel = channels->GetByNumber(strtol(option, NULL, 10));
91112
if (channel)
92113
cDBusChannelsHelper::AddChannel(array, channel);
93114
else {
@@ -96,9 +117,9 @@ namespace cDBusChannelsHelper
96117
}
97118
}
98119
else {
99-
cChannel *next = Channels.GetByChannelID(tChannelID::FromString(option));
120+
const cChannel *next = channels->GetByChannelID(tChannelID::FromString(option));
100121
if (!next) {
101-
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
122+
for (const cChannel *channel = channels->First(); channel; channel = channels->Next(channel)) {
102123
if (!channel->GroupSep()) {
103124
if (strcasestr(channel->Name(), option)) {
104125
if (next)
@@ -116,8 +137,8 @@ namespace cDBusChannelsHelper
116137
}
117138
}
118139
}
119-
else if (Channels.MaxNumber() >= 1) {
120-
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
140+
else if (channels->MaxNumber() >= 1) {
141+
for (const cChannel *channel = channels->First(); channel; channel = channels->Next(channel)) {
121142
if (withGroupSeps || !channel->GroupSep())
122143
cDBusChannelsHelper::AddChannel(array, channel);
123144
}

dbus2vdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "avahi-helper.h"
3838

3939

40-
static const char *VERSION = "25";
40+
static const char *VERSION = "26";
4141
static const char *DESCRIPTION = trNOOP("control vdr via D-Bus");
4242
static const char *MAINMENUENTRY = NULL;
4343

epg.c

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <vdr/eit.h>
88
#include <vdr/epg.h>
99
#include <vdr/svdrp.h>
10+
#include <vdr/timers.h>
1011

1112

1213
namespace cDBusEpgHelper
@@ -110,13 +111,27 @@ namespace cDBusEpgHelper
110111
tChannelID ChannelID = tChannelID::InvalidID;
111112
if (isnumber(channel)) {
112113
int o = strtol(channel, NULL, 10);
113-
if (o >= 1 && o <= Channels.MaxNumber())
114-
ChannelID = Channels.GetByNumber(o)->GetChannelID();
114+
const cChannels *channels = NULL;
115+
#if VDRVERSNUM > 20300
116+
LOCK_CHANNELS_READ;
117+
channels = Channels;
118+
#else
119+
channels = &Channels;
120+
#endif
121+
if (o >= 1 && o <= channels->MaxNumber())
122+
ChannelID = channels->GetByNumber(o)->GetChannelID();
115123
}
116124
else {
117125
ChannelID = tChannelID::FromString(channel);
118126
if (ChannelID == tChannelID::InvalidID) {
119-
for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) {
127+
const cChannels *channels = NULL;
128+
#if VDRVERSNUM > 20300
129+
LOCK_CHANNELS_READ;
130+
channels = Channels;
131+
#else
132+
channels = &Channels;
133+
#endif
134+
for (const cChannel *Channel = channels->First(); Channel; Channel = channels->Next(Channel)) {
120135
if (!Channel->GroupSep()) {
121136
if (strcasecmp(Channel->Name(), channel) == 0) {
122137
ChannelID = Channel->GetChannelID();
@@ -127,8 +142,13 @@ namespace cDBusEpgHelper
127142
}
128143
}
129144
if (!(ChannelID == tChannelID::InvalidID)) {
145+
#if VDRVERSNUM > 20300
146+
cStateKey StateKey;
147+
cSchedules *s = cSchedules::GetSchedulesWrite(StateKey, 1000);
148+
#else
130149
cSchedulesLock SchedulesLock(true, 1000);
131150
cSchedules *s = (cSchedules *)cSchedules::Schedules(SchedulesLock);
151+
#endif
132152
if (s) {
133153
cSchedule *Schedule = NULL;
134154
ChannelID.ClrRid();
@@ -150,6 +170,9 @@ namespace cDBusEpgHelper
150170
cString replyMessage = cString::sprintf("No EPG data found for channel \"%s\"", channel);
151171
cDBusHelper::SendReply(Invocation, 550, *replyMessage);
152172
}
173+
#if VDRVERSNUM > 20300
174+
StateKey.Remove();
175+
#endif
153176
}
154177
else
155178
cDBusHelper::SendReply(Invocation, 451, "Can't get EPG data");
@@ -160,10 +183,17 @@ namespace cDBusEpgHelper
160183
}
161184
}
162185
else {
186+
#if VDRVERSNUM > 20300
187+
LOCK_TIMERS_WRITE;
188+
LOCK_SCHEDULES_WRITE;
189+
for (cTimer *Timer = Timers->First(); Timer; Timer = Timers->Next(Timer))
190+
Timer->SetEvent(NULL); // processing all timers here (local *and* remote)
191+
for (cSchedule *Schedule = Schedules->First(); Schedule; Schedule = Schedules->Next(Schedule))
192+
Schedule->Cleanup(INT_MAX);
193+
#else
163194
cSchedules::ClearAll();
164-
#if APIVERSNUM >= 10711
195+
#endif
165196
cEitFilter::SetDisableUntil(time(NULL) + eitDisableTime);
166-
#endif
167197
cDBusHelper::SendReply(Invocation, 250, "EPG data cleared");
168198
}
169199
};
@@ -179,6 +209,9 @@ namespace cDBusEpgHelper
179209
return;
180210
}
181211

212+
#if VDRVERSNUM > 20300
213+
cDBusHelper::SendReply(Invocation, 554, "cPUTEHandler not available in vdr 2.3.1");
214+
#else
182215
cPUTEhandler *handler = new cPUTEhandler();
183216
if (handler->Status() == 354) {
184217
for (gsize i = 0; i < len; i++) {
@@ -193,6 +226,7 @@ namespace cDBusEpgHelper
193226
}
194227
cDBusHelper::SendReply(Invocation, handler->Status(), handler->Message());
195228
delete handler;
229+
#endif
196230
g_free(line);
197231
};
198232

@@ -285,7 +319,7 @@ namespace cDBusEpgHelper
285319
g_variant_builder_unref(arr);
286320
}
287321

288-
static bool sGetChannel(GVariant *Arg, const char **Input, cChannel **Channel)
322+
static bool sGetChannel(GVariant *Arg, const char **Input, const cChannels* Channels, const cChannel **Channel)
289323
{
290324
*Channel = NULL;
291325
*Input = NULL;
@@ -294,9 +328,9 @@ namespace cDBusEpgHelper
294328
if (**Input == 0)
295329
return true;
296330
if (isnumber(*Input))
297-
*Channel = Channels.GetByNumber(strtol(*Input, NULL, 10));
331+
*Channel = Channels->GetByNumber(strtol(*Input, NULL, 10));
298332
else
299-
*Channel = Channels.GetByChannelID(tChannelID::FromString(*Input));
333+
*Channel = Channels->GetByChannelID(tChannelID::FromString(*Input));
300334
if (*Channel == NULL)
301335
return false;
302336
}
@@ -320,12 +354,19 @@ namespace cDBusEpgHelper
320354

321355
static void sGetEntries(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation, eMode mode)
322356
{
323-
cChannel *channel = NULL;
357+
const cChannels *channels = NULL;
358+
#if VDRVERSNUM > 20300
359+
LOCK_CHANNELS_READ;
360+
channels = Channels;
361+
#else
362+
channels = &Channels;
363+
#endif
364+
const cChannel *channel = NULL;
324365
guint64 atTime = 0;
325366
GVariant *first = g_variant_get_child_value(Parameters, 0);
326367

327368
const char *c = NULL;
328-
if (!sGetChannel(first, &c, &channel)) {
369+
if (!sGetChannel(first, &c, channels, &channel)) {
329370
cString reply = cString::sprintf("channel \"%s\" not defined", c);
330371
esyslog("dbus2vdr: %s.GetEntries: %s", DBUS_VDR_EPG_INTERFACE, *reply);
331372
sReturnError(Invocation, 501, *reply);
@@ -346,13 +387,19 @@ namespace cDBusEpgHelper
346387
}
347388
g_variant_unref(first);
348389

390+
const cSchedules *scheds = NULL;
391+
#if VDRVERSNUM > 20300
392+
cStateKey StateKey;
393+
scheds = cSchedules::GetSchedulesRead(StateKey, 1000);
394+
#else
349395
cSchedulesLock sl(false, 1000);
350396
if (!sl.Locked()) {
351397
sReturnError(Invocation, 550, "got no lock on schedules");
352398
return;
353399
}
354400

355-
const cSchedules *scheds = cSchedules::Schedules(sl);
401+
scheds = cSchedules::Schedules(sl);
402+
#endif
356403
if (scheds == NULL) {
357404
sReturnError(Invocation, 550, "got no schedules");
358405
return;
@@ -365,7 +412,7 @@ namespace cDBusEpgHelper
365412

366413
bool next = false;
367414
if (channel == NULL) {
368-
channel = Channels.First();
415+
channel = channels->First();
369416
next = true;
370417
}
371418

@@ -391,11 +438,14 @@ namespace cDBusEpgHelper
391438
sAddEvent(array, *e);
392439
}
393440
if (next)
394-
channel = Channels.Next(channel);
441+
channel = channels->Next(channel);
395442
else
396443
break;
397444
}
398445

446+
#if VDRVERSNUM > 20300
447+
StateKey.Remove();
448+
#endif
399449
g_variant_builder_add_value(builder, g_variant_builder_end(array));
400450
g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
401451
g_variant_builder_unref(array);

0 commit comments

Comments
 (0)