77#include <vdr/eit.h>
88#include <vdr/epg.h>
99#include <vdr/svdrp.h>
10+ #include <vdr/timers.h>
1011
1112
1213namespace 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