version 1.4, 2025/01/31 19:41:00
|
version 1.5, 2025/02/01 03:17:46
|
Line 11
|
Line 11
|
# Licensed AGPL-3.0 |
# Licensed AGPL-3.0 |
# |
# |
# $Log$ |
# $Log$ |
|
# Revision 1.5 2025/02/01 03:17:46 snw |
|
# Fix session list |
|
# |
# Revision 1.4 2025/01/31 19:41:00 snw |
# Revision 1.4 2025/01/31 19:41:00 snw |
# Move to a UNIX UI paradigm |
# Move to a UNIX UI paradigm |
# |
# |
Line 121 sub list_ras_sessions {
|
Line 124 sub list_ras_sessions {
|
my $hashref = decode_json($json); |
my $hashref = decode_json($json); |
my $sessions = $hashref->{sessions}; |
my $sessions = $hashref->{sessions}; |
my $arrayref = $sessions->{sessions}; |
my $arrayref = $sessions->{sessions}; |
my $ct = 0; |
my @result = (); |
|
|
foreach my $session (@{$arrayref}) { |
foreach my $session (@{$arrayref}) { |
print "$session->{screen_name}\n"; |
push(@result, $session->{id}); |
|
|
$ct = $ct + 1; |
|
|
|
if($ct > $hchar - 2) { |
|
print "ENTER to continue, Q to quit..."; |
|
my $resp = <STDIN>; |
|
chomp($resp); |
|
if($resp eq "Q") { |
|
return; |
|
} |
|
elsif($resp eq "q") { |
|
return; |
|
} |
|
$ct = 0; |
|
} |
|
} |
} |
|
|
print "$sessions->{count} current sessions\n"; |
return @result; |
} |
} |
|
|
sub list_ras_screennames { |
sub list_ras_screennames { |
my($id) = @_; |
my($id) = @_; |
|
|
$cnclient->GET("/chivanet/ras_screen_names?id=$id"); |
my @result = (); |
|
$cnclient->GET("/chivanet/user_ras_screen_names?id=$id"); |
my $json = $cnclient->responseContent(); |
my $json = $cnclient->responseContent(); |
my $hashref = decode_json($json); |
my $hashref = decode_json($json); |
my $arrayref = $hashref->{screen_names}; |
my $arrayref = $hashref->{screen_names}; |
|
|
|
foreach my $item (@{$arrayref}) { |
|
push(@result, $item->{screen_name}); |
|
} |
|
|
|
|
return @{$arrayref}; |
return @result; |
} |
} |
|
|
sub list_ras_users { |
sub list_ras_users { |
|
|
return (); |
my @result = (); |
|
|
|
$cnclient->GET("/chivanet/all_ras_screen_names"); |
|
my $json = $cnclient->responseContent(); |
|
my $hashref = decode_json($json); |
|
|
|
if($hashref->{ok} == 0) { |
|
print "RPC error\n"; |
|
return @result; |
|
} |
|
|
|
my $arrayref = $hashref->{screen_names}; |
|
|
|
foreach my $entryref (@{$arrayref}) { |
|
push(@result, $entryref->{id}); |
|
} |
|
|
|
return @result; |
} |
} |
|
|
sub print_sso_user { |
sub print_sso_user { |
Line 217 sub print_ras_user {
|
Line 227 sub print_ras_user {
|
} |
} |
else { |
else { |
print "Screen Name : $id [$online]\n\n"; |
print "Screen Name : $id [$online]\n\n"; |
} |
} |
|
|
# print Dumper($status); |
|
|
|
} |
} |
|
|
Line 242 sub send_im {
|
Line 250 sub send_im {
|
} |
} |
} |
} |
|
|
|
sub ls { |
|
my ($description, @entries) = @_; |
|
|
|
my @sorted = sort(@entries); |
|
my $maxlen = 0; |
|
foreach my $entry (@sorted) { |
|
my $len = length($entry); |
|
if ($len > $maxlen) { |
|
$maxlen = $len; |
|
} |
|
} |
|
$maxlen = $maxlen + 2; |
|
my $ct = $#sorted + 1; |
|
foreach my $entry (@sorted) { |
|
if($col + $maxlen >= $wchar) { |
|
print "\n"; |
|
$col = 0; |
|
} |
|
else { |
|
printf("%-$maxlen\s", $entry); |
|
$col = $col + $maxlen; |
|
} |
|
} |
|
print "\n$ct items in $description\n"; |
|
|
|
} |
|
|
sub prompt { |
sub prompt { |
|
|
my $rawcmd = ''; |
my $rawcmd = ''; |
Line 269 sub prompt {
|
Line 304 sub prompt {
|
|
|
my @cmd = split(' ', $rawcmd); |
my @cmd = split(' ', $rawcmd); |
|
|
if ($cmd[0] eq "exit" || $cmd[0] eq "logout" || $cmd[0] eq "quit" || $cmd[0] eq "bye") { |
if ($cmd[0] eq "exit" || $cmd[0] eq "logout" || $cmd[0] eq "quit" || $cmd[0] eq "bye" || $cmd[0] eq "lo") { |
return; |
return; |
} |
} |
elsif ($cmd[0] eq "pwd") { |
elsif ($cmd[0] eq "pwd") { |
Line 402 sub prompt {
|
Line 437 sub prompt {
|
} |
} |
} |
} |
} |
} |
} # if .. |
} # if .. |
|
|
} |
} |
elsif ($cmd[0] eq "im") { |
elsif ($cmd[0] eq "im") { |
if($mode eq "RAS") { |
if($mode eq "RAS") { |
Line 450 sub prompt {
|
Line 484 sub prompt {
|
print "field: command invalid outside of ras directory\n"; |
print "field: command invalid outside of ras directory\n"; |
} |
} |
} |
} |
|
elsif ($cmd[0] eq "sessions") { |
|
if($mode ne "RAS") { |
|
print "sessions: must be in ras mode\n"; |
|
} |
|
else { |
|
ls "active RAS sessions", list_ras_sessions(); |
|
} |
|
} |
|
elsif ($cmd[0] eq "lssn") { |
|
if($mode ne "SSO" || $user eq "---") { |
|
print "lssn: must be in sso mode with a user selected\n"; |
|
} |
|
else { |
|
my @sns = list_ras_screennames($user); |
|
ls "RAS screen names for $user", @sns; |
|
} |
|
} |
elsif ($cmd[0] eq "ls") { |
elsif ($cmd[0] eq "ls") { |
my @entries = (); |
my @entries = (); |
|
|
Line 479 sub prompt {
|
Line 530 sub prompt {
|
my $col = 0; |
my $col = 0; |
my $pstr = join('/', @path); |
my $pstr = join('/', @path); |
my $pfin = "/$pstr"; |
my $pfin = "/$pstr"; |
my @sorted = sort(@entries); |
ls $pfin, @entries; |
my $maxlen = 0; |
|
foreach my $entry (@sorted) { |
|
my $len = length($entry); |
|
if ($len > $maxlen) { |
|
$maxlen = $len; |
|
} |
|
} |
|
$maxlen = $maxlen + 2; |
|
my $ct = $#sorted + 1; |
|
foreach my $entry (@sorted) { |
|
if($col + $maxlen >= $wchar) { |
|
print "\n"; |
|
$col = 0; |
|
} |
|
else { |
|
printf("%-$maxlen\s", $entry); |
|
$col = $col + $maxlen; |
|
} |
|
} |
|
print "\n\t$ct items in $pfin\n"; |
|
} |
} |
|
|
} |
} |