@@ -39,6 +39,12 @@ class cDBusRecordingsHelper
3939 c = recording -> Name ();
4040 if (c != NULL )
4141 cDBusHelper ::AddKeyValue (array , "Name" , "s" , (void * * )& c );
42+ #ifdef HIDE_FIRST_RECORDING_LEVEL_PATCH
43+ s = recording -> FullName ();
44+ c = * s ;
45+ if (c != NULL )
46+ cDBusHelper ::AddKeyValue (array , "FullName" , "s" , (void * * )& c );
47+ #endif
4248 c = recording -> Title ();
4349 if (c != NULL )
4450 cDBusHelper ::AddKeyValue (array , "Title" , "s" , (void * * )& c );
@@ -273,6 +279,84 @@ class cDBusRecordingsHelper
273279 g_variant_unref (second );
274280 };
275281
282+ static void ChangeName (cDBusObject * Object , GVariant * Parameters , GDBusMethodInvocation * Invocation )
283+ {
284+ int replyCode = 501 ;
285+ cString replyMessage ;
286+ cRecording * recording = NULL ;
287+
288+ GVariant * first = g_variant_get_child_value (Parameters , 0 );
289+ GVariant * refFirst = first ;
290+ if (g_variant_is_of_type (first , G_VARIANT_TYPE_VARIANT ))
291+ refFirst = g_variant_get_child_value (first , 0 );
292+
293+ const char * newName = NULL ;
294+ g_variant_get_child (Parameters , 1 , "&s" , & newName );
295+ if ((newName == NULL ) || (newName [0 ] == 0 ))
296+ replyMessage = "Missing new recording name" ;
297+
298+ if (g_variant_is_of_type (refFirst , G_VARIANT_TYPE_STRING )) {
299+ const char * path = NULL ;
300+ g_variant_get (refFirst , "&s" , & path );
301+ if ((path != NULL ) && * path ) {
302+ recording = recordings .GetByName (path );
303+ if (recording == NULL ) {
304+ recordings .Update (true);
305+ recording = recordings .GetByName (path );
306+ if (recording == NULL )
307+ replyMessage = cString ::sprintf ("recording \"%s\" not found" , path );
308+ }
309+ }
310+ }
311+ else if (g_variant_is_of_type (refFirst , G_VARIANT_TYPE_INT32 )) {
312+ int number = 0 ;
313+ g_variant_get (refFirst , "i" , & number );
314+ if (number > 0 ) {
315+ recording = recordings .Get (number - 1 );
316+ if (recording == NULL ) {
317+ recordings .Update (true);
318+ recording = recordings .Get (number - 1 );
319+ if (recording == NULL )
320+ replyMessage = cString ::sprintf ("recording \"%d\" not found" , number );
321+ }
322+ }
323+ }
324+
325+ if ((recording != NULL ) && (newName != NULL ) && (newName [0 ] != 0 )) {
326+ if (int RecordingInUse = recording -> IsInUse ()) {
327+ replyCode = 550 ;
328+ replyMessage = cString ::sprintf ("recording is in use, reason %d" , RecordingInUse );
329+ }
330+ else {
331+ #ifdef HIDE_FIRST_RECORDING_LEVEL_PATCH
332+ cString oldName = recording -> FullName ();
333+ #else
334+ cString oldName = recording -> Name ();
335+ #endif
336+ if (recording -> ChangeName (newName )) {
337+ // update list of vdr
338+ Recordings .Update (false);
339+ replyCode = 250 ;
340+ #ifdef HIDE_FIRST_RECORDING_LEVEL_PATCH
341+ cString name = recording -> FullName ();
342+ #else
343+ cString name = recording -> Name ();
344+ #endif
345+ replyMessage = cString ::sprintf ("Recording \"%s\" moved to \"%s\"" , * oldName , * name );
346+ }
347+ else {
348+ replyCode = 554 ;
349+ replyMessage = cString ::sprintf ("Error while moving recording \"%s\" to \"%s\"!" , * oldName , newName );
350+ }
351+ }
352+ }
353+
354+ cDBusHelper ::SendReply (Invocation , replyCode , * replyMessage );
355+ if (refFirst != first )
356+ g_variant_unref (refFirst );
357+ g_variant_unref (first );
358+ };
359+
276360 static void ListExtraVideoDirectories (cDBusObject * Object , GVariant * Parameters , GDBusMethodInvocation * Invocation )
277361 {
278362 int replyCode = 500 ;
@@ -399,11 +483,13 @@ const char *cDBusRecordingsHelper::_xmlNodeInfoConst =
399483 " <method name=\"List\">\n"
400484 " <arg name=\"recordings\" type=\"a(ia(sv))\" direction=\"out\"/>\n"
401485 " </method>\n"
486+ #ifdef EXTRA_VIDEO_DIRECTORIES_PATCH
402487 " <method name=\"ListExtraVideoDirectories\">\n"
403488 " <arg name=\"replycode\" type=\"i\" direction=\"out\"/>\n"
404489 " <arg name=\"replymessage\" type=\"s\" direction=\"out\"/>\n"
405490 " <arg name=\"extravideodirs\" type=\"as\" direction=\"out\"/>\n"
406491 " </method>\n"
492+ #endif
407493 " < /interface > \n "
408494 " < /node > \n ";
409495
@@ -429,6 +515,13 @@ const char *cDBusRecordingsHelper::_xmlNodeInfo =
429515 " <arg name=\"replycode\" type=\"i\" direction=\"out\"/>\n"
430516 " <arg name=\"replymessage\" type=\"s\" direction=\"out\"/>\n"
431517 " </method>\n"
518+ " <method name=\"ChangeName\">\n"
519+ " <arg name=\"number_or_path\" type=\"v\" direction=\"in\"/>\n"
520+ " <arg name=\"newname\" type=\"s\" direction=\"in\"/>\n"
521+ " <arg name=\"replycode\" type=\"i\" direction=\"out\"/>\n"
522+ " <arg name=\"replymessage\" type=\"s\" direction=\"out\"/>\n"
523+ " </method>\n"
524+ #ifdef EXTRA_VIDEO_DIRECTORIES_PATCH
432525 " <method name=\"AddExtraVideoDirectory\">\n"
433526 " <arg name=\"option\" type=\"s\" direction=\"in\"/>\n"
434527 " <arg name=\"replycode\" type=\"i\" direction=\"out\"/>\n"
@@ -448,6 +541,7 @@ const char *cDBusRecordingsHelper::_xmlNodeInfo =
448541 " <arg name=\"replymessage\" type=\"s\" direction=\"out\"/>\n"
449542 " <arg name=\"extravideodirs\" type=\"as\" direction=\"out\"/>\n"
450543 " </method>\n"
544+ #endif
451545 " < /interface > \n "
452546 " < /node > \n ";
453547
@@ -457,15 +551,19 @@ cDBusRecordingsConst::cDBusRecordingsConst(const char *NodeInfo)
457551{
458552 AddMethod (" Get ", cDBusRecordingsHelper::Get);
459553 AddMethod ("List" , cDBusRecordingsHelper ::List );
554+ #ifdef EXTRA_VIDEO_DIRECTORIES_PATCH
460555 AddMethod ("ListExtraVideoDirectories" , cDBusRecordingsHelper ::ListExtraVideoDirectories );
556+ #endif
461557}
462558
463559cDBusRecordingsConst ::cDBusRecordingsConst (void )
464560:cDBusObject ("/Recordings" , cDBusRecordingsHelper ::_xmlNodeInfoConst )
465561{
466562 AddMethod ("Get" , cDBusRecordingsHelper ::Get );
467563 AddMethod ("List" , cDBusRecordingsHelper ::List );
564+ #ifdef EXTRA_VIDEO_DIRECTORIES_PATCH
468565 AddMethod ("ListExtraVideoDirectories" , cDBusRecordingsHelper ::ListExtraVideoDirectories );
566+ #endif
469567}
470568
471569cDBusRecordingsConst ::~cDBusRecordingsConst (void )
@@ -477,9 +575,11 @@ cDBusRecordings::cDBusRecordings(void)
477575{
478576 AddMethod ("Update" , cDBusRecordingsHelper ::Update );
479577 AddMethod ("Play" , cDBusRecordingsHelper ::Play );
578+ #ifdef EXTRA_VIDEO_DIRECTORIES_PATCH
480579 AddMethod ("AddExtraVideoDirectory" , cDBusRecordingsHelper ::AddExtraVideoDirectory );
481580 AddMethod ("ClearExtraVideoDirectories" , cDBusRecordingsHelper ::ClearExtraVideoDirectories );
482581 AddMethod ("DeleteExtraVideoDirectory" , cDBusRecordingsHelper ::DeleteExtraVideoDirectory );
582+ #endif
483583}
484584
485585cDBusRecordings ::~cDBusRecordings (void )
0 commit comments