@@ -197,6 +197,69 @@ namespace cDBusEpgHelper
197
197
}
198
198
};
199
199
200
+ #if VDRVERSNUM > 20300
201
+ // copied from svdrp.c, maybe it will be available in future versions?
202
+ // --- cPUTEhandler ----------------------------------------------------------
203
+
204
+ class cPUTEhandler {
205
+ private :
206
+ FILE * f ;
207
+ int status ;
208
+ const char * message ;
209
+ public :
210
+ cPUTEhandler (void );
211
+ ~cPUTEhandler ();
212
+ bool Process (const char * s );
213
+ int Status (void ) { return status ; }
214
+ const char * Message (void ) { return message ; }
215
+ };
216
+
217
+ cPUTEhandler ::cPUTEhandler (void )
218
+ {
219
+ if ((f = tmpfile ()) != NULL ) {
220
+ status = 354 ;
221
+ message = "Enter EPG data, end with \".\" on a line by itself" ;
222
+ }
223
+ else {
224
+ LOG_ERROR ;
225
+ status = 554 ;
226
+ message = "Error while opening temporary file" ;
227
+ }
228
+ }
229
+
230
+ cPUTEhandler ::~cPUTEhandler ()
231
+ {
232
+ if (f )
233
+ fclose (f );
234
+ }
235
+
236
+ bool cPUTEhandler ::Process (const char * s )
237
+ {
238
+ if (f ) {
239
+ if (strcmp (s , "." ) != 0 ) {
240
+ fputs (s , f );
241
+ fputc ('\n' , f );
242
+ return true;
243
+ }
244
+ else {
245
+ rewind (f );
246
+ if (cSchedules ::Read (f )) {
247
+ cSchedules ::Cleanup (true);
248
+ status = 250 ;
249
+ message = "EPG data processed" ;
250
+ }
251
+ else {
252
+ status = 451 ;
253
+ message = "Error while processing EPG data" ;
254
+ }
255
+ fclose (f );
256
+ f = NULL ;
257
+ }
258
+ }
259
+ return false;
260
+ }
261
+ #endif
262
+
200
263
static void PutEntry (cDBusObject * Object , GVariant * Parameters , GDBusMethodInvocation * Invocation )
201
264
{
202
265
gsize len = 0 ;
@@ -208,9 +271,6 @@ namespace cDBusEpgHelper
208
271
return ;
209
272
}
210
273
211
- #if VDRVERSNUM > 20300
212
- cDBusHelper ::SendReply (Invocation , 554 , "cPUTEHandler not available in vdr 2.3.1" );
213
- #else
214
274
cPUTEhandler * handler = new cPUTEhandler ();
215
275
if (handler -> Status () == 354 ) {
216
276
for (gsize i = 0 ; i < len ; i ++ ) {
@@ -225,7 +285,6 @@ namespace cDBusEpgHelper
225
285
}
226
286
cDBusHelper ::SendReply (Invocation , handler -> Status (), handler -> Message ());
227
287
delete handler ;
228
- #endif
229
288
g_free (line );
230
289
};
231
290
0 commit comments