vdr/vdradmin udpd.pl HISTORY vdradmind.pl

Thomas Schmidt pkg-vdr-dvb-changes@lists.alioth.debian.org
Wed, 26 May 2004 23:27:52 +0000


Update of /cvsroot/pkg-vdr-dvb/vdr/vdradmin
In directory haydn:/tmp/cvs-serv22265/vdr/vdradmin

Modified Files:
	HISTORY vdradmind.pl 
Added Files:
	udpd.pl 
Log Message:
added vdradmin 0.96

Index: vdradmind.pl
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/vdr/vdradmin/vdradmind.pl,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- vdradmind.pl	21 Apr 2004 19:54:15 -0000	1.1.1.1
+++ vdradmind.pl	26 May 2004 23:27:50 -0000	1.2
@@ -42,7 +42,7 @@
 use strict;
 #use warnings;
 
-my $SEARCH_FILES_IN_SYSTEM = 1; # for distribution
+my $SEARCH_FILES_IN_SYSTEM = 0; # for distribution
 
 sub true           () { 1 };
 sub false          () { 0 };
@@ -64,7 +64,7 @@
 $CONFIG{GUEST_ACCOUNT}    = 0;
 $CONFIG{LANGUAGE}         = "Deutsch";
 $CONFIG{LOGLEVEL}         = 81; # 32799
-$CONFIG{CACHE_TIMEOUT}    = 5;
+$CONFIG{CACHE_TIMEOUT}    = 60;
 $CONFIG{CACHE_LASTUPDATE} = 0;
 $CONFIG{AT_FUNC}          = 1;
 $CONFIG{AT_TIMEOUT}       = 120; 
@@ -75,13 +75,14 @@
 $CONFIG{TM_MARGIN_BEGIN}  = 10;
 $CONFIG{TM_MARGIN_END}    = 10;
 $CONFIG{LOGINPAGE}        = 0;
+$CONFIG{LOGGING}          = 0;
 $CONFIG{MOD_GZIP}         = 0;
 #
 $CONFIG{LOGFILE}          = "vdradmind.log";
 $CONFIG{SERVERPORT}       = 8001;
 $CONFIG{RECORDINGS}       = 1;
 
-my $VERSION               = "0.95";
+my $VERSION               = "0.96";
 my $SERVERVERSION         = "vdradmind/$VERSION";
 
 my($TEMPLATEDIR, $CONFFILE, $LOGFILE, $PIDFILE, $AT_FILENAME);
@@ -102,10 +103,9 @@
 my $I18NFILE							= "i18n.pl";
 my $USE_SHELL_GZIP        = true; # set on false to use the gzip library
 
-
 if($CONFIG{MOD_GZIP}) {
-		# lib gzipping
-		use Compress::Zlib;
+  # lib gzipping
+  use Compress::Zlib;
 }
 
 my($DEBUG) = 0;
@@ -125,10 +125,9 @@
 
 $SIG{INT} = \&Shutdown;
 $SIG{TERM} = \&Shutdown;
+$SIG{HUP} = \&HupSignal;
 $SIG{PIPE} = 'IGNORE';
 
-ReadConfig();
-
 #
 my $DAEMON = 1;
 for(my $i = 0; $i < scalar(@ARGV); $i++) {
@@ -181,6 +180,9 @@
   }
 }
 
+ReadConfig();
+
+
 if(-e "$PIDFILE") {
 	print "There's already an copy of this program running! (pid: " . getPID($PIDFILE) . ")\n";
 	print "If you feel this is a error, remove $PIDFILE!\n";
@@ -277,6 +279,7 @@
 		$Guest = 1;
 	} else {
 		headerNoAuth();
+    close($Client);
 		next;
 	}
 		
@@ -462,16 +465,40 @@
 }
 
 sub get_name_from_vdrid {
-	my $vdr_id = shift;
-	if($vdr_id) {
-		for my $channel (@CHAN) {
-			if($channel->{vdr_id} == $vdr_id) {
-				return($channel->{name});
-			}
-		}	
-	}
+  my $vdr_id = shift;
+  if($vdr_id) {
+    # Kanalliste nach identischer vdr_id durchsuchen
+    my @C = grep($_->{vdr_id} == $vdr_id, @CHAN);
+    # Es darf nach Spec nur eine ‹bereinstimmung geben
+    if(scalar(@C) == 1) {
+      return $C[0]->{name};
+    }
+  }
+}
+ 
+sub get_transponder_from_vdrid {
+  my $vdr_id = shift;
+  if($vdr_id) {
+    # Kanalliste nach identischer vdr_id durchsuchen
+    my @C = grep($_->{vdr_id} == $vdr_id, @CHAN);
+    # Es darf nach Spec nur eine ‹bereinstimmung geben
+    if(scalar(@C) == 1) {
+      return("$C[0]->{source}-$C[0]->{frequency}-$C[0]->{polarization}");
+    }
+  }
+}
+ 
+sub get_ca_from_vdrid {
+  my $vdr_id = shift;
+  if($vdr_id) {
+    # Kanalliste nach identischer vdr_id durchsuchen
+    my @C = grep($_->{vdr_id} == $vdr_id, @CHAN);
+    # Es darf nach Spec nur eine ‹bereinstimmung geben
+    if(scalar(@C) == 1) {
+      return($C[0]->{ca});
+    }
+  }  
 }
-
 
 #############################################################################
 # EPG functions
@@ -1386,6 +1413,10 @@
 	close(FILE);
 }
 
+sub HupSignal {
+  UptoDate(1);
+}
+
 sub UptoDate {
 	my $force = shift;
   if(((time() - $CONFIG{CACHE_LASTUPDATE}) >= ($CONFIG{CACHE_TIMEOUT} * 60)) || $force) {
@@ -1781,7 +1812,9 @@
     $progname = $event->{progname};
     $cnumber = $event->{cnumber};
   }
-	push(@show, { endd => 1 });
+  if(scalar(@show)) {
+    push(@show, { endd => 1 });
+  }
 	
 	
   # 
@@ -1839,15 +1872,49 @@
 	#
   if($CONFIG{RECORDINGS})  {
     my($ii, $jj, $timer, $last);
-    for ($ii = 0; $ii < @timer; $ii++)  {
-      if ($timer[$ii]->{first} == -1 || $timer[$ii]->{first} == 1)  {
+    for($ii = 0; $ii < @timer; $ii++)  {
+      if($timer[$ii]->{first} == -1 || $timer[$ii]->{first} == 1)  {
         $last = $ii;
       }
-      for ($jj = 0; $jj < $ii; $jj++)  {
-        if ($timer[$ii]->{startsse} >= $timer[$jj]->{startsse} &&
+
+      # Liste der benutzten Transponder
+      my @Transponder = (get_transponder_from_vdrid($timer[$ii]->{vdr_id}));
+      $timer[$ii]->{collision} = 0;
+      
+      for($jj = 0; $jj < $ii; $jj++)  {
+        if($timer[$ii]->{startsse} >= $timer[$jj]->{startsse} &&
             $timer[$ii]->{startsse} < $timer[$jj]->{stopsse}) {
-          if ($timer[$ii]->{active} && $timer[$jj]->{active}) { 
-            ($timer[$ii]->{collision})++; 
+          if($timer[$ii]->{active} && $timer[$jj]->{active}) { 
+            # Timer kollidieren zeitlich. Pruefen, ob die Timer evtl. auf
+            # gleichem Transponder oder CAM liegen und daher ohne Probleme
+            # aufgenommen werden koennen
+            Log(LOG_DEBUG, sprintf("Kollission: %s (%s, %s) -- %s (%s, %s)\n",
+              substr($timer[$ii]->{title},0,15), $timer[$ii]->{vdr_id},
+              get_transponder_from_vdrid($timer[$ii]->{vdr_id}),
+              get_ca_from_vdrid($timer[$ii]->{vdr_id}),
+              substr($timer[$jj]->{title},0,15), $timer[$jj]->{vdr_id},
+              get_transponder_from_vdrid($timer[$jj]->{vdr_id}),
+              get_ca_from_vdrid($timer[$jj]->{vdr_id})));
+
+            if($timer[$ii]->{vdr_id} != $timer[$jj]->{vdr_id} &&
+              get_ca_from_vdrid($timer[$ii]->{vdr_id}) ==   
+              get_ca_from_vdrid($timer[$jj]->{vdr_id}) &&
+              get_ca_from_vdrid($timer[$ii]->{vdr_id}) >= 100) {
+              # Beide Timer laufen auf dem gleichen CAM auf verschiedenen
+              # Kanaelen, davon kann nur einer aufgenommen werden
+              Log(LOG_DEBUG, "Beide Kanaele gleiches CAM");
+              ($timer[$ii]->{collision}) = $CONFIG{RECORDINGS};
+              # Nur Kosmetik: Transponderliste vervollstaendigen
+              push(@Transponder, get_transponder_from_vdrid($timer[$jj]->{vdr_id}));
+            } else {
+              # "grep" prueft die Bedingung fuer jedes Element, daher den
+              # Transponder vorher zwischenspeichern -- ist effizienter
+              my $t = get_transponder_from_vdrid($timer[$jj]->{vdr_id});
+              if(scalar(grep($_ eq $t, @Transponder)) == 0) {
+                ($timer[$ii]->{collision})++;
+                push(@Transponder, get_transponder_from_vdrid($timer[$jj]->{vdr_id}));
+              } 
+            }
           }
         }
       }
@@ -2810,22 +2877,20 @@
 		close(CONF);
 	}
   
-  if(defined($q->param("submit"))) {
-    if($q->param("submit") eq ">>>>>") {
-      for my $vdr_id ($q->param("all_channels")) {
-        $CONFIG{CHANNELS_WANTED} = csvAdd($CONFIG{CHANNELS_WANTED}, $vdr_id); 
-      }
-      ApplyConfig(); WriteConfig();
-    } elsif($q->param("submit") eq "<<<<<") {
-      for my $vdr_id ($q->param("selected_channels")) {
-        $CONFIG{CHANNELS_WANTED} = csvRemove($CONFIG{CHANNELS_WANTED}, $vdr_id); 
-      }
-      ApplyConfig(); WriteConfig();
-    } elsif($q->param("save")) {
-      ApplyConfig(); WriteConfig(); 
-    } elsif($q->param("apply")) {
-      ApplyConfig();
+  if($q->param("submit") eq ">>>>>") {
+    for my $vdr_id ($q->param("all_channels")) {
+      $CONFIG{CHANNELS_WANTED} = csvAdd($CONFIG{CHANNELS_WANTED}, $vdr_id); 
     }
+    ApplyConfig(); WriteConfig();
+  } elsif($q->param("submit") eq "<<<<<") {
+    for my $vdr_id ($q->param("selected_channels")) {
+      $CONFIG{CHANNELS_WANTED} = csvRemove($CONFIG{CHANNELS_WANTED}, $vdr_id); 
+    }
+    ApplyConfig(); WriteConfig();
+  } elsif($q->param("save")) {
+    ApplyConfig(); WriteConfig(); 
+  } elsif($q->param("apply")) {
+    ApplyConfig();
   }
  
 	#

Index: HISTORY
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/vdr/vdradmin/HISTORY,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- HISTORY	21 Apr 2004 19:54:12 -0000	1.1.1.1
+++ HISTORY	26 May 2004 23:27:50 -0000	1.2
@@ -1,4 +1,9 @@
-v0.95 -- tom Sat Dec 13 14:55:04 CET 2003
+v0.96 -- tom -- Tue Apr  6 15:43:16 CEST 2004
+ - Reworked timer collision detection (Thanks to Cooper)
+ - Corrected Power button link in the remote control (Thanks to Tobias Grimm)
+ - Solved some javascript issues
+
+v0.95 -- tom -- Sat Dec 13 14:55:04 CET 2003
  - Added support to listen on specific network adresses (Thanks to 
    Ludwig Nussel)
  - Added two new parameters (--message, --displaycall)

--- NEW FILE: udpd.pl ---
#!/usr/bin/perl

##
# Simple UDP Server/Client to display messages in VDR
#
# 22.02.2004 by Thomas Koch <tom at linvdr dot org>
##

use IO::Socket;
use IO::Socket::INET 1.26;
use strict;

my $myself = join("", $0 =~ /^.*\/(.*)/);

# Server
if($myself eq "udpd.pl") {
  my $pid = fork();
  if($pid != 0) {
    exit(0);
  }
  my($Socket) = IO::Socket::INET->new( 
    Proto => 'udp',
    LocalPort => 4711,
    Reuse => 1
  ) || die;				     
  my $message;
  while($Socket->recv($message, 1024)) {
    my($port, $ipaddr) = sockaddr_in($Socket->peername);
    my $hishost = gethostbyaddr($ipaddr, AF_INET);
    system("logger udpd: client $hishost with message \\'$message\\'");
    for(my $z = 0; $z < 3; $z++) {
      for(my $i = 0; $i < 3; $i++) {
        system("svdrpsend.pl mesg $message 2>/dev/null >/dev/null");
      }
      sleep(3);
    }
  }
  exit(0);
}

# Client
if($myself eq "udpc.pl") {
  my $message = join(" ", @ARGV);
  my $Socket = IO::Socket::INET->new(
    PeerAddr => inet_ntoa(INADDR_BROADCAST),
    PeerPort => 4711, 
    Proto => 'udp',
    Broadcast => 1
  ) || die;
  my $result = $Socket->send($message);
}