[xiph-cvs] cvs commit: snatch libsnatch.c snatch.pl x11.c

Monty xiphmont at xiph.org
Wed Nov 7 19:41:50 PST 2001



xiphmont    01/11/07 19:41:49

  Modified:    .        libsnatch.c snatch.pl x11.c
  Log:
  incremental commit

Revision  Changes    Path
1.8       +2 -1      snatch/libsnatch.c

Index: libsnatch.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/libsnatch.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- libsnatch.c	2001/11/07 06:46:44	1.7
+++ libsnatch.c	2001/11/08 03:41:48	1.8
@@ -710,7 +710,8 @@
         }
       }
       return(ret);
-    }
+    }else
+      if(fake_audiop)return(0);
   }
   return((*libc_ioctl)(fd,rq,arg));
 }

1.7       +590 -99   snatch/snatch.pl

Index: snatch.pl
===================================================================
RCS file: /usr/local/cvsroot/snatch/snatch.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- snatch.pl	2001/11/07 06:46:44	1.6
+++ snatch.pl	2001/11/08 03:41:49	1.7
@@ -20,29 +20,26 @@
 $configfile=$configdir."/config.txt";
 $historyfile=$configdir."/history.txt";
 $logofile=$configdir."/logo.xpm";
-$libsnatch="/home/xiphmont/snatch/libsnatch.so";
 
 my $backchannel_socket="/tmp/snatch.$PID";
 my $uaddr=sockaddr_un($backchannel_socket);
 my $proto=getprotobyname('tcp');
 my $comm_ready=0;
+my $mode='active';
 
 # default config
 $CONFIG{'REALPLAYER'}='{realplay,~/RealPlayer8/realplay}';
-$CONFIG{'OUPUT_PATH'}="$HOME";
+$CONFIG{'LIBSNATCH'}='{~/snatch/libsnatch.so}';
+$CONFIG{'OUTPUT_PATH'}=$HOME;
 $CONFIG{'AUDIO_DEVICE'}="/dev/dsp*";
 $CONFIG{'AUDIO_MUTE'}='no';
 $CONFIG{'VIDEO_MUTE'}='no';
-$CONFIG{'MODE'}='active';
-$CONFIG{'OUTPUT'}=$HOME;
 $CONFIG{'DEBUG'}='no';
 
 if(! -e $configdir){
     die $! unless mkdir $configdir, 0770;
 }
 
-
-
 $snatchxpm= <<'EOF';
 /* XPM */
 static char * snatch_xpm[] = {
@@ -125,8 +122,6 @@
     close HFILE;
 }
 
-print @ARGV;
-
 # build the UI
 my $toplevel=new MainWindow(-class=>'Snatch');
 my $Xname=$toplevel->Class;
@@ -148,22 +143,55 @@
 
 $toplevel->optionAdd("$Xname*background",  "#d0d0d0",20);
 $toplevel->optionAdd("$Xname*foreground",  '#000000',20);
+
 $toplevel->optionAdd("$Xname*Tab*background",  "#a0a0a0",20);
+$toplevel->optionAdd("$Xname*Tab*disabledForeground",  "#ffffff",20);
+$toplevel->optionAdd("$Xname*Tab*relief",  "raised",20);
+$toplevel->optionAdd("$Xname*Tab*borderWidth",  1,20);
+
 $toplevel->optionAdd("$Xname*Button*background",  "#f0d0b0",20);
 $toplevel->optionAdd("$Xname*Button*foreground",  '#000000',20);
-$toplevel->optionAdd("$Xname*activeBackground",  "#f0f0ff",20);
+$toplevel->optionAdd("$Xname*Button*borderWidth",  '2',20);
+$toplevel->optionAdd("$Xname*Button*relief",  'groove',20);
+
+$toplevel->optionAdd("$Xname*activeBackground",  "#ffffff",20);
 $toplevel->optionAdd("$Xname*activeForeground",  '#0000a0',20);
 $toplevel->optionAdd("$Xname*borderWidth",         0,20);
+$toplevel->optionAdd("$Xname*relief",         'flat',20);
 $toplevel->optionAdd("$Xname*activeBorderWidth",         1,20);
 $toplevel->optionAdd("$Xname*highlightThickness",         0,20);
 $toplevel->optionAdd("$Xname*padX",         2,20);
 $toplevel->optionAdd("$Xname*padY",         2,20);
-$toplevel->optionAdd("$Xname*relief",         'flat',20);
 $toplevel->optionAdd("$Xname*font",    
                      '-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*',20);
-$toplevel->optionAdd("$Xname*quit.font",    
+$toplevel->optionAdd("$Xname*Entry.font",    
+                     '-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*',20);
+
+$toplevel->optionAdd("$Xname*Exit.font",    
                      '-*-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*',20);
+$toplevel->optionAdd("$Xname*Exit.relief",          'groove',20);
+$toplevel->optionAdd("$Xname*Exit.padX",          1,20);
+$toplevel->optionAdd("$Xname*Exit.padY",          1,20);
+$toplevel->optionAdd("$Xname*Exit.borderWidth",          2,20);
+$toplevel->optionAdd("$Xname*Exit*background",  "#a0a0a0",20);
+$toplevel->optionAdd("$Xname*Exit*disabledForeground",  "#ffffff",20);
+
+$toplevel->optionAdd("$Xname*Entry.background",  "#ffffff",20);
+$toplevel->optionAdd("$Xname*Entry.disabledForeground",  "#c0c0c0",20);
+$toplevel->optionAdd("$Xname*Entry.relief",  "sunken",20);
+$toplevel->optionAdd("$Xname*Entry.borderWidth",  2,20);
+
+$toplevel->optionAdd("$Xname*ListFrame.background",  "#ffffff",20);
+$toplevel->optionAdd("$Xname*ListRowOdd.background",  "#dfffe7",20);
+$toplevel->optionAdd("$Xname*ListRowEven.background",  "#ffffff",20);
+
+$toplevel->optionAdd("$Xname*Scrollbar*background",  "#f0d0b0",20);
+$toplevel->optionAdd("$Xname*Scrollbar*foreground",  '#000000',20);
+$toplevel->optionAdd("$Xname*Scrollbar*borderWidth",  '2',20);
+$toplevel->optionAdd("$Xname*Scrollbar*relief",  'sunken',20);
+
 
+
 $toplevel->configure(-background=>$toplevel->optionGet("background",""));
 
 #$toplevel->resizable(FALSE,FALSE);
@@ -173,72 +201,59 @@
     place(-x=>10,-y=>36,-relwidth=>1.0,-relheight=>1.0,
           -width=>-20,-height=>-46,-anchor=>'nw');
 
-$window_setupbar=$toplevel->Button(-class=>Tab,Name=>"setup",text=>"configuration",
-				   borderwidth=>1,relief=>raised)->
+$window_setupbar=$toplevel->Button(-class=>Tab,Name=>"setup",text=>"configuration")->
     place(-relx=>1.0,-anchor=>'se',-in=>$window_shell,-bordermode=>outside);
-$window_timerbar=$toplevel->Button(-class=>Tab,Name=>"timer",text=>"timer setup",
-				   borderwidth=>1,relief=>raised)->
+$window_timerbar=$toplevel->Button(-class=>Tab,Name=>"timer",text=>"timer setup")->
     place(-bordermode=>outside,-anchor=>'ne',-in=>$window_setupbar);
 
-$window_quit=$window_shell->Button(-class=>Tab,Name=>"quit",text=>"quit",
-				   -padx=>1,-pady=>1,
-				   relief=>'groove',borderwidth=>2)->
+$window_quit=$window_shell->Button(-class=>"Exit",text=>"quit")->
     place(-x=>-1,-y=>-1,-relx=>1.0,-rely=>1.0,-anchor=>'se');
 
 $window_logo=$toplevel->
-    Label(Name=>"logo",-class=>"Panel",image=>$xpm_snatch,
-	  relief=>flat,borderwidth=>0)->
+    Label(Name=>"logo",-class=>"Panel",image=>$xpm_snatch)->
     place(-x=>5,-y=>5,-anchor=>'nw');
 
 $window_version=$toplevel->
-    Label(Name=>"logo text",-class=>"Panel",text=>$version,
-	  relief=>flat,borderwidth=>0)->
+    Label(Name=>"logo text",-class=>"Panel",text=>$version)->
     place(-x=>5,-relx=>1.0,-rely=>1.0,-anchor=>'sw',-in=>$window_logo);
 
 
 $window_statuslabel=$window_shell->
-    Label(Name=>"statuslabel",-class=>"Statuslabel",text=>"Status: ",
-	  relief=>flat,borderwidth=>0)->
+    Label(Name=>"statuslabel",-class=>"Statuslabel",text=>"Status: ")->
     place(-x=>5,-y=>0,-rely=>.2,-relheight=>.4,-anchor=>'w');
 
 $window_status=$window_shell->
-    Label(Name=>"status",-class=>"Status",text=>"Starting...",
-	  relief=>flat,borderwidth=>0)->
+    Label(Name=>"status",-class=>"Status",text=>"Starting...")->
     place(-x=>5,-y=>0,-relx=>1.0,-relheight=>1.0,
           -anchor=>'nw',-in=>$window_statuslabel);
 
-$window_active=$window_shell->Button(Name=>"active",text=>"record all",
-				    state=>disabled,
-				   relief=>'groove',borderwidth=>2)->
+$window_active=$window_shell->Button(Name=>"active",text=>"capture all",
+				    state=>disabled)->
     place(-x=>5,-y=>0,-relx=>0.,-rely=>.55,-relwidth=>.33,
           -width=>-5,-anchor=>'w',-in=>$window_shell);
 
 $window_timer=$window_shell->Button(Name=>"timer",text=>"timed record",
-				    state=>disabled,
-				   relief=>'groove',borderwidth=>2)->
+				    state=>disabled)->
     place(-x=>0,-y=>0,-relx=>.333,-rely=>.55,-relwidth=>.33,
           -width=>-0,-anchor=>'w',-in=>$window_shell);
 
-$window_inactive=$window_shell->Button(Name=>"inactive",text=>"record off",
-				    state=>disabled,
-				   relief=>'groove',borderwidth=>2)->
+$window_inactive=$window_shell->Button(Name=>"inactive",text=>"off",
+				    state=>disabled)->
     place(-x=>0,-y=>0,-relx=>.667,-rely=>.55,-relwidth=>.33,
           -width=>-5,-anchor=>'w',-in=>$window_shell);
 
 
-$window_mute=$window_shell->Label(Name=>"mute",text=>"mutes: ")->
+$window_mute=$window_shell->Label(Name=>"mute",text=>"silent capture: ")->
     place(-x=>5,-y=>0,-relx=>0.,-rely=>.85,
           -anchor=>'w',-in=>$window_shell);
 
 $window_amute=$window_shell->Button(Name=>"audio",text=>"audio",
-				    state=>disabled,
-				   relief=>'groove',borderwidth=>2)->
+				    state=>disabled)->
     place(-x=>2,-relx=>1.0,-relheight=>1.0,-anchor=>'nw',-in=>$window_mute,
           -bordermode=>outside);
 
 $window_vmute=$window_shell->Button(Name=>"video",text=>"video",
-				    state=>disabled,
-				    relief=>'groove',borderwidth=>2)->
+				    state=>disabled)->
     place(-x=>2,-relx=>1.0,-relheight=>1.0,-anchor=>'nw',-in=>$window_amute,
           -bordermode=>outside);
 
@@ -251,19 +266,23 @@
 $minheight=
     $window_logo->reqheight()+
     $window_statuslabel->reqheight()+
-    $window_mute->reqwidth()+
-    20;
+    $window_active->reqheight()+
+    max($window_mute->reqheight(),$window_quit->reqheight())+
+    30;
 
-$toplevel->optionAdd("$Xname.geometry",    ($minwidth+20).'x'.$minheight,20);
-my$geometry=$toplevel->optionGet("geometry","");
 $toplevel->minsize($minwidth,$minheight);
-$toplevel->geometry($geometry);
 
+my$geometry=$toplevel->optionGet("geometry","");
+if(defined($geometry)){
+    $toplevel->geometry($geometry);
+}else{
+    $toplevel->geometry(($minwidth+20).'x'.$minheight);
+}
 $toplevel->update();
 
 $window_quit->configure(-command=>[sub{Shutdown();}]);
-$window_amute->configure(-command=>[sub{Amute();}]);
-$window_vmute->configure(-command=>[sub{Vmute();}]);
+$window_amute->configure(-command=>[sub{Robot_Audio();}]);
+$window_vmute->configure(-command=>[sub{Robot_Video();}]);
 $window_active->configure(-command=>[sub{Robot_Active();}]);
 $window_timer->configure(-command=>[sub{Robot_Timer();}]);
 $window_inactive->configure(-command=>[sub{Robot_Inactive();}]);
@@ -285,15 +304,29 @@
 
     Status("Starting RealPlayer...");
     # set up the environment
-
+    my at list=bsd_glob("$CONFIG{'LIBSNATCH'}",
+		     GLOB_TILDE|GLOB_ERR|GLOB_BRACE);
+    if(GLOB_ERROR || $#list<0){
+	Status("Failed to find libsnatch.so!");
+	Alert("Failed to find libsnatch.so!",
+	      "Please verify that libsnatch.so is built,".
+	      " installed, and its location is set correctly ".
+	      "on the configuration panel.\n");
+	return;
+    }
+    
     $ENV{"SNATCH_DEBUG"}=1;
-    $ENV{"LD_PRELOAD"}=$libsnatch;
+    $ENV{"LD_PRELOAD"}=@list[0];
     $ENV{"SNATCH_COMM_SOCKET"}=$backchannel_socket;
 
-    my at list=bsd_glob("$CONFIG{'REALPLAYER'}",
+    @list=bsd_glob("$CONFIG{'REALPLAYER'}",
                      GLOB_TILDE|GLOB_ERR|GLOB_BRACE);
     if(GLOB_ERROR || $#list<0){
         Status("Failed to find RealPlayer!");
+	Alert("Failed to find RealPlayer!",
+	      "Please verify that RealPlayer is installed,".
+	      " executable, and its location is set correctly".
+	      "on the configuration panel.\n");
         return;
     }
 
@@ -312,7 +345,7 @@
     my $stderr_output;
 
     Status("Waiting for rendevous... [$time]");
-    while($time){
+    while($time>0){
         my($nfound,$timeleft)=select($rout=$rin, $wout=$win, $eout=$ein, 1);
         if($nfound==0){
             $time--;
@@ -338,24 +371,31 @@
                 # socket has a request
                 $status=accept(COMM_SOCK,LISTEN_SOCK);
                 $comm_ready=1;
-		$time=0;
+		$time=-1;
             }
         }
     }
 
+    if($time==0){
+	Alert("Rendevous failed!",
+	      "RealPlayer appears to have started, but the Snatch ".
+	      "robot could not connect to it via libsnatch.  Most likely,".
+	      " this is a result of having a blank or mis-set ".
+	      "'libsntach.so location' setting on the configuration ".
+	      "menu.  Please verify this setting before continuing.\n");
+	Status("Rendevous failed!");
+	return;
+    }
 
     # configure
     Status("RealPlayer started...");
-    $window_active->configure(state=>normal);
-    $window_timer->configure(state=>normal);
-    $window_inactive->configure(state=>normal);
-
-    $window_amute->configure(state=>normal);
-    $window_vmute->configure(state=>normal);
     $toplevel->fileevent(REAL_STDERR,'readable'=>[sub{ReadStderr();}]);
+    ButtonConfig();
     send_string("F",$CONFIG{'OUTPUT_PATH'});
     send_string("D",$CONFIG{'AUDIO_DEVICE'});
-    Robot_Active();
+    Robot_Active() if($mode eq 'active');
+    Robot_Timer() if($mode eq 'timer');
+    Robot_Inactive() if($mode eq 'inactive');
 
 }
 
@@ -367,10 +407,15 @@
     die $! unless listen(LISTEN_SOCK,SOMAXCONN);
 }
 
-sub ReleaseSocket{
-    $window_amute->configure(state=>disabled);
-    $window_vmute->configure(state=>disabled);
+sub Disconnect{
+    $comm_ready=0;
+    ButtonConfig();
+    close COMM_SOCKET if($comm_ready);
+    close REAL_STDERR if($comm_ready);
+}
+
 
+sub ReleaseSocket{
     $comm_ready=0;
     unlink($backchannel_socket);
     close(LISTEN_SOCK);
@@ -386,35 +431,38 @@
         alarm 0;
         if($status){
             #enable the panel
-	    Status("libsnatch contacted");
+	    Status("RealPlayer contacted");
             $comm_ready=1;
-	    $window_amute->configure(state=>active);
-	    $window_vmute->configure(state=>active);
-
-	    
+	    ButtonConfig();
         }
     }
 }
 
-sub Shutdown{
-# save the config/history
-    Robot_Exit();
-    ReleaseSocket();
-
+sub SaveConfig{
     die $! unless open CFILE, ">$configfile".".tmp";
     foreach $key (keys %CONFIG){
         print CFILE "$key=$CONFIG{$key}\n";
     }
     close CFILE;
     die $! unless rename "$configfile".".tmp", $configfile;
-    
+}
+
+sub SaveHistory{
     die $! unless open HFILE, ">$historyfile".".tmp";
     foreach $line (@TIMER){
         print HFILE "$line\n";
     }
     close HFILE;
     die $! unless rename "$historyfile".".tmp", $historyfile;
-    
+}
+
+sub Shutdown{
+# save the config/history
+    Robot_Exit();
+    ReleaseSocket();
+    SaveConfig();
+    SaveHistory();
+
   Tk::exit(0);
 }
 
@@ -460,7 +508,7 @@
 sub Robot_Exit{
     my $exitcode=join "",("Kx",pack ("S",4));
     syswrite COMM_SOCK,$playcode;
-    close COMM_SOCK;
+    Disconnect();
 }
 
 sub Robot_Active{
@@ -470,9 +518,11 @@
     send_string("O","");
     send_string("L","");
     syswrite COMM_SOCK,'A';
-    Robot_Audio($global_audio_setting);
-    Robot_Video($global_video_setting);
-    Status("Active/Nominal");
+    Robot_Audio($CONFIG{"AUDIO_MUTE"});
+    Robot_Video($CONFIG{"VIDEO_MUTE"});
+    Status("Ready/waiting to record");
+    $mode='active';
+    ButtonPressConfig();
 }
 
 sub Robot_Inactive{
@@ -480,10 +530,12 @@
     send_string("P","");
     send_string("O","");
     send_string("L","");
-    Robot_Audio($global_audio_setting);
-    Robot_Video($global_video_setting);
     syswrite COMM_SOCK,'I';
+    Robot_Audio($CONFIG{"AUDIO_MUTE"});
+    Robot_Video($CONFIG{"VIDEO_MUTE"});
     Status("Recording off");
+    $mode='inactive';
+    ButtonPressConfig();
 }
 
 sub Robot_Timer{
@@ -491,39 +543,60 @@
     send_string("P","");
     send_string("O","");
     send_string("L","");
-    Robot_Audio($global_audio_setting);
-    Robot_Video($global_video_setting);
     syswrite COMM_SOCK,'T';
-    Status("Inactive [Timer]");
+    Robot_Audio($CONFIG{"AUDIO_MUTE"});
+    Robot_Video($CONFIG{"VIDEO_MUTE"});
+    Status("Timed recording only");
+    $mode='timer';
+    ButtonPressConfig();
 }
 
 sub Robot_Audio{
     my($onoff)=@_;
 
-    if($onoff=~m/on/){
-	syswrite COMM_SOCK,'S';
-    }
-    if($onoff=~m/off/){
+    if($onoff=~m/yes/){
         syswrite COMM_SOCK,'s';
+	$CONFIG{"AUDIO_MUTE"}='yes';
+    }elsif($onoff=~m/no/){
+	syswrite COMM_SOCK,'S';
+	$CONFIG{"AUDIO_MUTE"}='no';
+    }else{
+	if($CONFIG{"AUDIO_MUTE"}=~/yes/){
+	    syswrite COMM_SOCK,'S';
+	    $CONFIG{"AUDIO_MUTE"}='no';
+	}else{
+	    syswrite COMM_SOCK,'s';
+	    $CONFIG{"AUDIO_MUTE"}='yes';
+	}
     }
+    ButtonPressConfig();
+
 }
 
 sub Robot_Video{
     my($onoff)=@_;
 
-    if($onoff=~m/on/){
-	syswrite COMM_SOCK,'V';
-    }
-    if($onoff=~m/off/){
+    if($onoff=~m/yes/){
         syswrite COMM_SOCK,'v';
+	$CONFIG{"VIDEO_MUTE"}='yes';
+    }elsif($onoff=~m/no/){
+	syswrite COMM_SOCK,'V';
+	$CONFIG{"VIDEO_MUTE"}='no';
+    }else{
+	if($CONFIG{"VIDEO_MUTE"}=~/yes/){
+	    syswrite COMM_SOCK,'V';
+	    $CONFIG{"VIDEO_MUTE"}='no';
+	}else{
+	    syswrite COMM_SOCK,'v';
+	    $CONFIG{"VIDEO_MUTE"}='yes';
+	}
     }
+    ButtonPressConfig();
 }
 
 sub SplitTimerEntry{
     my($line)=@_;
 
-# eg
-# 2001 11 05 1 12:25 300000 FAKEA FAKEV length:USERNAME length:PASSWORD length:FILE length:URL
     $line=~/^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\d+):(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(.*)/;
     my $year=$1;
     my $month=$2;
@@ -692,8 +765,7 @@
                                          -width=>-8,-height=>-8,-anchor=>'nw');
 
     $modal_exit=$modal_shell->
-	Button(-class=>Tab,Name=>"exit",text=>"X",
-	       -padx=>1,-pady=>1,relief=>'groove',borderwidth=>2)->
+	Button(-class=>"Exit",text=>"X")->
                    place(-x=>-1,-y=>-1,-relx=>1.0,-rely=>1.0,-anchor=>'se');
     
     $modal_message=$modal_shell->
@@ -701,8 +773,8 @@
             place(-x=>5,-y=>10);
 
     $width=$modal_message->reqwidth();
+    $width=300 if($width<300);
 
-
     $modal_detail=$modal_shell->
         Message(text=>$detail,-class=>"AlertDetail",
                 -width=>($width-$modal_exit->reqwidth()))->
@@ -729,20 +801,439 @@
 sub ReadStderr{
     $bytes=sysread REAL_STDERR, my$scalar, 4096;
     if($bytes==0){
+	Disconnect();
         Alert("RealPlayer unexpectedly exited!","Attempting to start a new copy...\n");
         $toplevel->fileevent(REAL_STDERR,'readable' => ''); 
-	close REAL_STDERR;
         ThrowRealPlayer();
     }
 
     if($scalar=~/shut down X/){
+	Disconnect();
         $toplevel->fileevent(REAL_STDERR,'readable' => ''); 
-	close REAL_STDERR;
-	close COMM_SOCK;
       Tk::exit(0);
     }	
-    print $scalar;
+    print $scalar if($CONFIG{DEBUG} eq 'yes');
+}
+
+sub ButtonPressConfig(){
+    $window_timer->configure(-relief=>'groove') if ($mode ne 'timer');
+    $window_timer->configure(-relief=>'sunken') if ($mode eq 'timer');
+    $window_active->configure(-relief=>'groove') if ($mode ne 'active');
+    $window_active->configure(-relief=>'sunken') if ($mode eq 'active');
+    $window_inactive->configure(-relief=>'groove') if ($mode ne 'inactive');
+    $window_inactive->configure(-relief=>'sunken') if ($mode eq 'inactive');
+
+    $window_amute->configure(-relief=>'groove') if ($CONFIG{AUDIO_MUTE} eq 'no');
+    $window_amute->configure(-relief=>'sunken') if ($CONFIG{AUDIO_MUTE} eq 'yes');
+    $window_vmute->configure(-relief=>'groove') if ($CONFIG{VIDEO_MUTE} eq 'no');
+    $window_vmute->configure(-relief=>'sunken') if ($CONFIG{VIDEO_MUTE} eq 'yes');
+
 }
+
+sub ButtonConfig{
+    if ($#TIMER<0 || !$comm_ready){
+	$window_timer->configure(state=>disabled);
+    }else{ 
+	$window_timer->configure(state=>normal);
+    }
+    if (!$comm_ready){
+	$window_active->configure(state=>disabled);
+	$window_inactive->configure(state=>disabled);
+	$window_amute->configure(state=>disabled);
+	$window_vmute->configure(state=>disabled);
+    }else{ 
+	$window_active->configure(state=>normal);
+	$window_inactive->configure(state=>normal);
+	$window_amute->configure(state=>normal);
+	$window_vmute->configure(state=>normal);
+    }
+    ButtonPressConfig();
+}
+
+sub TimerSort{
+    $count=0;
+    @TIMER_TIMES=(map {TimerWhen(-1,(SplitTimerEntry($_)))} @TIMER);
+    @TIMER_SORTED=sort sortsub, (map {$count++} @TIMER);
+}    
+
+sub Setup{
+    %TEMPCONF=%CONFIG;
+    my$tempstdout;
+    if($CONFIG{'OUTPUT_PATH'} eq '-'){
+	$tempstdout='yes';
+	$TEMPCONF{'OUTPUT_PATH'}=`pwd`;
+    }
+
+    $window_setupbar->configure(-state=>'disabled');
+    $window_setupbar->configure(-relief=>'flat');
+    $setup=new MainWindow(-class=>'Snatch');
+
+    my$xpm_snatch=$setup->Pixmap("_snatchlogo_xpm",-file=>$logofile);
+
+    $setup_shell=$setup->Label(Name=>"shell",borderwidth=>1,relief=>raised)->
+	place(-x=>10,-y=>36,-relwidth=>1.0,-relheight=>1.0,
+	      -width=>-20,-height=>-46,-anchor=>'nw');
+    
+    $setup_quit=$setup_shell->
+	Button(-class=>"Exit",text=>"OK")->
+		   place(-x=>-1,-y=>-1,-relx=>1.0,-rely=>1.0,-anchor=>'se');
+    $setup_apply=$setup_shell->
+	Button(-class=>"Exit",text=>"apply")->
+		   place(-x=>0,-y=>0,-anchor=>'ne',-in=>$setup_quit,
+			 -bordermode=>outside);
+    $setup_cancel=$setup_shell->
+	Button(-class=>"Exit",text=>"cancel")->
+		   place(-x=>1,-y=>-1,-rely=>1.0,-anchor=>'sw');
+    
+
+    $setup_logo=$setup->
+	Label(Name=>"logo",-class=>"Panel",image=>$xpm_snatch)->
+		  place(-x=>5,-y=>5,-anchor=>'nw');
+
+    $setup_title=$setup->
+	Label(Name=>"setup text",-class=>"Panel",text=>"Configuration")->
+		  place(-x=>5,-relx=>1.0,-rely=>1.0,-anchor=>'sw',
+			-in=>$setup_logo);
+
+    # Real location
+    $nexty=5;
+    $temp=$setup_shell->
+	Label(text=>"RealPlayer location:")->
+	    place(-x=>5,-y=>$nexty);
+    $setup_shell->
+	Entry(-textvariable=>\$TEMPCONF{'REALPLAYER'},-width=>"256")->
+	    place(-y=>$nexty,-x=>$temp->reqwidth()+10,
+		  -anchor=>'nw',-relwidth=>1.0,
+		  -height=>$temp->reqheight(),
+		  -width=>-$temp->reqwidth()-18);
+    $nexty=8+$temp->reqheight();
+
+    #libsnatch location
+    $temp=$setup_shell->
+	Label(text=>"libsnatch.so location:")->
+	    place(-x=>5,-y=>$nexty);
+    $setup_shell->
+	Entry(-textvariable=>\$TEMPCONF{'LIBSNATCH'},-width=>"256")->
+	    place(-y=>$nexty,-x=>$temp->reqwidth()+10,
+		  -anchor=>'nw',-relwidth=>1.0,
+		  -height=>$temp->reqheight(),
+		  -width=>-$temp->reqwidth()-18);
+    $nexty+=8+$temp->reqheight();
+
+    #audio device
+    $temp=$setup_shell->
+	Label(text=>"audio device (OSS only):")->
+	    place(-x=>5,-y=>$nexty);
+    $setup_shell->
+	Entry(-textvariable=>\$TEMPCONF{'AUDIO_DEVICE'},-width=>"256")->
+	    place(-y=>$nexty,-x=>$temp->reqwidth()+10,
+		  -anchor=>'nw',-relwidth=>1.0,
+		  -height=>$temp->reqheight(),
+		  -width=>-$temp->reqwidth()-18);
+    $nexty+=15+$temp->reqheight();
+    
+    #debug
+    if($TEMPCONF{'DEBUG'} eq 'yes'){
+	$temp=$setup_debug=$setup_shell->
+	    Button(text=>"full debug output",-relief=>'sunken',-pady=>1)->
+		place(-x=>5,-y=>$nexty);
+    }else{
+	$temp=$setup_debug=$setup_shell->
+	    Button(text=>"full debug output",-pady=>1)->
+		   place(-x=>5,-y=>$nexty);
+    }
+    $setup_debug->configure(-command=>[sub{Setup_Debug();}]);
+    $nexty+=15+$temp->reqheight();
+
+    #output path
+    $temp=$setup_shell->
+	Label(text=>"capture output:")->
+	    place(-x=>5,-y=>$nexty);
+    if($tempstdout eq 'yes'){
+	$setup_stdout=$setup_shell->
+	    Button(text=>"stdout",-relief=>'sunken',-pady=>1)->
+		place(-x=>$temp->reqwidth()+5,-y=>$nexty,
+		      -height=>$temp->reqheight());
+	$setup_path=$setup_shell->
+	    Entry(-textvariable=>\$TEMPCONF{'OUTPUT_PATH'},-width=>256,
+		  -state=>disabled,relief=>groove)->
+		      place(-x=>$temp->reqwidth()+10+$setup_stdout->reqwidth(),
+			    -y=>$nexty,-height=>$temp->reqheight(),
+			    -width=>-$setup_stdout->reqwidth()-$temp->reqwidth()-18,
+			    -relwidth=>1.0);
+    }else{
+	$setup_stdout=$setup_shell->
+	    Button(text=>"stdout",-pady=>1)->
+		place(-x=>$temp->reqwidth()+5,-y=>$nexty,
+		      -height=>$temp->reqheight());
+	$setup_path=$setup_shell->
+	    Entry(-textvariable=>\$TEMPCONF{'OUTPUT_PATH'},-width=>256)->
+		      place(-x=>$temp->reqwidth()+10+$setup_stdout->reqwidth(),
+			    -y=>$nexty,-height=>$temp->reqheight(),
+			    -width=>-$setup_stdout->reqwidth()-$temp->reqwidth()-18,
+			    -relwidth=>1.0);
+    }
+
+    $nexty+=15+$temp->reqheight();
+
+
+    $minwidth=400;
+    $minheight=$nexty+28+$setup_logo->reqheight()+$setup_cancel->reqheight();
+    
+    $setup->minsize($minwidth,$minheight);
+    $setup->geometry(($minwidth+20)."x".$minheight);
+
+    $setup_quit->configure(-command=>[sub{
+	$TEMPCONF{"OUTPUT_PATH"}='-' if($tempstdout eq 'yes');
+	$setup->destroy();undef $setup;%CONFIG=%TEMPCONF;
+	$window_setupbar->configure(state=>'normal');
+	$window_setupbar->configure(relief=>'raised');
+	SaveConfig();
+	
+	ThrowRealPlayer() if(!$comm_ready);
+    }]);
+
+    $setup_apply->configure(-command=>[sub{
+	$TEMPCONF{"OUTPUT_PATH"}='-' if($tempstdout eq 'yes');
+	%CONFIG=%TEMPCONF;
+	SaveConfig();
+	
+	ThrowRealPlayer() if(!$comm_ready);
+    }]);
+    
+    $setup_cancel->configure(-command=>[sub{
+	$setup->destroy();undef $setup;
+	$window_setupbar->configure(state=>'normal');
+	$window_setupbar->configure(relief=>'raised');
+    }]);
+
+    $setup_stdout->configure(-command=>[sub{Setup_Stdout();}]);
+
+}
+
+sub Setup_Debug{
+    if($TEMPCONF{'DEBUG'} eq 'yes'){
+	$TEMPCONF{'DEBUG'}='no';
+	$setup_debug->configure(-relief=>groove);
+    }else{
+	$TEMPCONF{'DEBUG'}='yes';
+	$setup_debug->configure(-relief=>sunken);
+    }
+}    
+
+sub Setup_Stdout{
+    if($tempstdout eq 'yes'){
+	$tempstdout='no';
+	$setup_path->configure(-state=>normal);
+	$setup_path->configure(-relief=>sunken);
+	$setup_stdout->configure(-relief=>groove);
+    }else{
+	$tempstdout='yes';
+	$setup_path->configure(-state=>disabled);
+	$setup_path->configure(-relief=>groove);
+	$setup_stdout->configure(-relief=>sunken);
+    }
+}    
+
+
+sub Timer{
+
+    $window_timerbar->configure(-state=>'disabled');
+    $window_timerbar->configure(-relief=>'flat');
+    $timerw=new MainWindow(-class=>'Snatch');
+
+    my$xpm_snatch=$timerw->Pixmap("_snatchlogo_xpm",-file=>$logofile);
+
+    $timerw_shell=$timerw->Label(Name=>"shell",borderwidth=>1,relief=>raised)->
+	place(-x=>10,-y=>36,-relwidth=>1.0,-relheight=>1.0,
+	      -width=>-20,-height=>-46,-anchor=>'nw');
+    
+    $timerw_quit=$timerw_shell->
+	Button(-class=>"Exit",text=>"X")->
+		   place(-x=>-1,-y=>-1,-relx=>1.0,-rely=>1.0,-anchor=>'se');
+    
+    $timerw_quit->configure(-command=>[sub{
+	$timerw->destroy();
+	$window_timerbar->configure(state=>'normal');
+	$window_timerbar->configure(relief=>'raised');
+    }]);
+
+    $timerw_logo=$timerw->
+	Label(Name=>"logo",-class=>"Panel",image=>$xpm_snatch)->
+		  place(-x=>5,-y=>5,-anchor=>'nw');
+
+    $timerw_title=$timerw->
+	Label(Name=>"timertext",-class=>"Panel",text=>"Timed Record Setup")->
+	    place(-x=>5,-relx=>1.0,-rely=>1.0,-anchor=>'sw',
+		  -in=>$timerw_logo);
+
+    $timerw_delete=$timerw_shell->
+	Button(Name=>"delete",text=>"delete",-state=>disabled)->
+	    place(-x=>-5,-relx=>1.0,-y=>-$timerw_quit->reqheight()-25,
+		  -rely=>1.0,-anchor=>'se');
+
+    $timerw_edit=$timerw_shell->
+	Button(Name=>"edit",text=>"edit",-state=>disabled)->
+	    place(-x=>0,-y=>-25,-relwidth=>1.0,-anchor=>'sw',
+		  -in=>$timerw_delete,-bordermode=>outside);
+    $timerw_add=$timerw_shell->
+	Button(Name=>"add",text=>"add")->
+	    place(-x=>0,-y=>-5,-relwidth=>1.0,-anchor=>'sw',
+		  -in=>$timerw_edit,-bordermode=>outside);
+
+    $listbox=Snatch::ListBox::new($timerw_shell,7,
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah",
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah1",
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah2",
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah3",
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah4",
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah5",
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah6",
+			  "2001","Dec","12","Tues","12:00","2 hours","rtsp://blah7")->
+			      place(-x=>5,-y=>5,-relheight=>1.0,-relwidth=>1.0,
+				    -width=>-$timerw_delete->reqwidth()-15,
+				    -height=>-$timerw_quit->reqheight()-30,
+				    -bordermode=>outside);
+    
+    $minwidth=500;
+    $minheight=$timerw_add->reqheight()*3+$timerw_quit->reqheight()+110;
+    
+    $timerw->minsize($minwidth,$minheight);
+    $timerw->geometry(($minwidth+20)."x".$minheight);
+    
+    $timerw->update();
+}
+
+package Snatch::ListBox;
+
+sub new{
+    my%listbox;
+    my$this=bless \%listbox;
+
+    my$parent=shift @_;
+    my$cols=$listbox{cols}=shift @_;
+    $listbox{rows}=0;
+    my at textrows;
+    my at widgetrows;
+
+    $listbox{textrows}=\@textrows;
+    $listbox{widgetrows}=\@widgetrows;
+
+    my$frame=$listbox{frame}=$parent->Frame(-class=>'ListBoxFrame');
+    my$scrollbar=$listbox{scrollbar}=$frame->Scrollbar(-orient=>"vertical")->
+	place(-relx=>1.0,-relheight=>1.0,-anchor=>'ne',-bordermode=>outside);
+    my$pane=$listbox{pane}=$frame->Frame(-class=>'ListBox')->
+	place(-relwidth=>1.0,-relheight=>1.0,-width=>-$scrollbar->reqwidth());
+
+    $listbox{window}=$pane->Frame(-class=>'ListFrame')->place(-relwidth=>1.0);
+
+    my$maxheight=0;
+
+    # row by row
+    my$done=0;
+    for($listbox{rows}=0;!$done;$listbox{rows}++){
+	my @textrow=();
+	my @widgetrow=();
+	$textrows[$listbox{rows}]=\@textrow;
+	$widgetrows[$listbox{rows}]=\@widgetrow;
+
+	for(my$j=0;$j<$cols;$j++){
+	    my$temp=shift;
+	    if(defined($temp)){
+		$textrow[$j]=$temp;
+		if($listbox{rows} % 2){
+		    $widgetrow[$j]=$listbox{window}->
+			Label(-class=>'ListRowEven',text=>$temp);
+		}else{
+		    $widgetrow[$j]=$listbox{window}->
+			Label(-class=>'ListRowOdd',text=>$temp);
+		}
+	    }else{
+		$done=1;
+		last;
+	    }
+	}
+    }
+    $listbox{rows}--;
+	
+    my at maxwidth;
+    my$x=0;
+    my$y=0;
+
+    # find widths col by col
+    for(my$j=0;$j<$listbox{cols};$j++){
+	$y=0;
+	$maxwidth[$j]=0;
+	for(my$i=0;$i<$listbox{rows};$i++){
+	    my$width=$widgetrows[$i][$j]->reqwidth();
+	    my$height=$widgetrows[$i][$j]->reqheight();
+	    $maxwidth[$j]=$width if($width>$maxwidth[$j]);
+	    $maxheight=$height if($height>$maxheight);
+	}
+
+	if($j+1<$listbox{cols}){
+	    for(my$i=0;$i<$listbox{rows};$i++){
+		$widgetrows[$i][$j]->
+		    place(-height=>$maxheight,-width=>$maxwidth[$j],
+			  -x=>$x,-y=>$y);
+		$y+=$maxheight+3;
+	    }
+	    $x+=$maxwidth[$j]+1;
+	}else{
+	    for(my$i=0;$i<$listbox{rows};$i++){
+		$widgetrows[$i][$j]->configure(-anchor=>w);
+		$widgetrows[$i][$j]->
+		    place(-height=>$maxheight,-relwidth=>1.0,
+			  -width=>-$x,-x=>$x,-y=>$y);
+		$y+=$maxheight+3;
+	    }
+	    $x+=$maxwidth[$j]+1;
+	}
+    }
+
+    #$frame->bind('syncscrollbar','<Configure>',[\$this->resize,Ev('w'),Ev('h')]);
+    $pane->bind('<Configure>',[sub{$this->resize();}]);
+    $listbox{window}->configure(-height=>$y);
+    $scrollbar->configure(-command=>[yview=>$this]);
+
+    $this;
+}
+   
+sub place{
+    my$this=shift;
+    $this->{frame}->place(@_);
+    $this;
+}
+
+sub destroy{
+    my$this=shift;
+    $this->{frame}->destroy();
+    undef $$this;
+}
+
+sub yview{
+    my$this=shift;
+    
+    my$paneheight=$this->{pane}->height();
+    my$listheight=$this->{window}->height();
+
+    my$first=-$this->{window}->y()/$listheight;
+    my$second=(-$this->{window}->y()+$paneheight)/$listheight;
+
+    print "$first $second\n";
+    ($first,$second);
+
+}
+
+sub resize{
+    my$this=shift;
+
+    print "resize\n";
+    
+    $this->{scrollbar}->set($this->yview());
+}
+# eg
+# 2001 11 05 1 12:25 300000 FAKEA FAKEV length:USERNAME length:PASSWORD length:FILE length:URL
 
 
 

1.11      +36 -31    snatch/x11.c

Index: x11.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/x11.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- x11.c	2001/11/07 05:13:46	1.10
+++ x11.c	2001/11/08 03:41:49	1.11
@@ -474,43 +474,48 @@
   }
 
   /* watch for the auth password window */
-  if(n>32 &&  !memcmp(data,"AuthDialogShell\0RCACoreAppShell\0",32)){
-    if(rpauth_already>2){
-      fprintf(stderr,
-	      "**ERROR: Password not accepted.\n");
-      rpauth_shell=0;
-      rpauth_already=0;
-    }else{      
-      fprintf(stderr,
-	      "    ...: RealPlayer popped auth window.  Watching for username\n"
-	      "         password and ok button windows\n");
-      rpauth_shell=id;
-      rpauth_count=0;
-      rpauth_username=0;
-      rpauth_password=0;
-      rpauth_okbutton=0;
-      rpauth_already++;
+  if(username || password){
+    if(n>32 &&  !memcmp(data,"AuthDialogShell\0RCACoreAppShell\0",32)){
+      if(rpauth_already>2){
+	fprintf(stderr,
+		"**ERROR: Password not accepted.\n");
+	rpauth_shell=0;
+	rpauth_already=0;
+      }else{      
+	fprintf(stderr,
+		"    ...: RealPlayer popped auth window.  Watching for username\n"
+		"         password and ok button windows\n");
+	rpauth_shell=id;
+	rpauth_count=0;
+	rpauth_username=0;
+	rpauth_password=0;
+	rpauth_okbutton=0;
+	rpauth_already++;
+      }
     }
   }
 
   /* watch for the open location window */
-  if(n>36 &&  !memcmp(data,"OpenLocationDialogShell\0RCACoreAppShell\0",36)){
-    fprintf(stderr,
+  if(location){
+    if(n>36 &&  !memcmp(data,"OpenLocationDialogShell\0RCACoreAppShell\0",36)){
+      fprintf(stderr,
             "    ...: RealPlayer popped open location dialog.  Watching for\n"
-	    "         dialog window tree...\n");
-    rploc_shell=id;
-    rploc_count=0;
-    rploc_entry=0;
-    rploc_clear=0;
-    rploc_ok=0;
+	      "         dialog window tree...\n");
+      rploc_shell=id;
+      rploc_count=0;
+      rploc_entry=0;
+      rploc_clear=0;
+      rploc_ok=0;
+    }
   }
-
-  /* watch for the open file window */
-  if(n>32 && !memcmp(data,"OpenFileDialogShell\0RCACoreAppShell\0",32)){
-    fprintf(stderr,
-	    "    ...: RealPlayer popped open file dialog.\n");
-    rpfile_shell=id;
-    rpfile_main=0;
+  if(openfile){
+    /* watch for the open file window */
+    if(n>32 && !memcmp(data,"OpenFileDialogShell\0RCACoreAppShell\0",32)){
+      fprintf(stderr,
+	      "    ...: RealPlayer popped open file dialog.\n");
+      rpfile_shell=id;
+      rpfile_main=0;
+    }
   }
 }
 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list