<%pre>

#include <setup.h>
#include <recman.h>
#include <vdr/menu.h>

using namespace vdrlive;

</%pre>
<%args>
  std::string param;
</%args>
<%session scope="global">
  bool logged_in(false);
</%session>
<%cpp>
  if (!logged_in && LiveSetup().UseAuth()) {
    cToSvConcat targetUrl = "/login.html?redirect=";
    targetUrl.appendUrlEscaped(request.getQuery());
    return reply.redirect(targetUrl.data());
  }
  reply.setContentType( "application/xml" );

  const char *error_message = "";
  {
    LOCK_RECORDINGS_READ;
    const cRecording *recording = RecordingsManager::GetByHash(param, Recordings);
    if (!recording)
      error_message = tr("Couldn't find recording or no recordings available.");
  }

  if (*error_message == 0) {
    const char *current = cReplayControl::NowReplaying();
    if (!current) {
      error_message = tr("Not playing a recording.");
    } else {
      cReplayControl::SetRecording(0);
      cControl::Shutdown();
    }
  }

</%cpp>
<& xmlresponse.ajax name=("stop_recording") pname=("recording") value=(param) result=(*error_message == 0) error=(error_message) &>
