From patchwork Mon Jan 16 21:56:19 2006 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schwarzott X-Patchwork-Id: 12164 Received: from mail-out.m-online.net ([212.18.0.9]) by www.linuxtv.org with esmtp (Exim 4.50) id 1EycKW-0007VR-L7 for vdr@linuxtv.org; Mon, 16 Jan 2006 22:56:00 +0100 Received: from mail01.m-online.net (svr21.m-online.net [192.168.3.149]) by mail-out.m-online.net (Postfix) with ESMTP id 4FD7770F6A for ; Mon, 16 Jan 2006 22:55:59 +0100 (CET) Received: from gauss.x.fun (DSL01.83.171.144.136.NEFkom.net [83.171.144.136]) by mail.nefkom.net (Postfix) with ESMTP id 17DB3B8B53 for ; Mon, 16 Jan 2006 22:55:59 +0100 (CET) Received: by gauss.x.fun (Postfix, from userid 1003) id 7B9F3DCB8E2; Mon, 16 Jan 2006 22:56:20 +0100 (CET) From: Matthias Schwarzott To: vdr@linuxtv.org Date: Mon, 16 Jan 2006 22:56:19 +0100 User-Agent: KMail/1.9 MIME-Version: 1.0 Message-Id: <200601162256.20192.zzam@gentoo.org> Subject: [vdr] [ANNOUNCE] svdrp shutdown patch 0.1 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jan 2006 21:56:00 -0000 Status: O X-Status: X-Keywords: X-UID: 7242 Hallo! This is the first release of my "svdrp shutdown patch". It adds the new svdrp-command "DOWN". This command triggers an automatic shutdown like the one when reaching minuserinactivity. An optional given number is the additional time in minutes after which this shutdown should start by showing "press any key to abort shutdown" for 5min. It is mainly thought to replace svdrpsend.pl hitk power inside some scripts by svdrpsend.pl down to give the user 5minutes to abort shutdown instead of some seconds. Our primary use is inside the shutdown-script in the abort-case (for example there are user logged in) to trigger a shutdown-retry in 5 or 10 minutes. Matthias diff -ru --exclude='*.o' vdr-1.3.36-orig/svdrp.c vdr-1.3.36/svdrp.c --- vdr-1.3.36-orig/svdrp.c 2005-12-29 00:02:26.000000000 +0100 +++ vdr-1.3.36/svdrp.c 2005-12-29 00:18:45.000000000 +0100 @@ -293,6 +293,9 @@ " Updates a timer. Settings must be in the same format as returned\n" " by the LSTT command. If a timer with the same channel, day, start\n" " and stop time does not yet exists, it will be created.", + "DOWN [ ]\n" + " Starts an automatic shutdown (with 5 minutes waiting time) in given\n" + " minutes or now if no number was given.", "VOLU [ | + | - | mute ]\n" " Set the audio volume to the given number (which is limited to the range\n" " 0...255). If the special options '+' or '-' are given, the volume will\n" @@ -1342,6 +1345,16 @@ Reply(501, "Missing timer settings"); } +extern time_t LastActivity; +void cSVDRP::CmdDOWN(const char *Option) +{ + if (isnumber(Option)) + LastActivity = time(NULL) - Setup.MinUserInactivity*60 + strtol(Option, NULL, 10)*60; + else + LastActivity = time(NULL) - Setup.MinUserInactivity*60; + Reply(250, "Automatic shutdown triggered"); +} + void cSVDRP::CmdVOLU(const char *Option) { if (*Option) { @@ -1413,6 +1426,7 @@ else if (CMD("STAT")) CmdSTAT(s); else if (CMD("UPDT")) CmdUPDT(s); else if (CMD("VOLU")) CmdVOLU(s); + else if (CMD("DOWN")) CmdDOWN(s); else if (CMD("QUIT")) Close(); else Reply(500, "Command unrecognized: \"%s\"", Cmd); } diff -ru --exclude='*.o' vdr-1.3.36-orig/svdrp.h vdr-1.3.36/svdrp.h --- vdr-1.3.36-orig/svdrp.h 2005-12-29 00:02:26.000000000 +0100 +++ vdr-1.3.36/svdrp.h 2005-12-30 02:28:08.000000000 +0100 @@ -59,6 +59,7 @@ void CmdDELC(const char *Option); void CmdDELR(const char *Option); void CmdDELT(const char *Option); + void CmdDOWN(const char *Option); void CmdEDIT(const char *Option); void CmdGRAB(const char *Option); void CmdHELP(const char *Option); diff -ru --exclude='*.o' vdr-1.3.36-orig/vdr.c vdr-1.3.36/vdr.c --- vdr-1.3.36-orig/vdr.c 2005-12-29 00:02:26.000000000 +0100 +++ vdr-1.3.36/vdr.c 2005-12-29 00:09:49.000000000 +0100 @@ -89,6 +89,8 @@ exit(1); } +time_t LastActivity; + int main(int argc, char *argv[]) { // Save terminal settings: @@ -395,7 +397,7 @@ int PreviousChannel[2] = { 1, 1 }; int PreviousChannelIndex = 0; time_t LastChannelChanged = time(NULL); - time_t LastActivity = 0; + LastActivity = 0; // now being a global variable time_t LastCamMenu = 0; int MaxLatencyTime = 0; bool ForceShutdown = false;