upstream version 2.8.2 master
authorivan <ivan>
Sun, 23 May 2010 01:11:00 +0000 (01:11 +0000)
committerivan <ivan>
Sun, 23 May 2010 01:11:00 +0000 (01:11 +0000)
Changes
lib/CGP/CLI.pm

diff --git a/Changes b/Changes
index feb6f41..f49297f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,6 +3,9 @@ http://www.stalker.com/CGPerl/History.html
 
 This changelog reflects the CPAN packaging.
 
+2.8.2 unreleased
+- packaged http://www.stalker.com/CGPerl/CLI.pm version 2.8.2 for CPAN
+
 2.8.0 unreleased
 - packaged http://www.stalker.com/CGPerl/CLI.pm version 2.8.0 for CPAN
 - reordered this changelog in reverse-chronologial and added note about
index 596ff6b..4eee367 100644 (file)
@@ -1,7 +1,7 @@
 ####################################################################
 #  Perl interface to CommuniGate Pro CLI.
 #
-#  Version 2.8.0
+#  Version 2.8.2
 #
 #  Original location: <http://www.communigate.com/CGPerl/>
 #  Revision history: <http://www.communigate.com/CGPerl/History.html>
 # [Get|Set]ClientIPs 
 # [Get|Set]WhiteHoleIPs 
 # [Get|Set]Protection 
+# [Get|Set]Network 
 # [Get|Set]Banned
 
 # [Get|Set]ClusterLANIPs
 # [Get|Set]ClusterClientIPs 
 # [Get|Set]ClusterWhiteHoleIPs 
 # [Get|Set]ClusterProtection 
+# [Get|Set]ClusterNetwork 
 # GetClusterBanned
 
 # [Get|Set][Server|Cluster]Rules
@@ -265,7 +267,7 @@ use IO::Socket;
 use Digest::MD5;
 
 use vars qw($VERSION);
-$VERSION = '2.8.0';
+$VERSION = '2.8.2';
 
 
 $CGP::SECURE_LOGIN = 1;
@@ -368,7 +370,7 @@ sub new {
     if($this->{isSecureLogin} && $this->{isWebUserLogin});
 
   #print %$params;
-  bless $this;
+  bless $this, $class;
   $this->{connParams}=$params;
   
   if(!(defined $params->{'connectNow'}) || $params->{'connectNow'}) { 
@@ -572,10 +574,12 @@ sub SetAccount {
 }
 
 sub SetAccountPassword {
-  my ($this, $accountName, $newPass) = @_;
-  croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword)'
+  my ($this, $accountName, $newPass,$check) = @_;
+  croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword,$check)'
     unless defined $accountName && defined $newPass;
-  $this->send('SetAccountPassword '.$accountName.' TO '.$this->printWords($newPass));
+  my $line = 'SetAccountPassword '.$accountName.' PASSWORD '.$this->printWords($newPass); 
+  $line .= ' CHECK' if($check);
+  $this->send($line);
   $this->_parseResponse();
 }
 
@@ -3191,6 +3195,12 @@ sub GetProtection {
   return undef unless $this->_parseResponse();
   $this->parseWords($this->getWords);
 }
+sub GetNetwork {
+  my ( $this ) = @_;
+  $this->send('GetNetwork');
+  return undef unless $this->_parseResponse();
+  $this->parseWords($this->getWords);
+}
 
 sub GetBanned {
   my ( $this ) = @_;
@@ -3260,6 +3270,13 @@ sub SetProtection {
   $this->send ('SetProtection '.$this->printWords($settings));
   $this->_parseResponse();
 }
+sub SetNetwork {
+  my ( $this, $settings ) = @_;
+  croak 'usage CGP::CLI->SetNetwork(\%settings)'
+    unless defined $settings;
+  $this->send ('SetNetwork '.$this->printWords($settings));
+  $this->_parseResponse();
+}
 
 sub SetBanned {
   my ( $this, $settings ) = @_;
@@ -3321,6 +3338,12 @@ sub GetClusterProtection {
   return undef unless $this->_parseResponse();
   $this->parseWords($this->getWords);
 }
+sub GetClusterNetwork {
+  my ( $this ) = @_;
+  $this->send('GetClusterNetwork');
+  return undef unless $this->_parseResponse();
+  $this->parseWords($this->getWords);
+}
 sub GetClusterBanned {
   my ( $this ) = @_;
   $this->send('GetClusterBanned');
@@ -3388,6 +3411,13 @@ sub SetClusterProtection {
   $this->send ('SetClusterProtection '.$this->printWords($settings));
   $this->_parseResponse();
 }
+sub SetClusterNetwork {
+  my ( $this, $settings ) = @_;
+  croak 'usage CGP::CLI->SetClusterNetwork(\%settings)'
+    unless defined $settings;
+  $this->send ('SetClusterNetwork '.$this->printWords($settings));
+  $this->_parseResponse();
+}
 
 sub GetServerRules {
   my $this = shift;
@@ -3688,6 +3718,90 @@ sub ResetDomainStat {
 }
 
 #############################################
+#  Directory Administration commands
+
+sub ListDirectoryUnits {
+  my ($this, $shared) = @_;
+  my $line = 'ListDirectoryUnits';
+  $line .= ' SHARED' if $shared;
+  $this->send($line);
+  $this->_parseResponse();
+}
+
+sub CreateDirectoryUnit {
+  my ($this, $unitName,$mountPoint,$shared,$remote) = @_;
+  croak 'usage CGP::CLI->CreateDirectoryUnit($unitName,$mountPoint,[$shared,[$remote]])'
+    unless defined $unitName && defined $mountPoint;
+  my $line = 'CreateDirectoryUnit '.$unitName;
+  $line .= ' SHARED' if $shared;
+  $line .= ' REMOTE' if $remote;
+  $line .= ' '.$mountPoint;
+  $this->send($line);
+  $this->_parseResponse();
+}
+
+sub RelocateDirectoryUnit {
+  my ($this, $unitName,$newMountPoint,$shared) = @_;
+  croak 'usage CGP::CLI->RelocateDirectoryUnit($unitName,$newMountPoint,[$shared])'
+    unless defined $unitName && defined $newMountPoint;
+  my $line = 'RelocateDirectoryUnit '.$unitName;
+  $line .= ' SHARED' if $shared;
+  $line .= ' '.$newMountPoint;
+}
+
+sub DeleteDirectoryUnit {
+  my ($this, $unitName,$shared) = @_;
+  croak 'usage CGP::CLI->DeleteDirectoryUnit($unitName,[$shared])'
+    unless defined $unitName;
+  my $line = 'DeleteDirectoryUnit '.$unitName;
+  $line .= ' SHARED' if $shared;
+  $this->send($line);
+  $this->_parseResponse();
+}
+
+sub GetDirectoryUnit {
+  my ($this, $unitName,$shared) = @_;
+  croak 'usage CGP::CLI->GetDirectoryUnit($unitName,[$shared])'
+    unless defined $unitName;
+  my $line = 'GetDirectoryUnit '.$unitName;
+  $line .= ' SHARED' if $shared;
+  $this->send($line);
+  return undef unless $this->_parseResponse();
+  $this->parseWords($this->getWords);
+}
+
+sub SetDirectoryUnit {
+  my ($this, $unitName,$newSettings,$shared) = @_;
+  croak 'usage CGP::CLI->SetDirectoryUnit($unitName,$newSettings,[$shared])'
+    unless defined $unitName && defined $newSettings;
+  my $line = 'SetDirectoryUnit '.$unitName;
+  $line .= ' SHARED' if $shared;
+  $line .= ' '.$this->printWords($newSettings);
+  $this->send($line);
+  $this->_parseResponse();
+}
+
+sub GetDirectoryAccessRights {
+  my ($this, $shared) = @_;
+  my $line = 'GetDirectoryAccessRights';
+  $line .= ' SHARED' if $shared;
+  $this->send($line);
+  return undef unless $this->_parseResponse();
+  $this->parseWords($this->getWords);
+}
+
+sub SetDirectoryAccessRights {
+  my ($this, $unitName,$newRights,$shared) = @_;
+  croak 'usage CGP::CLI->SetDirectoryAccessRights($newRights,[$shared])'
+    unless defined $newRights;
+  my $line = 'SetDirectoryAccessRights';
+  $line .= ' SHARED' if $shared;
+  $line .= ' '.$this->printWords($newRights);
+  $this->send($line);
+  $this->_parseResponse();
+}
+
+#############################################
 #  Miscellaneous commands
 
 sub WriteLog {
@@ -3904,8 +4018,7 @@ sub skipSpaces {
 
 sub readWord {
   my $this = shift;
-  my $isQuoted=0;
-  my $isBlock=0;
+  my ($isQuoted,$isBlock,$isUnkData)=(0,0,0);
   my $result="";
 
   $this->skipSpaces();
@@ -3913,6 +4026,10 @@ sub readWord {
     $isQuoted=1; ++$this->{'span'};
   } elsif(substr($this->{'data'},$this->{'span'},1) eq '[') {
     $isBlock=1;
+  } elsif(substr($this->{'data'},$this->{'span'},2) eq '#(') {
+    $isUnkData=1;
+    $result='#(';
+    $this->{'span'}+=2;
   }
   while($this->{'span'} < $this->{'len'}) {
     my $ch=substr($this->{'data'},$this->{'span'},1);
@@ -3950,6 +4067,13 @@ sub readWord {
         }  
 
       }
+    } elsif($isUnkData) {
+      if($ch eq ')') {
+        $result .= $ch;
+        ++$this->{'span'};
+        $this->skipSpaces();    
+        last;
+      }
     } elsif($ch =~ /[-a-zA-Z0-9\x80-\xff_\.\@\!\#\%\:]/) {    
     } else {
       last;
@@ -4067,7 +4191,7 @@ sub readDictionary {
       ++$this->{'span'};
       last;
     } else {
-      my $theKey=$this->readKey();
+      my $theKey=$this->readKey();     
       $this->skipSpaces();
       if(substr($this->{'data'},$this->{'span'},1) ne '=') { croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10); }
       ++$this->{'span'};