[Freeswitch-branches] [commit] r3538 - freeswitch/branches/igorneves/scripts/socket

Freeswitch SVN igorneves at freeswitch.org
Tue Dec 5 06:59:20 EST 2006


Author: igorneves
Date: Tue Dec  5 06:59:19 2006
New Revision: 3538

Modified:
   freeswitch/branches/igorneves/scripts/socket/fsconsole.pl

Log:
corrected status bar, added a clean func (not finish yet), added suport for "!ls"

Modified: freeswitch/branches/igorneves/scripts/socket/fsconsole.pl
==============================================================================
--- freeswitch/branches/igorneves/scripts/socket/fsconsole.pl	(original)
+++ freeswitch/branches/igorneves/scripts/socket/fsconsole.pl	Tue Dec  5 06:59:19 2006
@@ -9,7 +9,6 @@
 use POE qw/Filter::FSSocket Component::Client::TCP/;
 use Data::Dumper;
 use Term::Visual;
-use Sys::Hostname;
 
 local *D;
 if (Term::Visual::DEBUG) {
@@ -63,7 +62,8 @@
 		'update_time'  => \&handle_update_time,  #update the status line clock
 		'quit'         => \&handle_quit,         #handler to do any cleanup
 		'server_input' => \&handle_server_input,
-		'_default'      => \&handle_default,
+                'clean'        => \&handle_curses_clean,
+		'_default'     => \&handle_default,
 	},
 	'heap' => {
 		'terminal'     => undef,
@@ -101,11 +101,11 @@
 	my $window_id = $terminal->create_window(
 		'Window_Name' => 'console',
 		'Buffer_Size' => 3000,
-		'Title'       => 'FreeSWITCH Console @ '.hostname,
+		'Title'       => 'FreeSWITCH Console',
 		'Status'      => {
 			'0' => {
-				'format' => '%s',
-				'fields' => ['time'],
+				'format' => '%s - %s',
+				'fields' => [qw( host time )],
 			},
 			'1' => {
 				'format' => '%s',
@@ -157,7 +157,7 @@
 
 	$terminal->change_window(0);
 	$kernel->delay_set('update_time' => 1);
-	$terminal->set_status_field(0, 'time' => scalar(localtime));
+	$terminal->set_status_field(0, 'host' => $server_address, 'time' => scalar(localtime));
 	new_message('destination_window' => 0, 'message' =>  "
 Welcome to the FreeSWITCH POE Curses Console!
   The console is split into three windows:
@@ -204,9 +204,20 @@
 
 	open(ERROR, ">>error.log");
 
-	if($input =~ /^\s*(exit)|(quit)\s*$/) {
-		$kernel->yield('quit');
-	} elsif ($input =~ /^w\ (.*)$/) {
+        if($input =~ /^\s*(exit)|(quit)\s*$/){
+	   $kernel->yield('quit');
+        }
+        if($input =~ /^\s*(clean)\s*$/){
+	   $kernel->yield('clean');
+        }
+	if($input =~ /^!{1}(.*)/) {
+	   if(defined($window)) {
+	      my $output = qx($1);
+	      new_message('destination_window' => $window, 'message' => $output);
+	   }
+	}
+
+	elsif ($input =~ /^w\ (.*)$/) {
 		#get the id of the requested window
 		eval {
 			my $window_id = $windows{$1};
@@ -310,8 +321,13 @@
 
 sub handle_update_time {
 	my ($kernel, $heap) = @_[KERNEL, HEAP];
-	$terminal->set_status_field($terminal->current_window, 'time' => scalar(localtime));
+	$terminal->set_status_field($terminal->current_window, 'host' => $server_address, 'time' => scalar(localtime));
 	$kernel->delay_set('update_time' => 1);
+}
+
+sub handle_curses_clean {
+	 my ($kernel, $heap) = @_[KERNEL, HEAP];
+	 #TODO
 }
 ###############################################################################
 ##   END Handlers #############################################################



More information about the Freeswitch-branches mailing list