<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">####################################################################
#  Perl interface to CommuniGate Pro CLI.
#
#  Version 2.7.7
#
#  Original location: &lt;http://www.communigate.com/CGPerl/&gt;
#  Revision history: &lt;http://www.communigate.com/CGPerl/History.html&gt;
#
#  See &lt;http://www.communigate.com/CommuniGatePro/CLI.html&gt; for the related info.
#
#  Mail your comments and error reports to &lt;support@stalker.com&gt;

############################## Commands: 
# new
# Logout
# getErrCode
# getErrMessage
# isSuccess
# getErrCommand
# setStringsTranslateMode
# NewPassword
# SendCommand
# GetResponseData

############################## Accounts commands
# ListAccounts
# CreateAccount 
# RenameAccount 
# DeleteAccount
# SetAccountType
# GetAccountSettings
# GetAccountEffectiveSettings
# UpdateAccountSettings
# SetAccountSettings
# SetAccountPassword
# VerifyAccountPassword
# GetAccountAliases
# SetAccountAliases
# [Get|Set]AccountTelnums
# [Get|Set]AccountRules
# [Get|Set]Account[Mail|Signal]Rules
# UpdateAccount[Mail|Signal]Rule
# SetAccountRules
# GetAccountRPOP
# SetAccountRPOP
# GetAccountRights
# SetAccountRights
# GetAccountInfo
# [Get|Set|Update]AccountPrefs
# GetAccountEffectivePrefs
# KillAccountSessions
# [Get|Set]AccountACL
# GetAccountACLRights
# GetAccountPresence
############################## Group Commands
# ListGroups
# CreateGroup
# RenameGroup
# DeleteGroup
# GetGroup
# SetGroup

############################## Forwarder Commands
# ListForwarders
# CreateForwarder
# RenameForwarder
# DeleteForwarder
# GetForwarder
# FindForwarders

############################## Domain commands
# ListDomains
# MainDomainName
# [Get|Update|Set]DomainSettings
# GetDomainEffectiveSettings
# [Create|Rename|Delete]Domain
# [Suspend|Resume]Domain
# CreateSharedDomain
# CreateDirectoryDomain
# [Get|Set]DomainRules
# [Get|Set]DomainAliases
# ListAdminDomains
# [Insert|Delete]DirectoryRecords
# [Get|Set][Server|Cluster]TrustedCerts

# [Get|Set]DirectoryIntegration
# [Get|Set]ClusterDirectoryIntegration


# [Get|Update|Set]DomainDefaults
# [Get|Update|Set]ClusterDomainDefaults
# [Get|Update|Set]AllAccountsDefaults *
# [Get|Update|Set]ServerAccountsDefaults
# GetDomainLocation
# GetAccountLocation
# [Get|Update|Set]AccountDefaults
# [Get|Update|Set]ClusterAccountDefaults
# [Get|Set|Update]AccountDefaultPrefs
# [Get|Set][Server|Cluster]AccountPrefs
# [Get|Update|Set]AccountTemplate

############################## Mailbox Administration
# ListMailboxes
# [Create|Rename|Delete]Mailbox
# [Rename|Delete]Mailboxes
# GetMailboxInfo
# [Get|Set]MailboxACL
# GetMailboxRights
# SetMailboxClass

# [Get|Set]AccountSubscription
# [Get|Set]MailboxAliases

############################## Alerts Administration
# Get[Domain|Account|Server|Cluster]Alerts
# Set[Domain|Account|Server|Cluster]Alerts
# Post[Domain|Account|Server|Cluster]Alert
# Remove[Domain|Account|Server|Cluster]Alert

############################## Personal Web Site Administration
# GetWebFile
# PutWebFile
# RenameWebFile
# DeleteWebFile
# ListWebFiles
# GetWebFilesInfo

############################## Lists commands
# ListLists
# GetDomainLists
# GetAccountLists
# [Create|Rename|Delete|Get|Update]List
# List
# ListSubscribers
# GetSubscriberInfo
# SetPostingMode
# ProcessBounce

############################## Web Skins Administration 
# ListDomainSkins( [domainName] )
# CreateDomainSkin(domainName,skinName)
# RenameDomainSkin(domainName,oldSkinName,newSkinName)
# DeleteDomainSkin(domainName,skinName)
# ListDomainSkinFiles(domainName,skinName)
# ReadDomainSkinFile(domainName,skinName,fileName)
# StoreDomainSkinFile(domainName,skinName,fileName,base64data)
# DeleteDomainSkinFile(domainName,skinName,fileName)

# ListServerSkins()
# CreateServerSkin(skinName)
# RenameServerSkin(oldSkinName,newSkinName)
# DeleteServerSkin(skinName)
# ListServerSkinFiles(skinName)
# ReadServerSkinFile(skinName,fileName)
# StoreServerSkinFile(skinName,fileName,base64data)
# DeleteServerSkinFile(skinName,fileName)

# ListClusterSkins()
# CreateClusterSkin(skinName)
# RenameClusterSkin(oldSkinName,newSkinName)
# DeleteClusterSkin(skinName)
# ListClusterSkinFiles(skinName)
# ReadClusterSkinFile(skinName,fileName)
# StoreClusterSkinFile(skinName,fileName,base64data)
# DeleteClusterSkinFile(skinName,fileName)

############################## Web Interface Tuning
# [List|Get|Put|Delete]WebUserInterface
# ClearWebUserCache

############################## Web Interface Integration
# [Create|Get|Kill|Find]WebUserSession
# CreateXIMSSSession
# FindAccountSession
# [Get|Kill]Session

############################## Real-Time Application Administration
# Create[Domain|Server|Cluster]PBX
# List[Domain|Server|Cluster]PBXFiles
# [Read|Store|Delete][Domain|Server|Cluster]PBXFile

############################## Real-Time Application Control
# StartPBXTask
# SendTaskEvent
# KillNode
# ReadNodeStatus
############################## Server commands
# [Get|Update|Set]Module

# [Get|Set]LANIPs
# [Get|Set]BlacklistedIPs
# [Get|Set]ClientIPs 
# [Get|Set]WhiteHoleIPs 
# [Get|Set]Protection 
# [Get|Set]Banned

# [Get|Set]ClusterLANIPs
# [Get|Set]ClusterBlacklistedIPs
# [Get|Set]ClusterClientIPs 
# [Get|Set]ClusterWhiteHoleIPs 
# [Get|Set]ClusterProtection 
# GetClusterBanned

# [Get|Set][Server|Cluster]Rules
# [Get|Set][Server|Cluster][Mail|Signal]Rules
## Update[Server|Cluster][Mail|Signal]Rule

# RefreshOSData
# [Get|Set]RouterTable
# [Get|Set]RouterSettings
# [Get|Set]ClusterRouterTable
# [Get|Set][Server|Cluster]Intercept

# Route

############################## Monitoring commands
# GetSNMPElement
# Shutdown

############################## Statistics commands
# [Get|Reset]AccountStat
# [Get|Reset]DomainStat

############################## Miscellaneous commands
# WriteLog
# ReleaseSMTPQueue
# RejectQueueMessage
# GetMessageQueueInfo
# GetCurrentController
# GetTempClientIPs
# [Get|Set]TempBlacklistedIPs 
# RemoveAccountSubset
# List[Domain|Server|Cluster]Telnums

##############################################################

package CGP::CLI;

use strict;
use Carp;

# You may need to change this to "use IO::Socket::INET;" if you have INET.pm
use IO::Socket;

# You may need to install this module.
# See &lt;http://search.cpan.org/search?module=Digest::MD5&gt;
use Digest::MD5;



$CGP::SECURE_LOGIN = 1;
$CGP::WEBUSER_LOGIN = 0;
$CGP::TIMEOUT = 60*5-5;  # 5 minutes timeout

$CGP::ERR_STRING = "No error";

$CGP::CLI_CODE_OK = 200;
$CGP::CLI_CODE_OK_INLINE = 201;

$CGP::CLI_CODE_PASSWORD = 300;
$CGP::CLI_CODE_UNKNOW_USER = 500;
$CGP::CLI_CODE_GEN_ERR = 501;
$CGP::CLI_CODE_STRANGE = 10000;




sub connect {
  my ($this) = @_;
  $this-&gt;{isConnected}=0;  
  
  delete $this-&gt;{theSocket};

  $this-&gt;{theSocket} = new IO::Socket::INET( %{$this-&gt;{connParams}} );

  unless(defined $this-&gt;{theSocket} &amp;&amp; $this-&gt;{theSocket}) {
    $CGP::ERR_STRING="Can't open connection to CGPro Server";
    return undef;
  };
  $this-&gt;{theSocket}-&gt;autoflush(1);

  unless($this-&gt;_parseResponse()) {
    $CGP::ERR_STRING="Can't read CGPro Server prompt";
    return undef;
  };

  if($this-&gt;{isSecureLogin} &amp;&amp; $this-&gt;{errMsg} =~ /(\&lt;.*\@.*\&gt;)/) {
    my $md5=Digest::MD5-&gt;new;
    if($md5) {
      $md5-&gt;add($1.$this-&gt;{password});
      $this-&gt;send('APOP '.$this-&gt;{login}.' '.$md5-&gt;hexdigest);
      $this-&gt;_parseResponse();
    } else {
      $CGP::ERR_STRING="Can't create MD5 object";
      close($this-&gt;{theSocket});
      return undef;
    }
  } elsif($this-&gt;{isWebUserLogin}) {
    $this-&gt;send('AUTH WEBUSER '.$this-&gt;{login}.' '.$this-&gt;{password});
    $this-&gt;_parseResponse();
  
  } else {  
    $this-&gt;send('USER '.$this-&gt;{login});
    $this-&gt;_parseResponse();
    unless( $this-&gt;{errCode} == $CGP::CLI_CODE_PASSWORD) {
      $CGP::ERR_STRING="Unexpected answer: ".$this-&gt;{errCode};
      close($this-&gt;{theSocket});
      return undef;
    }
    $this-&gt;send('PASS '.$this-&gt;{password});
    $this-&gt;_parseResponse();    
  }

  unless($this-&gt;isSuccess) {
    $CGP::ERR_STRING=$this-&gt;{errMsg};
    close($this-&gt;{theSocket});
    return undef;
  }
  $this-&gt;send('INLINE');
  $this-&gt;_parseResponse();
  $this-&gt;setStringsTranslateMode(0);
  $this-&gt;{isConnected}=1;  
  1;
}


sub new {
  my ($class, $params) = @_;
  my $this = {};
  
  $this-&gt;{login} = delete $params-&gt;{'login'};
  $this-&gt;{password} = delete $params-&gt;{'password'};

  $this-&gt;{isSecureLogin} = delete $params-&gt;{'SecureLogin'};
  $this-&gt;{isWebUserLogin} = delete $params-&gt;{'WebUserLogin'};
  
  
  $this-&gt;{isSecureLogin} = $CGP::SECURE_LOGIN unless defined $this-&gt;{isSecureLogin};
  $this-&gt;{isWebUserLogin} = $CGP::WEBUSER_LOGIN unless defined $this-&gt;{isWebUserLogin};


  croak 'You must pass login parameter to CGP::CLI::new'
    unless defined $this-&gt;{login};
  croak 'You must pass password parameter to CGP::CLI::new'
    unless defined $this-&gt;{password};

  croak 'SecureLogin and WebUserLogin are mutually exclusive'
    if($this-&gt;{isSecureLogin} &amp;&amp; $this-&gt;{isWebUserLogin});

  #print %$params;
  bless $this;
  $this-&gt;{connParams}=$params;
  
  if(!(defined $params-&gt;{'connectNow'}) || $params-&gt;{'connectNow'}) { 
    unless($this-&gt;connect()) {
      return undef;
    }
  }
  $this;
}

sub DESTROY {
  my $this = shift;
  $this-&gt;Logout() if($this-&gt;{isConnected});
}

sub getErrCode {
  my $this = shift;
  return $this-&gt;{errCode};
}

sub getErrMessage {
  my $this = shift;
  return $this-&gt;{errMsg};
}

sub getErrCommand {
  my $this = shift;
  return $this-&gt;{'currentCGateCommand'};
}

sub isSuccess {
  my $this = shift;
  return ($this-&gt;{errCode} == $CGP::CLI_CODE_OK || $this-&gt;{errCode} == $CGP::CLI_CODE_OK_INLINE);
}

sub setDebug {
  my ($this, $debugFlag) = @_;
  $this-&gt;{'debug'} = $debugFlag;    
}

sub setStringsTranslateMode {
  my ($this, $onFlag) = @_;
  $this-&gt;{'translateStrings'} = $onFlag;    
}

sub Logout {
  my $this = shift;
  $this-&gt;send('QUIT');
  $this-&gt;_parseResponse();
  $this-&gt;{isConnected}=0;
}

sub NewPassword {
  my ($this, $newPassword) = @_;
  croak 'usage CGP::CLI-&gt;NewPassword($newPassword)'
    unless defined $newPassword;
  $this-&gt;send('NEWPASS '.$newPassword);
  $this-&gt;_parseResponse();
}

sub SendCommand {
  my ($this, $command) = @_;
  croak 'usage CGP::CLI-&gt;SendCommand($commandString)'
    unless defined $command;
  $this-&gt;send($command);
  $this-&gt;_parseResponse();
}    

sub GetResponseData {
  my ($this) = @_;
  $this-&gt;parseWords($this-&gt;getWords);
}    


####################################################################
#    Account commands

sub ListDomainObjects {
  my ($this, $domainName,$limit,$filter,$what,$cookie) = @_;
  croak 'usage CGP::CLI-&gt;ListDomainObjects($domainName,$limit[,$filter][,$what][,$cookie])'
      unless defined $domainName &amp;&amp; defined $limit;
  my $line = "ListDomainObjects $domainName";
  $line .= ' FILTER '.$this-&gt;printWords($filter) if defined $filter;
  $line .= " $limit";
  $line .= " $what" if $what;
  $line .= " COOKIE ".$this-&gt;printWords($cookie) if defined $cookie;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}    


sub ListAccounts {
  my ($this, $domainName) = @_;
  my $line = 'ListAccounts';
  $line .= ' '.$domainName if $domainName;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}    

sub ListDomainTelnums {
  my ($this, $domainName,$limit,$filter) = @_;
  croak 'usage CGP::CLI-&gt;ListDomainTelnums($domainName,$limit[,$filter])'
      unless defined $domainName &amp;&amp; defined $limit;
  my $line = "ListDomainTelnums $domainName";
  $line .= ' FILTER '.$this-&gt;printWords($filter) if defined $filter;
  $line .= " $limit";
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}    



sub CreateAccount {
  my ($this) = shift;;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;CreateAccount(accountName =&gt; \'newAccountName\',
                            accountType =&gt; \'accountType\',
                            externalFlag =&gt; \'externalFlag\',
                            settings     =&gt; $settings)'
      unless exists $params{accountName};
  my $line = 'CreateAccount '.$params{accountName};
  $line .= ' ' . $params{accountType} if exists $params{accountType};
  $line .= ' ' . 'external' if exists $params{externalFlag};
  $line .= ' ' . $this-&gt;printWords($params{settings}) if exists $params{settings};

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub RenameAccount {
  my ($this, $oldAccountName, $newAccountName) = @_;
  croak 'usage CGP::CLI-&gt;RenameAccount($oldAccountName, $newAccountName)'
      unless defined $oldAccountName &amp;&amp; defined $newAccountName;
  $this-&gt;send('RenameAccount '.$oldAccountName.' into '.$newAccountName);
  $this-&gt;_parseResponse();
}

sub DeleteAccount {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;DeleteAccount($accountName)'
    unless defined $accountName;
  $this-&gt;send('DeleteAccount '.$accountName);
  $this-&gt;_parseResponse();
}
sub SetAccountType {
  my ($this, $accountName,$type) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountType($accountName,$type)'
    unless (defined $accountName &amp;&amp; defined $type);
  $this-&gt;send('SetAccountType '.$accountName.' '.$type);
  $this-&gt;_parseResponse();
}

sub GetAccountSettings {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountSettings($accountName)'
    unless defined $accountName;
  $this-&gt;send('GetAccountSettings '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetAccount {
  GetAccountSettings(@_);
}

sub GetAccountEffectiveSettings {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountEffectiveSettings($accountName)'
    unless defined $accountName;
  $this-&gt;send('GetAccountEffectiveSettings '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateAccountSettings {
  my ($this, $accountName, $params) = @_;
  croak 'usage CGP::CLI-&gt;UpdateAccountSettings($accountName, \%settings)'
    unless defined $accountName;
  $this-&gt;send('UpdateAccountSettings '.$accountName.' '.$this-&gt;printWords($params));
  $this-&gt;_parseResponse();
}

sub UpdateAccount {
  UpdateAccountSettings(@_);
}

sub SetAccountSettings {
  my ($this, $accountName, $params) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountSettings($accountName, \%settings)'
    unless defined $accountName;
  $this-&gt;send('SetAccountSettings '.$accountName.' '.$this-&gt;printWords($params));
  $this-&gt;_parseResponse();
}

sub SetAccount {
  SetAccountSettings(@_);
}

sub SetAccountPassword {
  my ($this, $accountName, $newPass) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountPassword($accountName, $newPassword)'
    unless defined $accountName &amp;&amp; defined $newPass;
  $this-&gt;send('SetAccountPassword '.$accountName.' TO '.$this-&gt;printWords($newPass));
  $this-&gt;_parseResponse();
}

sub VerifyAccountPassword {
  my ($this, $accountName, $pass) = @_;
  croak 'usage CGP::CLI-&gt;VerifyAccountPassword($accountName, $password)'
    unless defined $accountName &amp;&amp; defined $pass;
  $this-&gt;send('VerifyAccountPassword '.$accountName.' PASSWORD '.$this-&gt;printWords($pass));
  $this-&gt;_parseResponse();
}


sub GetAccountAliases {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountAliases($accountName)'
    unless defined $accountName;
  $this-&gt;send('GetAccountAliases '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountAliases {
  my ($this, $accountName, $aliases) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountAliases($accountName, \@aliases)'
    unless defined $accountName &amp;&amp; defined $aliases;
  $this-&gt;send('SetAccountAliases '.$accountName.' '.$this-&gt;printWords($aliases));
  $this-&gt;_parseResponse();
}

sub GetAccountTelnums {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountTelnums($accountName)'
    unless defined $accountName;
  $this-&gt;send('GetAccountTelnums '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountTelnums {
  my ($this, $accountName, $aliases) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountTelnums($accountName, \@telnums)'
    unless defined $accountName &amp;&amp; defined $aliases;
  $this-&gt;send('SetAccountTelnums '.$accountName.' '.$this-&gt;printWords($aliases));
  $this-&gt;_parseResponse();
}


sub GetAccountRules {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountRules($accountName)'
    unless defined $accountName;
  $this-&gt;send('GetAccountRules '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountRules {
  my ($this, $accountName, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountRules($accountName, \@rules)'
    unless defined $accountName &amp;&amp; defined $rules;
  $this-&gt;send('SetAccountRules '.$accountName.' '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

sub GetAccountMailRules {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountMailRules($accountName)'
    unless defined $accountName;
  $this-&gt;send('GetAccountMailRules '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountMailRules {
  my ($this, $accountName, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountMailRules($accountName, \@rules)'
    unless defined $accountName &amp;&amp; defined $rules;
  $this-&gt;send('SetAccountMailRules '.$accountName.' '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}
sub UpdateAccountMailRule {
  my ($this, $accountName, $rule) = @_;
  croak 'usage CGP::CLI-&gt;UpdateAccountMailRule($accountName, \@rule)'
    unless defined $accountName &amp;&amp; defined $rule;
  $this-&gt;send('UpdateAccountMailRule '.$accountName.' '.$this-&gt;printWords($rule));
  $this-&gt;_parseResponse();
}

sub GetAccountSignalRules {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountSignalRules($accountName)'
    unless defined $accountName;
  $this-&gt;send('GetAccountSignalRules '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountSignalRules {
  my ($this, $accountName, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountSignalRules($accountName, \@rules)'
    unless defined $accountName &amp;&amp; defined $rules;
  $this-&gt;send('SetAccountSignalRules '.$accountName.' '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}
sub UpdateAccountSignalRule {
  my ($this, $accountName, $rule) = @_;
  croak 'usage CGP::CLI-&gt;UpdateAccountSignalRule($accountName, \@rule)'
    unless defined $accountName &amp;&amp; defined $rule;
  $this-&gt;send('UpdateAccountSignalRule '.$accountName.' '.$this-&gt;printWords($rule));
  $this-&gt;_parseResponse();
}

sub GetAccountRPOP {
  my ($this, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountRPOP($accountName)'
      unless defined $accountName;
  $this-&gt;send('GetAccountRPOP '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountRPOP {
  my ($this, $accountName, $newRecords) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountAliases($accountName, \@newRecords)'
    unless defined $accountName &amp;&amp; defined $newRecords;
  $this-&gt;send('SetAccountRPOP '.$accountName.' '.$this-&gt;printWords($newRecords));
  $this-&gt;_parseResponse();
}

sub GetAccountRights {
  my ($this, $account) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountRights($account)'
    unless defined $account;
  $this-&gt;send('GetAccountRights '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountRights {
  my ($this, $account, $list) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountRigthts($acount, \@list)'
    unless defined $account &amp;&amp; defined $list;
  my $line = 'SetAccountRights '.$account.' '.$this-&gt;printWords($list);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub GetAccountInfo {
  my ($this, $account, $key) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountInfo($account,$key)'
    unless defined $account &amp;&amp; defined $key;       
  $this-&gt;send('GetAccountInfo '.$account.' Key '.$this-&gt;printWords($key));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);      
}

sub GetWebUser {
  my ($this, $account) = @_;
  croak 'usage CGP::CLI-&gt;GetWebUser($account)'
    unless defined $account;
  $this-&gt;send('GetWebUser '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}


sub GetAccountPrefs {
  my ($this, $account) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountPrefs($account)'
    unless defined $account;
  $this-&gt;send('GetAccountPrefs '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetWebUser {
  my ($this, $account, $settings) = @_;
  croak 'usage CGP::CLI-&gt;SetWebUser($acount, \%settings)'
    unless defined $account &amp;&amp; defined $settings;
  my $line = 'SetWebUser '.$account.' '.$this-&gt;printWords($settings);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub SetAccountPrefs {
  my ($this, $account, $settings) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountPrefs($acount, \%settings)'
    unless defined $account &amp;&amp; defined $settings;
  my $line = 'SetAccountPrefs '.$account.' '.$this-&gt;printWords($settings);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}
sub UpdateAccountPrefs {
  my ($this, $account, $settings) = @_;
  croak 'usage CGP::CLI-&gt;UpdateAccountPrefs($acount, \%settings)'
    unless defined $account &amp;&amp; defined $settings;
  my $line = 'UpdateAccountPrefs '.$account.' '.$this-&gt;printWords($settings);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}


sub GetEffectiveWebUser {
  my ($this, $account) = @_;
  croak 'usage CGP::CLI-&gt;GetEffectiveWebUser($account)'
    unless defined $account;
  $this-&gt;send('GetEffectiveWebUser '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetAccountEffectivePrefs {
  my ($this, $account) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountEffectivePrefs($account)'
    unless defined $account;
  $this-&gt;send('GetAccountEffectivePrefs '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}


sub KillAccountSessions {
  my ($this, $account) = @_;
  croak 'usage CGP::CLI-&gt;KillAccountSessions($account)'
    unless defined $account;
  $this-&gt;send('KillAccountSessions '.$account);
  $this-&gt;_parseResponse();
}

sub GetAccountACL {
  my ($this, $account,$authAccountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountACL($accountName [,authAccountName])'
    unless defined $account;
    
  my $line = 'GetAccountACL '.$account;
  $line .= ' AUTH '.$authAccountName if($authAccountName);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountACL {
  my ($this, $account, $newACL,$authAccountName) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountACL($acountACL, \%newACL [,$authAccountName])'
    unless defined $account &amp;&amp; defined $newACL;
  my $line = 'SetAccountACL '.$account;
  $line .= ' AUTH '.$authAccountName if($authAccountName);  
  $line.=' '.$this-&gt;printWords($newACL);
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub GetAccountACLRights {
  my ($this, $account,$authAccountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountACLRights($accountName ,authAccountName)'
    unless (defined $account &amp;&amp; defined $authAccountName);
    
  my $line = 'GetAccountACLRights '.$account.' AUTH '.$authAccountName ;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetAccountPresence {
  my ($this, $account) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountPresence($accountName)'
    unless (defined $account);

  my $line = 'GetAccountPresence '.$account;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
#################################################################
#  Group managent commands

sub ListGroups {
  my ($this, $domainName) = @_;
  my $line = 'ListGroups';
  $line .= ' '.$domainName if $domainName;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}    

sub CreateGroup {
  my ($this, $groupName, $params) = @_;
  croak 'usage CGP::CLI-&gt;CreateGroup($groupName[, \%params])'
    unless defined $groupName;
  my $line = 'CreateGroup '.$groupName;
  $line .= ' '.$this-&gt;printWords($params) if $params;
  $this-&gt;send($line);
  $this-&gt;_parseResponse(); 
}

sub RenameGroup {
  my ($this, $oldGroupName, $newGroupName) = @_;
  croak 'usage CGP::CLI-&gt;RenameGroup($oldGroupName, $newGroupName)'
    unless defined $oldGroupName &amp;&amp; defined $newGroupName;
  $this-&gt;send('RenameGroup '.$oldGroupName.' into '.$newGroupName);
  $this-&gt;_parseResponse();    
}

sub DeleteGroup {
  my ($this, $groupName) = @_;
  croak 'usage CGP::CLI-&gt;DeleteGroup($groupName)'
    unless defined $groupName;
  $this-&gt;send('DeleteGroup '.$groupName);
  $this-&gt;_parseResponse();    
}

sub GetGroup {
  my ($this, $groupName) = @_;
  croak 'usage CGP::CLI-&gt;GetGroup($groupName)'
    unless defined $groupName;
  $this-&gt;send('GetGroup '.$groupName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);      
}

sub SetGroup {
  my ($this, $groupName, $params) = @_;
  croak 'usage CGP::CLI-&gt;SetGroup($groupName, \%settings)'
    unless defined $groupName &amp;&amp; defined $params;
  $this-&gt;send('SetGroup '.$groupName.' '.$this-&gt;printWords($params));
  $this-&gt;_parseResponse();
}


#################################################################
#  Forwarder managent commands

sub ListForwarders {
  my ($this, $domainName) = @_;
  my $line = 'ListForwarders';
  $line .= ' ' .$domainName if $domainName;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}    

sub CreateForwarder {
  my ($this, $forwarderName, $address) = @_;
  croak 'usage CGP::CLI-&gt;CreateForwarder($forwarderName, $address)'
    unless defined $forwarderName &amp;&amp; defined $address;
  $this-&gt;send('CreateForwarder '.$forwarderName.' TO '.$this-&gt;printWords($address));
  $this-&gt;_parseResponse(); 
}
sub RenameForwarder {
  my ($this, $forwarderName, $newName) = @_;
  croak 'usage CGP::CLI-&gt;RenameForwarder($forwarderName, $newName)'
    unless defined $forwarderName &amp;&amp; defined $newName;
  $this-&gt;send('RenameForwarder '.$forwarderName.' into '.$newName);
  $this-&gt;_parseResponse(); 
}

sub DeleteForwarder {
  my ($this, $forwarderName) = @_;
  croak 'usage CGP::CLI-&gt;DeleteForwarder($forwarderName)'
    unless defined $forwarderName;
  $this-&gt;send('DeleteForwarder '.$forwarderName);
  $this-&gt;_parseResponse();    
}

sub GetForwarder {
  my ($this, $forwarderName) = @_;
  croak 'usage CGP::CLI-&gt;GetForwarder($forwarderName)'
    unless defined $forwarderName;
  $this-&gt;send('GetForwarder '.$forwarderName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);      
}
sub FindForwarders {
  my ($this, $domain,$forwarderAddress) = @_;
  croak 'usage CGP::CLI-&gt;FindForwarders($domainName,$forwarderAddress)'
    unless (defined $domain &amp;&amp; defined $forwarderAddress);
  $this-&gt;send('FindForwarders '.$domain.' TO '.$this-&gt;printWords($forwarderAddress));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);      
}

#################################################################
#  Domain managent commands

sub ListDomains {
  my $this = shift;
  $this-&gt;send('ListDomains');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub MainDomainName {
  my $this = shift;
  $this-&gt;send('MainDomainName');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetDomainSettings {
  my ($this, $domainName) = @_;

  my $line = 'GetDomainSettings';
  $line .= ' '.$domainName if($domainName);

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetDomain {
  GetDomainSettings(@_);
}

sub GetDomainEffectiveSettings {
  my ($this, $domainName) = @_;
  my $line = 'GetDomainEffectiveSettings';
  $line .= ' '.$domainName if($domainName);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateDomainSettings {
  my ($this) = shift;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;UpdateDomainSettings(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'UpdateDomainSettings';
  $line .= ' '.$params{domain} if exists $params{domain};
  $this-&gt;send($line.' '.$this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

sub UpdateDomain {
  UpdateDomainSettings(@_);
}

sub SetDomainSettings {
  my ($this) = shift;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;SetDomainSettings(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'SetDomainSettings';
  $line .= ' '.$params{domain} if exists $params{domain};
  $this-&gt;send($line.' '.$this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

sub SetDomain {
  SetDomainSettings(@_);
}


sub CreateDomain {
  my ($this, $domainName, $params) = @_;
  croak 'usage CGP::CLI-&gt;CreateDomain($domainName[, \%params])'
    unless defined $domainName;
  my $line = 'CreateDomain '.$domainName;
  $line .= ' '.$this-&gt;printWords($params) if $params;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub RenameDomain {
  my ($this, $oldDomainName, $newDomainName) = @_;
  croak 'usage CGP::CLI-&gt;RenameDomain($oldDomainName, $newDomainName)'
    unless defined $oldDomainName &amp;&amp; defined $newDomainName;
  $this-&gt;send('RenameDomain '.$oldDomainName.' into '.$newDomainName );
  $this-&gt;_parseResponse();
}

sub DeleteDomain {
  my ($this, $domainName, $force) = @_;
  croak 'usage CGP::CLI-&gt;DeleteDomain($domainName[, $force])'
    unless defined $domainName;
  my $line = 'DeleteDomain '.$domainName;
  $line .= ' force' if $force;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub SuspendDomain {
  my ($this, $domainName) = @_;
  croak 'usage CGP::CLI-&gt;SuspendDomain($domainName)'
    unless defined $domainName;
  $this-&gt;send('SuspendDomain '.$domainName);
  $this-&gt;_parseResponse();
}
sub ResumeDomain {
  my ($this, $domainName) = @_;
  croak 'usage CGP::CLI-&gt;ResumeDomain($domainName)'
    unless defined $domainName;
  $this-&gt;send('ResumeDomain '.$domainName);
  $this-&gt;_parseResponse();
}

sub CreateSharedDomain {
  my ($this, $domainName, $params) = @_;
  croak 'usage CGP::CLI-&gt;CreateSharedDomain($domainName[, \%params])'
    unless defined $domainName;
  my $line = 'CreateSharedDomain '.$domainName;
  $line .= ' '.$this-&gt;printWords($params) if $params;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub CreateDirectoryDomain {
  my ($this, $domainName, $params) = @_;
  croak 'usage CGP::CLI-&gt;CreateDirectoryDomain($domainName[, \%params])'
    unless defined $domainName;
  my $line = 'CreateDirectoryDomain '.$domainName;
  $line .= ' '.$this-&gt;printWords($params) if $params;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub ReloadDirectoryDomains {
  my ($this) = @_;
  $this-&gt;send('ReloadDirectoryDomains');
  $this-&gt;_parseResponse();
}

sub GetDomainRules {
  my ($this, $domainName) = @_;
  croak 'usage CGP::CLI-&gt;GetDomainRules($domainName)'
    unless defined $domainName;
  $this-&gt;send('GetDomainRules '.$domainName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetDomainRules {
  my ($this, $domainName, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetDomainRules($domainName, \@rules)'
    unless defined $domainName &amp;&amp; defined $rules;
  $this-&gt;send('SetDomainRules '.$domainName.' '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

sub GetDomainMailRules {
  my ($this, $domainName) = @_;
  croak 'usage CGP::CLI-&gt;GetDomainMailRules($domainName)'
    unless defined $domainName;
  $this-&gt;send('GetDomainMailRules '.$domainName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetDomainMailRules {
  my ($this, $domainName, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetDomainMailRules($domainName, \@rules)'
    unless defined $domainName &amp;&amp; defined $rules;
  $this-&gt;send('SetDomainMailRules '.$domainName.' '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

#sub UpdateDomainMailRule {
#  my ($this, $domainName, $rule) = @_;
#  croak 'usage CGP::CLI-&gt;UpdateDomainMailRules($domainName, \@rule)'
#    unless defined $domainName &amp;&amp; defined $rule;
#  $this-&gt;send('UpdateDomainMailRule '.$domainName.' '.$this-&gt;printWords($rule));
#  $this-&gt;_parseResponse();
#}
sub GetDomainSignalRules {
  my ($this, $domainName) = @_;
  croak 'usage CGP::CLI-&gt;GetDomainSignalRules($domainName)'
    unless defined $domainName;
  $this-&gt;send('GetDomainSignalRules '.$domainName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetDomainSignalRules {
  my ($this, $domainName, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetDomainSignalRules($domainName, \@rules)'
    unless defined $domainName &amp;&amp; defined $rules;
  $this-&gt;send('SetDomainSignalRules '.$domainName.' '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

#sub UpdateDomainSignalRule {
#  my ($this, $domainName, $rule) = @_;
#  croak 'usage CGP::CLI-&gt;UpdateDomainSignalRules($domainName, \@rule)'
#    unless defined $domainName &amp;&amp; defined $rule;
#  $this-&gt;send('UpdateDomainSignalRule '.$domainName.' '.$this-&gt;printWords($rule));
#  $this-&gt;_parseResponse();
#}


sub GetDomainAliases {
  my ($this, $domain) = @_;

  my $line = 'GetDomainAliases';
  $line .= ' '.$domain if $domain;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}


sub SetDomainAliases {
  my ($this, $domain, $aliases) = @_;
  croak 'usage CGP::CLI-&gt;SetDomainAliases($domainName, \@aliases)'
    unless defined $domain &amp;&amp; defined $aliases;
  $this-&gt;send('SetDomainAliases '.$domain.' '.$this-&gt;printWords($aliases));
  $this-&gt;_parseResponse();
}

sub ListAdminDomains {
  my ($this, $domain) = @_;
  my $line = 'ListAdminDomains';
  $line .= ' '.$domain if $domain;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub InsertDirectoryRecords {
  my ($this, $domain) = @_;
  my $line = 'InsertDirectoryRecords';
  $line .= ' '.$domain if $domain;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}
sub DeleteDirectoryRecords {
  my ($this, $domain) = @_;
  my $line = 'DeleteDirectoryRecords';
  $line .= ' '.$domain if $domain;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub GetServerTrustedCerts {
  my $this = shift;
  $this-&gt;send('GetServerTrustedCerts');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetServerTrustedCerts {
  my ( $this, $certs ) = @_;
  croak 'usage CGP::CLI-&gt;SetServerTrustedCerts(\@certs)'
    unless defined $certs;
  $this-&gt;send('SetServerTrustedCerts '.$this-&gt;printWords($certs));
  $this-&gt;_parseResponse(); 
}

sub GetClusterTrustedCerts {
  my $this = shift;
  $this-&gt;send('GetClusterTrustedCerts');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterTrustedCerts {
  my ( $this, $certs ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterTrustedCerts(\@certs)'
    unless defined $certs;
  $this-&gt;send('SetClusterTrustedCerts '.$this-&gt;printWords($certs));
  $this-&gt;_parseResponse(); 
}


sub GetDirectoryIntegration {
  my $this = shift;
  $this-&gt;send('GetDirectoryIntegration');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetDirectoryIntegration {
  my ( $this, $dict ) = @_;
  croak 'usage CGP::CLI-&gt;SetDirectoryIntegration(\%settings)'
    unless defined $dict;

  $this-&gt;send('SetDirectoryIntegration '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub GetClusterDirectoryIntegration {
  my $this = shift;
  $this-&gt;send('GetClusterDirectoryIntegration');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterDirectoryIntegration {
  my ( $this, $dict ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterDirectoryIntegration(\%settings)'
    unless defined $dict;

  $this-&gt;send('SetClusterDirectoryIntegration '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse(); 
}


sub GetDomainDefaults {
  my $this = shift;
  $this-&gt;send('GetDomainDefaults');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateDomainDefaults {
  my ( $this, $dict ) = @_;
  croak 'usage CGP::CLI-&gt;UpdateDomainDefaults(\%settings)'
    unless defined $dict;

  $this-&gt;send('UpdateDomainDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse(); 
}

sub SetDomainDefaults {
  my ( $this, $dict ) = @_;
  croak 'usage CGP::CLI-&gt;SetDomainDefaults(\%settings)'
    unless defined $dict;
  $this-&gt;send('SetDomainDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub GetClusterDomainDefaults {
  my $this = shift;
  $this-&gt;send('GetClusterDomainDefaults');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateClusterDomainDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('UpdateClusterDomainDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub SetClusterDomainDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetClusterDomainDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}


sub GetAllAccountsDefaults {
  my $this = shift;
  $this-&gt;send('GetAllAccountsDefaults');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateAllAccountsDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('UpdateAllAccountsDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub SetAllAccountsDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetAllAccountsDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub GetServerAccountDefaults {
  my $this = shift;
  $this-&gt;send('GetServerAccountDefaults');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateServerAccountDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('UpdateServerAccountDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub SetServerAccountDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetServerAccountDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub GetClusterAccountDefaults {
  my $this = shift;
  $this-&gt;send('GetClusterAccountDefaults');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateClusterAccountDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('UpdateClusterAccountDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub SetClusterAccountDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetClusterAccountDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub GetServerWebUserDefaults {
  my $this = shift;
  $this-&gt;send('GetServerWebUserDefaults');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetServerAccountPrefs {
  my $this = shift;
  $this-&gt;send('GetServerAccountPrefs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetServerWebUserDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetServerWebUserDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}
sub SetServerAccountPrefs {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetServerAccountPrefs '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub GetClusterWebUserDefaults {
  my $this = shift;
  $this-&gt;send('GetClusterWebUserDefaults');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetClusterAccountPrefs {
  my $this = shift;
  $this-&gt;send('GetClusterAccountPrefs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub SetClusterWebUserDefaults {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetClusterWebUserDefaults '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}
sub SetClusterAccountPrefs {
  my ( $this, $dict ) = @_;
  $this-&gt;send('SetClusterAccountPrefs '.$this-&gt;printWords($dict));
  $this-&gt;_parseResponse();
}

sub GetDomainLocation {
  my ( $this, $account ) = @_;
  $this-&gt;send('GetDomainLocation '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetAccountLocation {
  my ( $this, $account ) = @_;
  $this-&gt;send('GetAccountLocation '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ListServerTelnums {
  my ($this, $limit,$filter) = @_;
  croak 'usage CGP::CLI-&gt;ListServerTelnums($limit[,$filter])'
      unless defined $limit;
  my $line = "ListServerTelnums";
  $line .= ' FILTER '.$this-&gt;printWords($filter) if defined $filter;
  $line .= " $limit";
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
 
sub ListClusterTelnums {
  my ($this, $limit,$filter) = @_;
  croak 'usage CGP::CLI-&gt;ListClusterTelnums($limit[,$filter])'
      unless defined $limit;
  my $line = "ListClusterTelnums";
  $line .= ' FILTER '.$this-&gt;printWords($filter) if defined $filter;
  $line .= " $limit";
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}


sub GetAccountDefaults {
  my ($this, $domain) = @_;

  my $line = 'GetAccountDefaults';
  $line .= ' '.$domain if($domain);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateAccountDefaults {
  my ($this) = shift;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;UpdateAccountDefaults(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'UpdateAccountDefaults';
  $line .= ' '.$params{domain} if exists $params{domain};

  $this-&gt;send($line . ' ' . $this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

sub SetAccountDefaults {
  my ($this) = shift;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;SetAccountDefaults(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'SetAccountDefaults';
  $line .= ' '.$params{domain} if exists $params{domain};

  $this-&gt;send($line . ' ' . $this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

sub GetWebUserDefaults {
  my ($this, $domain) = @_;

  my $line = 'GetWebUserDefaults';
  $line .= ' '.$domain if($domain);
        
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetAccountDefaultPrefs {
  my ($this, $domain) = @_;

  my $line = 'GetAccountDefaultPrefs';
  $line .= ' '.$domain if($domain);
        
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetWebUserDefaults {
  my ($this) = shift;;
  my %params = (@_);
  croak 'usage CGP::CLI-&gt;SetWebUserDefaults(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'SetWebUserDefaults';
  $line .= ' ' .$params{domain} if exists $params{domain};

  $this-&gt;send($line . ' ' . $this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}
sub SetAccountDefaultPrefs {
  my ($this) = shift;;
  my %params = (@_);
  croak 'usage CGP::CLI-&gt;SetAccountDefaultPrefs(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'SetAccountDefaultPrefs';
  $line .= ' ' .$params{domain} if exists $params{domain};

  $this-&gt;send($line . ' ' . $this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

sub UpdateWebUserDefaults {
  my ($this) = shift;;
  my %params = (@_);
  croak 'usage CGP::CLI-&gt;UpdateWebUserDefaults(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'UpdateWebUserDefaults';
  $line .= ' ' .$params{domain} if exists $params{domain};

  $this-&gt;send($line . ' ' . $this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}
sub UpdateAccountDefaultPrefs {
  my ($this) = shift;;
  my %params = (@_);
  croak 'usage CGP::CLI-&gt;UpdateAccountDefaultPrefs(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'UpdateAccountDefaultPrefs';
  $line .= ' ' .$params{domain} if exists $params{domain};

  $this-&gt;send($line . ' ' . $this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

sub GetAccountTemplate {
  my ($this, $domain) = @_;

  my $line = 'GetAccountTemplate';
  $line .= ' '.$domain if($domain);

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateAccountTemplate {
  my ($this) = shift;;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;UpdateAccountTemplate(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'UpdateAccountTemplate';
  $line .= ' '.$params{domain} if exists $params{domain};

  $this-&gt;send($line.' '.$this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

sub SetAccountTemplate {
  my ($this) = shift;;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;SetAccountTemplate(domain =&gt; \'domainName\',settings =&gt; {settings})'
    unless exists $params{settings};

  my $line = 'SetAccountTemplate';
  $line .= ' '.$params{domain} if exists $params{domain};

  $this-&gt;send($line.' '.$this-&gt;printWords($params{settings}));
  $this-&gt;_parseResponse();
}

#################################################################
#  Mailbox managent commands

sub ListMailboxes {
  my ($this) = shift;;
  my %params = (@_);

  croak 'usage CGP::CLI-&gt;ListMailboxes(accountName =&gt; \'account\',filter =&gt; \'*\',authAccountName =&gt; \'extAccount\')'
      unless exists $params{accountName};

  my $line = 'ListMailboxes '.$params{accountName};
  $line .= ' FILTER '.$this-&gt;printWords($params{filter}) if exists $params{filter};
  $line .= ' AUTH '.$params{authAccountName} if exists $params{authAccountName};

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub CreateMailbox {
  my ($this,$accountName,$mailboxName,$authAccountName,$class) = @_;
 
 
  croak 'usage CGP::CLI-&gt;CreateMailbox(accountName,mailboxName,[authAccountName],[class])'
      unless (defined $accountName &amp;&amp; defined $mailboxName);
      
  my $line = 'CREATEMAILBOX '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName if($authAccountName);
  $line .= ' CLASS '.$class if($class);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub RenameMailbox {   
  my ($this,$accountName,$oldMailboxName,$newMailboxName,$authAccountName) = @_;
  
  croak 'usage CGP::CLI-&gt;RenameMailbox(accountName,oldMailboxName,newMailboxName[,authAccountName])'
      unless (defined $accountName &amp;&amp; defined $oldMailboxName &amp;&amp; defined $newMailboxName);
      
  my $line = 'RENAMEMAILBOX '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($oldMailboxName);
  $line .= ' INTO '.$this-&gt;printWords($newMailboxName);
  $line .= ' AUTH '.$authAccountName if defined $authAccountName;

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub RenameMailboxes {   
  my ($this,$accountName,$oldMailboxName,$newMailboxName,$authAccountName) = @_;
  
  croak 'usage CGP::CLI-&gt;RenameMailboxes(accountName,oldMailboxName,newMailboxName[,authAccountName])'
      unless (defined $accountName &amp;&amp; defined $oldMailboxName &amp;&amp; defined $newMailboxName);
      
  my $line = 'RENAMEMAILBOX '.$accountName;
  $line .= ' MAILBOXES '.$this-&gt;printWords($oldMailboxName);
  $line .= ' INTO '.$this-&gt;printWords($newMailboxName);
  $line .= ' AUTH '.$authAccountName if defined $authAccountName;

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub DeleteMailbox {
  my ($this,$accountName,$mailboxName,$authAccountName) = @_;
  
  croak 'usage CGP::CLI-&gt;DeleteMailbox(accountName,mailboxName[,authAccountName])'
      unless (defined $accountName &amp;&amp; defined $mailboxName);
      
  my $line = 'DELETEMAILBOX '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName if defined $authAccountName;

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub DeleteMailboxes {
  my ($this,$accountName,$mailboxName,$authAccountName) = @_;
  
  croak 'usage CGP::CLI-&gt;DeleteMailboxes(accountName,mailboxName[,authAccountName])'
      unless (defined $accountName &amp;&amp; defined $mailboxName);
      
  my $line = 'DELETEMAILBOX '.$accountName;
  $line .= ' MAILBOXES '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName if defined $authAccountName;

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub GetMailboxInfo {
  my ($this,$accountName,$mailboxName,$authAccountName) = @_;

  croak 'usage CGP::CLI-&gt;GetMailboxInfo(accountName,mailboxName[,authAccountName])'
       unless (defined $accountName &amp;&amp; defined $mailboxName);
     
  my $line = 'GETMAILBOXINFO '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName if defined $authAccountName;

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetMailboxACL {   
  my ($this,$accountName,$mailboxName,$authAccountName) = @_;

  croak 'usage CGP::CLI-&gt;GetMailboxACL(accountName,mailboxName[,authAccountName])'
       unless (defined $accountName &amp;&amp; defined $mailboxName);
     
  my $line = 'GETMAILBOXACL '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName if defined $authAccountName;

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetMailboxACL {
  my ($this,$accountName,$mailboxName,$newACL,$authAccountName) = @_;

  croak 'usage CGP::CLI-&gt;SetMailboxACL(accountName,mailboxName,\@newACL[,authAccountName])'
       unless (defined $accountName &amp;&amp; defined $mailboxName &amp;&amp; defined $newACL);
     
  my $line = 'SETMAILBOXACL '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName if defined $authAccountName;

  $this-&gt;send($line.' '.$this-&gt;printWords($newACL));
  $this-&gt;_parseResponse();
}


sub GetMailboxRights {
  my ($this,$accountName,$mailboxName,$authAccountName) = @_;

  croak 'usage CGP::CLI-&gt;GetMailboxRights(accountName,mailboxName,authAccountName)'
       unless (defined $accountName &amp;&amp; defined $mailboxName &amp;&amp; defined $authAccountName);
     
  my $line = 'GETMAILBOXRIGHTS '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName;

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetMailboxClass {
  my ($this,$accountName,$mailboxName,$class,$authAccountName) = @_;

  croak 'usage CGP::CLI-&gt;SetMailboxClass(accountName,mailboxName,class [,authAccountName])'
       unless (defined $accountName &amp;&amp; defined $mailboxName &amp;&amp; defined $class);
     
  my $line = 'SetMailboxClass '.$accountName;
  $line .= ' MAILBOX '.$this-&gt;printWords($mailboxName);
  $line .= ' AUTH '.$authAccountName if(defined $authAccountName);
  $line .= ' CLASS '.$class;

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
}


sub GetAccountSubscription {
  my ($this,$accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountSubscription(accountName)'
       unless defined $accountName;
     
  $this-&gt;send('GetAccountSubscription '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountSubscription {
  my ($this,$accountName,$newSubscription) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountSubscription(accountName,\%newSubscription)'
       unless (defined $accountName &amp;&amp; defined $newSubscription);
     
  $this-&gt;send('SetAccountSubscription '.$accountName.' '.$this-&gt;printWords($newSubscription));
  $this-&gt;_parseResponse();
}

sub GetMailboxAliases {
  my ($this,$accountName) = @_;
  croak 'usage CGP::CLI-&gt;GetMailboxAliases(accountName)'
       unless defined $accountName;
     
  $this-&gt;send('GetMailboxAliases '.$accountName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetMailboxAliases {
  my ($this,$accountName,$newAliases) = @_;
  croak 'usage CGP::CLI-&gt;SetMailboxAliases(accountName,\%newAliases)'
       unless (defined $accountName &amp;&amp; defined $newAliases);
     
  $this-&gt;send('SetMailboxAliases '.$accountName.' '.$this-&gt;printWords($newAliases));
  $this-&gt;_parseResponse();
}


#################################################################
#   Alerts Administration

sub GetDomainAlerts {
  my ($this, $domain) = @_;

  my $line = 'GetDomainAlerts';
  $line .= ' '.$domain if $domain;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetDomainAlerts {
  my ($this, $domain, $alerts) = @_;
  croak 'usage CGP::CLI-&gt;SetDomainAlerts($domainName, \@alerts)'
    unless defined $domain &amp;&amp; defined $alerts;
  $this-&gt;send('SetDomainAlerts '.$domain.' '.$this-&gt;printWords($alerts));
  $this-&gt;_parseResponse();
}

sub PostDomainAlert {
  my ($this, $domain, $alert) = @_;
  croak 'usage CGP::CLI-&gt;PostDomainAlert($domainName, $alertString)'
    unless defined $domain &amp;&amp; defined $alert;
  $this-&gt;send('PostDomainAlert '.$domain.' ALERT '.$this-&gt;printWords($alert));
  $this-&gt;_parseResponse();
}

sub RemoveDomainAlert {
  my ($this, $domain, $timeStamp) = @_;
  croak 'usage CGP::CLI-&gt;RemoveDomainAlert($domainName, $timeStamp)'
    unless defined $domain &amp;&amp; defined $timeStamp;
  $this-&gt;send('RemoveDomainAlert '.$domain.' ALERT '.$timeStamp);
  $this-&gt;_parseResponse();
}

sub GetAccountAlerts {
  my ($this, $account) = @_;
  $this-&gt;send('GetAccountAlerts '.$account);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetAccountAlerts {
  my ($this, $account, $alerts) = @_;
  croak 'usage CGP::CLI-&gt;SetAccountAlerts($account, \@alerts)'
    unless defined $account &amp;&amp; defined $alerts;
  $this-&gt;send('SetAccountAlerts '.$account.' '.$this-&gt;printWords($alerts));
  $this-&gt;_parseResponse();
}

sub PostAccountAlert {
  my ($this, $account, $alert) = @_;
  croak 'usage CGP::CLI-&gt;PostAccountAlert($account, $alertString)'
    unless defined $account &amp;&amp; defined $alert;
  $this-&gt;send('PostAccountAlert '.$account.' ALERT '.$this-&gt;printWords($alert));
  $this-&gt;_parseResponse();
}

sub RemoveAccountAlert {
  my ($this, $account, $timeStamp) = @_;
  croak 'usage CGP::CLI-&gt;RemoveAccountAlert($account, $timeStamp)'
    unless defined $account &amp;&amp; defined $timeStamp;
  $this-&gt;send('RemoveAccountAlert '.$account.' ALERT '.$timeStamp);
  $this-&gt;_parseResponse();
}


sub GetServerAlerts {
  my ($this) = @_;
  $this-&gt;send('GetServerAlerts');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetServerAlerts {
  my ($this, $alerts) = @_;
  croak 'usage CGP::CLI-&gt;SetServerAlerts(\@alerts)'
    unless defined $alerts;
  $this-&gt;send('SetServerAlerts '.$this-&gt;printWords($alerts));
  $this-&gt;_parseResponse();
}

sub PostServerAlert {
  my ($this,  $alert) = @_;
  croak 'usage CGP::CLI-&gt;PostServerAlert($alertString)'
    unless defined $alert;
  $this-&gt;send('PostServerAlert '.$this-&gt;printWords($alert));
  $this-&gt;_parseResponse();
}

sub RemoveServerAlert {
  my ($this, $timeStamp) = @_;
  croak 'usage CGP::CLI-&gt;RemoveServerAlert($timeStamp)'
    unless defined $timeStamp;
  $this-&gt;send('RemoveServerAlert '.$timeStamp);
  $this-&gt;_parseResponse();
}

sub GetClusterAlerts {
  my ($this) = @_;
  $this-&gt;send('GetClusterAlerts');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterAlerts {
  my ($this, $alerts) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterAlerts(\@alerts)'
    unless defined $alerts;
  $this-&gt;send('SetClusterAlerts '.$this-&gt;printWords($alerts));
  $this-&gt;_parseResponse();
}

sub PostClusterAlert {
  my ($this,  $alert) = @_;
  croak 'usage CGP::CLI-&gt;PostClusterAlert($alertString)'
    unless defined $alert;
  $this-&gt;send('PostClusterAlert '.$this-&gt;printWords($alert));
  $this-&gt;_parseResponse();
}

sub RemoveClusterAlert {
  my ($this, $timeStamp) = @_;
  croak 'usage CGP::CLI-&gt;RemoveClusterAlert($timeStamp)'
    unless defined $timeStamp;
  $this-&gt;send('RemoveClusterAlert '.$timeStamp);
  $this-&gt;_parseResponse();
}

#################################################################
#   Personal Web Site Administration

sub GetWebFile {
  my ($this,$accountName,$fileName,$position,$sliceSize) = @_;

  croak 'usage CGP::CLI-&gt;GetWebFile(accountName,fileName[,position,sliceSize])'
       unless (defined $accountName &amp;&amp; defined $fileName);
  my $line='GetWebFile '.$accountName.' FILE '.$this-&gt;printWords($fileName);
  $line .= ' OFFSET '. $position if(defined $position &amp;&amp; $position!=0);
  $line .= ' SIZE '. $sliceSize if(defined $sliceSize);
      
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse;
  $this-&gt;parseWords($this-&gt;getWords);
}

sub PutWebFile {
  my ($this,$accountName,$fileName,$data,$position) = @_;

  croak 'usage CGP::CLI-&gt;PutWebFile(accountName,fileName,data [,position])'
       unless (defined $accountName &amp;&amp; defined $fileName &amp;&amp; defined $data);
  my $line='PutWebFile '.$accountName.' FILE '.$this-&gt;printWords($fileName);
  $line .= ' OFFSET '. $position if(defined $position &amp;&amp; $position!=0);
  
  $line .= ' DATA ['.$data.']';
       
  $this-&gt;send($line);
  $this-&gt;_parseResponse;
}

sub RenameWebFile {
  my ($this,$accountName,$oldFileName,$newFileName) = @_;

  croak 'usage CGP::CLI-&gt;RenameWebFile(accountName,oldFileName,newFileName)'
       unless (defined $accountName &amp;&amp; defined $oldFileName &amp;&amp; defined $newFileName);
  $this-&gt;send('RenameWebFile '.$accountName.' FILE '.$this-&gt;printWords($oldFileName).' INTO '.$this-&gt;printWords($newFileName));
  $this-&gt;_parseResponse;
}

sub DeleteWebFile {
  my ($this,$accountName,$fileName) = @_;

  croak 'usage CGP::CLI-&gt;DeleteWebFile(accountName,fileName)'
       unless (defined $accountName &amp;&amp; defined $fileName);
  $this-&gt;send('DeleteWebFile '.$accountName.' FILE '.$this-&gt;printWords($fileName));
  $this-&gt;_parseResponse;
}

sub ListWebFiles {
  my ($this,$accountName,$filePath) = @_;

  croak 'usage CGP::CLI-&gt;ListWebFiles(accountName [,filePath])'
       unless defined $accountName;
  my $line = 'ListWebFiles '.$accountName;
  $line .= ' PATH '.$this-&gt;printWords($filePath) if $filePath;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse;
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetWebFilesInfo {
  my ($this,$accountName) = @_;

  croak 'usage CGP::CLI-&gt;InfoWebFiles(accountName)'
       unless defined $accountName;
  $this-&gt;send('GetWebFilesInfo '.$accountName);
  return undef unless $this-&gt;_parseResponse;
  $this-&gt;parseWords($this-&gt;getWords);
}

#################################################################
#   List management commands

sub ListLists {
  my ( $this, $domain ) = @_;
  my $line = 'LISTLISTS';
  $line .= ' '.$domain if $domain;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse;
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetDomainLists {
  my ( $this, $domain ) = @_;
  my $line = 'GetDomainLists';
  $line .= ' '.$domain if $domain;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse;
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetAccountLists {
  my ( $this, $accountName ) = @_;
  croak 'usage CGP::CLI-&gt;GetAccoountLists($accountName)'
      unless defined $accountName;

  $this-&gt;send('GetAccountLists '.$accountName);
  return undef unless $this-&gt;_parseResponse;
  $this-&gt;parseWords($this-&gt;getWords);
}

sub CreateList {
  my ($this, $listName, $accountName) = @_;
  croak 'usage CGP::CLI-&gt;CreateList($listName, $accountName)'
      unless defined $listName &amp;&amp; defined $accountName;
  $this-&gt;send('CREATELIST '.$listName.' for '.$accountName);
  $this-&gt;_parseResponse();
}

sub RenameList {
  my ($this, $oldListName, $newListName) = @_;
  croak 'usage CGP::CLI-&gt;RenameList($oldListName, $newListName)'
      unless defined $oldListName &amp;&amp; defined $newListName;
  $this-&gt;send('RENAMELIST '.$oldListName.' into '.$newListName);
  $this-&gt;_parseResponse();
}

sub DeleteList {
  my ( $this, $listName ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteList($listName)'
      unless defined $listName;

  $this-&gt;send('DELETELIST '.$listName);
  $this-&gt;_parseResponse();
}

sub GetList {
  my ( $this, $listName ) = @_;
  croak 'usage CGP::CLI-&gt;GetList($listName)'
      unless defined $listName;
      
  $this-&gt;send('GETLIST '.$listName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateList {
  my ( $this, $listName, $dict ) = @_;
  croak 'usage CGP::CLI-&gt;UpdateList($listName,\%params)'
      unless defined $listName &amp;&amp; defined $dict;
  
  $this-&gt;send('UPDATELIST '.$listName.' '.$this-&gt;printWords($dict) );
  $this-&gt;_parseResponse();
}

sub List {
  my ( $this, $listName, $command, $subscriber, @options ) = @_;
  croak 'usage CGP::CLI-&gt;List($listName, $command, $subscriber, @options)'
      unless defined $listName &amp;&amp; defined $command &amp;&amp; defined $subscriber;

  $this-&gt;send('LIST '.$listName.' '.$command.' '.join(' ',@options).' '.$subscriber);
  $this-&gt;_parseResponse();
}

sub ListSubscribers {
  my ( $this, $listName,$filter,$limit ) = @_;    
  croak 'usage CGP::CLI-&gt;ListSubscribers($listName [,$filter[,$limit]])'
      unless defined $listName;

  my $line = 'ListSubscribers '.$listName;
  $line .= ' FILTER '. ($filter eq '' ? '""' : $this-&gt;printWords($filter)) if($filter || $limit);
  $line .= " $limit" if($limit);
  
  $this-&gt;send($line );
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetSubscriberInfo {
  my ( $this, $listName,$address ) = @_;    
  croak 'usage CGP::CLI-&gt;GetSubscriberInfo($listName ,$subscriberAddress)'
      unless defined $listName &amp;&amp; defined $address;
  $this-&gt;send('GetSubscriberInfo '.$listName.' NAME '.$address);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetPostingMode {
  my ($this, $listName, $address, $mode) = @_;
  croak 'usage CGP::CLI-&gt;SetPostingMode($listName,$subscriberAddress,$mode)'
      unless defined $listName &amp;&amp; defined $address &amp;&amp; defined $mode;
  $this-&gt;send('SetPostingMode '.$listName.' FOR '.$address.' '.$mode);
  $this-&gt;_parseResponse();
}

sub ProcessBounce {
  my ($this, $listName, $address, $fatal) = @_;
  croak 'usage CGP::CLI-&gt;ProcessBounce($listName,$subscriberAddress,"fatal")'
      unless defined $listName &amp;&amp; defined $address;
  my $line = 'ProcessBounce '.$listName;
  $line .= ' FATAL' if($fatal);
  $this-&gt;send($line. ' FOR '.$address);
  $this-&gt;_parseResponse();
}

#############################################
#   Web Skins Administration 
 
sub ListDomainSkins {
  my ($this, $domainName) = @_;
  my $line = 'ListDomainSkins';
  $line .= ' '.$domainName if($domainName);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub CreateDomainSkin {
  my ( $this, $domain, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;CreateDomainSkin($domainName,$skinName)'
      unless defined $domain &amp;&amp; defined $skin;

  $this-&gt;send('CreateDomainSkin '.$domain.' SKIN '.$this-&gt;printWords($skin));
  $this-&gt;_parseResponse();
}

sub RenameDomainSkin {
  my ( $this, $domain, $skin, $newName ) = @_;
  croak 'usage CGP::CLI-&gt;RenameDomainSkin($domainName,$oldSkinName,$newSkinName)'
      unless defined $domain &amp;&amp; defined $skin &amp;&amp; defined $newName;

  $this-&gt;send('RenameDomainSkin '.$domain.' SKIN '.$this-&gt;printWords($skin).' INTO '.$this-&gt;printWords($newName));
  $this-&gt;_parseResponse();
}

sub DeleteDomainSkin {
  my ( $this, $domain, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteDomainSkin($domainName,$skinName)'
      unless defined $domain &amp;&amp; defined $skin;

  $this-&gt;send('DeleteDomainSkin '.$domain.' SKIN '.$this-&gt;printWords($skin));
  $this-&gt;_parseResponse();
}

sub ListDomainSkinFiles {
  my ( $this, $domain, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;ListDomainSkinFiles($domainName,$skinName)'
      unless defined $domain &amp;&amp; defined $skin;
  
  $this-&gt;send('ListDomainSkinFiles '.$domain.' SKIN '.$this-&gt;printWords($skin));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ReadDomainSkinFile {
  my ( $this, $domain, $skin, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;ReadDomainSkinFile($domainName,$skinName,$fileName)'
      unless defined $domain &amp;&amp; defined $skin &amp;&amp; defined $fileName;

  $this-&gt;send('ReadDomainSkinFile '.$domain.' SKIN '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub StoreDomainSkinFile {
  my ( $this, $domain, $skin, $fileName,$base64data ) = @_;
  croak 'usage CGP::CLI-&gt;StoreDomainSkinFile($domainName,$skinName,$fileName,$base64data)'
      unless defined $domain &amp;&amp; defined $skin &amp;&amp; defined $fileName &amp;&amp; defined $base64data;
  $this-&gt;send('StoreDomainSkinFile '.$domain.' SKIN '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName).' DATA ['.$base64data.']');
  $this-&gt;_parseResponse();
}

sub DeleteDomainSkinFile {
  my ( $this, $domain, $skin, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteDomainSkinFile($domainName,$skinName,$fileName)'
      unless defined $domain &amp;&amp; defined $skin &amp;&amp; defined $fileName;

  $this-&gt;send('StoreDomainSkinFile '.$domain.' SKIN '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName).' DELETE');
  $this-&gt;_parseResponse();
}

#--
sub ListServerSkins {
  my ($this) = @_;
  $this-&gt;send('ListServerSkins');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub CreateServerSkin {
  my ( $this, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;CreateServerSkin($skinName)'
      unless defined $skin;

  $this-&gt;send('CreateServerSkin '.$this-&gt;printWords($skin));
  $this-&gt;_parseResponse();
}

sub RenameServerSkin {
  my ( $this, $skin, $newName ) = @_;
  croak 'usage CGP::CLI-&gt;RenameServerSkin($oldSkinName,$newSkinName)'
      unless defined $skin &amp;&amp; defined $newName;

  $this-&gt;send('RenameServerSkin '.$this-&gt;printWords($skin).' INTO '.$this-&gt;printWords($newName));
  $this-&gt;_parseResponse();
}

sub DeleteServerSkin {
  my ( $this, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteServerSkin($skinName)'
      unless defined $skin;

  $this-&gt;send('DeleteServerSkin '.$this-&gt;printWords($skin));
  $this-&gt;_parseResponse();
}

sub ListServerSkinFiles {
  my ( $this, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;ListServerSkinFiles($skinName)'
      unless defined $skin;

  $this-&gt;send('ListServerSkinFiles '.$this-&gt;printWords($skin));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ReadServerSkinFile {
  my ( $this, $skin, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;ReadServerSkinFile($skinName,$fileName)'
      unless defined $skin &amp;&amp; defined $fileName;

  $this-&gt;send('ReadServerSkinFile '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub StoreServerSkinFile {
  my ( $this, $skin, $fileName,$data ) = @_;
  croak 'usage CGP::CLI-&gt;StoreServerSkinFile($skinName,$fileName,$base64data)'
      unless defined $skin &amp;&amp; defined $fileName &amp;&amp; defined $data;

  $this-&gt;send('StoreServerSkinFile '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName).' DATA ['.$data.']');
  $this-&gt;_parseResponse();
}

sub DeleteServerSkinFile {
  my ( $this, $skin, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteServerSkinFile($skinName,$fileName)'
      unless defined $skin &amp;&amp; defined $fileName;

  $this-&gt;send('StoreServerSkinFile '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName).' DELETE');
  $this-&gt;_parseResponse();
}

#--
sub ListClusterSkins {
  my ($this) = @_;
  $this-&gt;send('ListClusterSkins');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub CreateClusterSkin {
  my ( $this, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;CreateClusterSkin($skinName)'
      unless defined $skin;

  $this-&gt;send('CreateClusterSkin '.$this-&gt;printWords($skin));
  $this-&gt;_parseResponse();
}

sub RenameClusterSkin {
  my ( $this, $skin, $newName ) = @_;
  croak 'usage CGP::CLI-&gt;RenameClusterSkin($oldSkinName,$newSkinName)'
      unless defined $skin &amp;&amp; defined $newName;

  $this-&gt;send('RenameClusterSkin '.$this-&gt;printWords($skin).' INTO '.$this-&gt;printWords($newName));
  $this-&gt;_parseResponse();
}

sub DeleteClusterSkin {
  my ( $this, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteClusterSkin($skinName)'
      unless defined $skin;

  $this-&gt;send('DeleteClusterSkin '.$this-&gt;printWords($skin));
  $this-&gt;_parseResponse();
}

sub ListClusterSkinFiles {
  my ( $this, $skin ) = @_;
  croak 'usage CGP::CLI-&gt;ListClusterSkinFiles($skinName)'
      unless defined $skin;

  $this-&gt;send('ListClusterSkinFiles '.$this-&gt;printWords($skin));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ReadClusterSkinFile {
  my ( $this, $skin, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;ReadClusterSkinFile($skinName,$fileName)'
      unless defined $skin &amp;&amp; defined $fileName;

  $this-&gt;send('ReadClusterSkinFile '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub StoreClusterSkinFile {
  my ( $this, $skin, $fileName,$data ) = @_;
  croak 'usage CGP::CLI-&gt;StoreClusterSkinFile($skinName,$fileName,$base64data)'
      unless defined $skin &amp;&amp; defined $fileName &amp;&amp; defined $data;

  $this-&gt;send('StoreClusterSkinFile '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName).' DATA ['.$data.']');
  $this-&gt;_parseResponse();
}

sub DeleteClusterSkinFile {
  my ( $this, $skin, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteClusterSkinFile($skinName,$fileName)'
      unless defined $skin &amp;&amp; defined $fileName;

  $this-&gt;send('StoreClusterSkinFile '.$this-&gt;printWords($skin).' FILE '.$this-&gt;printWords($fileName).' DELETE');
  $this-&gt;_parseResponse();
}

#############################################
#   Web Interface Tuning

sub ListWebUserInterface {
  my ($this, $domainName, $path) = @_;

  my $line = 'ListWebUserInterface';
  $line .= ' '.$domainName if($domainName);
  $line .= ' PATH '.$this-&gt;printWords($path) if($path);

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetWebUserInterface {
  my ($this, $domainName, $path) = @_;
  croak 'usage CGP::CLI-&gt;GetWebUserInterface($domainName, $fileName)'
    unless defined $domainName &amp;&amp; defined $path;

  my $line = 'GetWebUserInterface '.$domainName.' FILE '.$this-&gt;printWords($path);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub PutWebUserInterface {
  my ($this, $domainName, $path, $data) = @_;
  croak 'usage CGP::CLI-&gt;PutWebUserInterface($domainName, $fileName, $base64data)'
    unless defined $domainName &amp;&amp; defined $path &amp;&amp; defined $data;

  my $line = 'PutWebUserInterface '.$domainName;
  $line .= ' FILE '.$this-&gt;printWords($path).' DATA ['.$data.']';
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub DeleteWebUserInterface {
  my ($this, $domainName, $path) = @_;
  croak 'usage CGP::CLI-&gt;DeleteWebUserInterface($domainName, $fileName)'
    unless defined $domainName &amp;&amp; defined $path;

  my $line = 'DeleteWebUserInterface ';
  $line .= ' '.$domainName if($domainName);
  $line .= ' FILE '.$this-&gt;printWords($path) if($path);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub ClearWebUserCache {
  my ($this, $domainName) = @_;

  my $line = 'ClearWebUserCache';
  $line .= ' '.$domainName if($domainName);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

#############################################
#   Web Interface Integration

sub CreateWebUserSession {
  my ($this, $accountName, $ipAddress, $wml,$skin,$origAddress) = @_;
  croak 'usage CGP::CLI-&gt;CreateWebUserSession($accountName, $IP_Address[, "WML"[,"mySkin"]][,$origAddress )'
    unless defined $accountName &amp;&amp; defined $ipAddress;
  my $line='CreateWebUserSession '.$accountName.' ADDRESS '.$ipAddress;
  $line .= " FOR $origAddress" if($origAddress);
  $line .= " $wml" if($wml);
  $line .= " SKIN $skin" if($skin);
  
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub CreateXIMSSSession {
  my ($this, $accountName, $ipAddress,$origAddress) = @_;
  croak 'usage CGP::CLI-&gt;CreateXIMSSSession($accountName, $IP_Address,[$origAddress] )'
    unless defined $accountName &amp;&amp; defined $ipAddress;
  my $line='CreateXIMSSSession '.$accountName.' ADDRESS '.$ipAddress;
  $line .= " FOR $origAddress" if($origAddress);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub FindWebUserSession {
  my ($this, $accountName,$address) = @_;
  croak 'usage CGP::CLI-&gt;FindWebUserSession($accountName [,$address])' unless defined $accountName;

  my $line='FindWebUserSession '.$accountName;
  $line .= ' ADDRESS '.$address if($address);

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetWebUserSession {
  my ($this, $sessionID,$domain) = @_;
  croak 'usage CGP::CLI-&gt;GetWebUserSession($sessionID [,$domain])' unless defined $sessionID;

  my $line='GetWebUserSession '.$sessionID;
  $line .= ' DOMAIN '.$domain if($domain);

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub FindAccountSession {
  my ($this, $accountName,$address,$proxiedAddress,$protocol,$transport,$client) = @_;
  croak 'usage CGP::CLI-&gt;FindAccountSession($accountName [,$address,$proxiedAddress,$protocol,$transport,$client])' unless defined $accountName;

  my $line='FindAccountSession '.$accountName;
  $line .= ' ADDRESS '.$address if($address);
  $line .= ' FOR '.$proxiedAddress if($proxiedAddress);
  $line .= ' PROTOCOL '.$protocol if($protocol);
  $line .= ' TRANSPORT '.$transport if($transport);
  $line .= ' CLIENT '.$client if($client);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetSession {
  my ($this, $sessionID,$domain) = @_;
  croak 'usage CGP::CLI-&gt;GetSession($sessionID [,$domain])' unless defined $sessionID;

  my $line='GetSession '.$sessionID;
  $line .= ' DOMAIN '.$domain if($domain);

  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}



sub KillWebUserSession {
  my ($this, $sessionID,$domain) = @_;
  croak 'usage CGP::CLI-&gt;KillWebUserSession($sessionID [,$domain])' unless defined $sessionID;
  my $line='KillWebUserSession '.$sessionID;
  $line .= ' DOMAIN '.$domain if($domain);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}
sub KillSession {
  my ($this, $sessionID,$domain) = @_;
  croak 'usage CGP::CLI-&gt;KillSession($sessionID [,$domain])' unless defined $sessionID;
  my $line='KillSession '.$sessionID;
  $line .= ' DOMAIN '.$domain if($domain);

  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

#############################################
#   Real-Time Application Administration 
 
sub CreateDomainPBX {
  my ( $this, $domain, $language ) = @_;
  croak 'usage CGP::CLI-&gt;CreateDomainPBX($domainName,$language)'
      unless defined $domain;
  my $line = 'CreateDomainPBX '.$domain;
  $line .= ' FILE '.$this-&gt;printWords($language) if($language);
      
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}
sub DeleteDomainPBX {
  my ( $this, $domain, $language ) = @_;
  croak 'usage CGP::CLI-&gt;Deleref($ret)teDomainPBX($domainName,$language)'
      unless defined $domain &amp;&amp; defined $language;
  my $line = 'DeleteDomainPBX '.$domain . ' FILE '.$this-&gt;printWords($language);
      
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub ListDomainPBXFiles {
  my ($this, $domain,$language) = @_;
  croak 'usage CGP::CLI-&gt;ListDomainPBXFiles($domainName,$language)'
      unless defined $domain;
  my $line = 'ListDomainPBXFiles '.$domain;
  $line .= ' FILE '.$this-&gt;printWords($language) if($language);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ReadDomainPBXFile {
  my ( $this, $domain, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;ReadDomainPBXFile($domainName,$fileName)'
      unless defined $domain &amp;&amp; defined $fileName;

  $this-&gt;send('ReadDomainPBXFile '.$domain.' FILE '.$this-&gt;printWords($fileName));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub StoreDomainPBXFile {
  my ( $this, $domain, $fileName,$base64data ) = @_;
  croak 'usage CGP::CLI-&gt;StoreDomainPBXFile($domainName,$fileName,$base64data)'
      unless defined $domain &amp;&amp; defined $fileName &amp;&amp; defined $base64data;
  $this-&gt;send('StoreDomainPBXFile '.$domain.' FILE '.$this-&gt;printWords($fileName).' DATA ['.$base64data.']');
  $this-&gt;_parseResponse();
}

sub DeleteDomainPBXFile {
  my ( $this, $domain, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteDomainPBXFile($domainName,$fileName)'
      unless defined $domain &amp;&amp; defined $fileName;

  $this-&gt;send('StoreDomainPBXFile '.$domain.' FILE '.$this-&gt;printWords($fileName).' DELETE');
  $this-&gt;_parseResponse();
}

#--

sub CreateServerPBX {
  my ( $this, $language ) = @_;
  croak 'usage CGP::CLI-&gt;CreateServerPBX($language)'
      unless defined $language;
  my $line = 'CreateServerPBX '.$this-&gt;printWords($language);      
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}
sub DeleteServerPBX {
  my ( $this, $language ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteServerPBX($language)'
      unless defined $language;
  my $line = 'DeleteServerPBX ' .$this-&gt;printWords($language);      
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub ListServerPBXFiles {
  my ($this,$language) = @_;

  my $line = 'ListServerPBXFiles ';
  $line .= $this-&gt;printWords($language) if($language);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ReadServerPBXFile {
  my ( $this, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;ReadServerPBXFile($fileName)'
      unless defined $fileName;

  $this-&gt;send('ReadServerPBXFile '.$this-&gt;printWords($fileName));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub StoreServerPBXFile {
  my ( $this, $fileName,$base64data ) = @_;
  croak 'usage CGP::CLI-&gt;StoreServerPBXFile($fileName,$base64data)'
      unless  defined $fileName &amp;&amp; defined $base64data;
  $this-&gt;send('StoreServerPBXFile ' .$this-&gt;printWords($fileName).' DATA ['.$base64data.']');
  $this-&gt;_parseResponse();
}

sub DeleteServerPBXFile {
  my ( $this, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteServerPBXFile($fileName)'
      unless defined $fileName;

  $this-&gt;send('StoreServerPBXFile '.$this-&gt;printWords($fileName).' DELETE');
  $this-&gt;_parseResponse();
}

#--

sub CreateClusterPBX {
  my ( $this, $language ) = @_;
  croak 'usage CGP::CLI-&gt;CreateClusterPBX($language)'
      unless defined $language;
  my $line = 'CreateClusterPBX ' .$this-&gt;printWords($language);      
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}
sub DeleteClusterPBX {
  my ( $this, $language ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteClusterPBX($language)'
      unless defined $language;
  my $line = 'DeleteClusterPBX ' .$this-&gt;printWords($language);      
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub ListClusterPBXFiles {
  my ($this,$language) = @_;

  my $line = 'ListClusterPBXFiles ';
  $line .= $this-&gt;printWords($language) if($language);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ReadClusterPBXFile {
  my ( $this, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;ReadClusterPBXFile($fileName)'
      unless defined $fileName;

  $this-&gt;send('ReadClusterPBXFile '.$this-&gt;printWords($fileName));
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub StoreClusterPBXFile {
  my ( $this, $fileName,$base64data ) = @_;
  croak 'usage CGP::CLI-&gt;StoreClusterPBXFile($fileName,$base64data)'
      unless  defined $fileName &amp;&amp; defined $base64data;
  $this-&gt;send('StoreClusterPBXFile ' .$this-&gt;printWords($fileName).' DATA ['.$base64data.']');
  $this-&gt;_parseResponse();
}

sub DeleteClusterPBXFile {
  my ( $this, $fileName ) = @_;
  croak 'usage CGP::CLI-&gt;DeleteClusterPBXFile($fileName)'
      unless defined $fileName;

  $this-&gt;send('StoreClusterPBXFile '.$this-&gt;printWords($fileName).' DELETE');
  $this-&gt;_parseResponse();
}

#############################################
#  Real-Time Application Control

sub StartPBXTask {
  my ($this, $account,$program,$entry,$param) = @_;
  croak 'usage CGP::CLI-&gt;StartPBXTask($account,$program[,$entryName,$param])'
      unless (defined $account &amp;&amp; defined $program);
  my $line = "StartPBXTask $account PROGRAM $program";
  $line .= ' ENTRY '.$entry if($entry);
  $line .= ' PARAM '.$param if($param);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SendTaskEvent {
  my ($this, $taskID,$eventName,$param) = @_;
  croak 'usage CGP::CLI-&gt;SendTaskEvent($taskID,$eventName[,$param])'
      unless (defined $taskID &amp;&amp; defined $eventName);
  my $line = "SendTaskEvent $taskID EVENT ".$this-&gt;printWords($eventName);
  $line .= ' PARAM '.$param if($param);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub KillNode {
  my ($this, $taskID) = @_;
  croak 'usage CGP::CLI-&gt;KillNode($taskID)'
      unless (defined $taskID);
  my $line = "KillNode $taskID";
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub ReadNodeStatus {
  my ($this, $taskID) = @_;
  croak 'usage CGP::CLI-&gt;ReadNodeStatus($taskID)'
      unless (defined $taskID);
  my $line = "ReadNodeStatus $taskID";
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}


#############################################
#  Server Settings

sub GetModule {
  my ( $this, $moduleName ) = @_;
  $this-&gt;send('GetModule '.$moduleName);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub UpdateModule {
  my ( $this, $moduleName, $newSettings ) = @_;
  croak 'usage CGP::CLI-&gt;UpdateModule($moduleName, \%newSettings)'
    unless defined $moduleName &amp;&amp; defined $newSettings;
  $this-&gt;send ('UpdateModule '.$moduleName.' '.$this-&gt;printWords($newSettings) );
  $this-&gt;_parseResponse();
}

sub SetModule {
  my ( $this, $moduleName, $newSettings ) = @_;
  croak 'usage CGP::CLI-&gt;SetModule($moduleName, \%newSettings)'
    unless defined $moduleName &amp;&amp; defined $newSettings;
  $this-&gt;send ('SetModule '.$moduleName.' '.$this-&gt;printWords($newSettings) );
  $this-&gt;_parseResponse();
}

sub GetQueueSettings {
  my ( $this ) = @_;
  $this-&gt;send('GetQueueSettings');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub SetQueueSettings {
  my ( $this,  $newSettings ) = @_;
  croak 'usage CGP::CLI-&gt;SetQueueSettings(\%newSettings)'
    unless defined $newSettings;
  $this-&gt;send ('SetQueueSettings '.$this-&gt;printWords($newSettings) );
  $this-&gt;_parseResponse();
}

sub GetSignalSettings {
  my ( $this ) = @_;
  $this-&gt;send('GetSignalSettings');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub SetSignalSettings {
  my ( $this,  $newSettings ) = @_;
  croak 'usage CGP::CLI-&gt;SetSignalSettings(\%newSettings)'
    unless defined $newSettings;
  $this-&gt;send ('SetSignalSettings '.$this-&gt;printWords($newSettings) );
  $this-&gt;_parseResponse();
}
sub GetClusterSettings {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterSettings');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub SetClusterSettings {
  my ( $this,  $newSettings ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterSettings(\%newSettings)'
    unless defined $newSettings;
  $this-&gt;send ('SetClusterSettings '.$this-&gt;printWords($newSettings) );
  $this-&gt;_parseResponse();
}


sub GetLANIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetLANIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetBlacklistedIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetBlacklistedIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetClientIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClientIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetWhiteHoleIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetWhiteHoleIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetNATedIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetNATedIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetDebugIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetDebugIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetDeniedIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetDeniedIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetProtection {
  my ( $this ) = @_;
  $this-&gt;send('GetProtection');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetBanned {
  my ( $this ) = @_;
  $this-&gt;send('GetBanned');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetLANIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetLANIPs("10.0.0.1\e192.168.0.1")'
    unless defined $addresses;
  $this-&gt;send ('SetLANIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}


sub SetBlacklistedIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetBlacklistedIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetBlacklistedIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub SetClientIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClientIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetClientIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub SetWhiteHoleIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetWhiteHoleIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetWhiteHoleIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}
sub SetNATedIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetNATedIPs("192.168.0.1\e10.0.0.1")'
    unless defined $addresses;
  $this-&gt;send ('SetNATedIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}
sub SetDebugIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetDebugIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetDebugIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}
sub SetDeniedIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetDeniedIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetDeniedIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub SetProtection {
  my ( $this, $settings ) = @_;
  croak 'usage CGP::CLI-&gt;SetProtection(\%settings)'
    unless defined $settings;
  $this-&gt;send ('SetProtection '.$this-&gt;printWords($settings));
  $this-&gt;_parseResponse();
}

sub SetBanned {
  my ( $this, $settings ) = @_;
  croak 'usage CGP::CLI-&gt;SetBanned(\%settings)'
    unless defined $settings;
  $this-&gt;send ('SetBanned '.$this-&gt;printWords($settings));
  $this-&gt;_parseResponse();
}

sub GetClusterLANIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterLANIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetClusterBlacklistedIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterBlacklistedIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetClusterClientIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterClientIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetClusterWhiteHoleIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterWhiteHoleIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetClusterNATedIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterNATedIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetClusterDebugIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterDebugIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetClusterDeniedIPs {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterDeniedIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetClusterProtection {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterProtection');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetClusterBanned {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterBanned');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterLANIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterLANIPs("10.0.0.1\e192.168.0.1")'
    unless defined $addresses;
  $this-&gt;send ('SetClusterLANIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub SetClusterBlacklistedIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterBlacklistedIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetClusterBlacklistedIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub SetClusterClientIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterClientIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetClusterClientIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub SetClusterWhiteHoleIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterWhiteHoleIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetClusterWhiteHoleIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}
sub SetClusterNATedIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterNATedIPs("192.168.0.1\e10.0.0.1")'
    unless defined $addresses;
  $this-&gt;send ('SetClusterNATedIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}
sub SetClusterDebugIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterDebugIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetClusterDebugIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}
sub SetClusterDeniedIPs {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterDeniedIPs("11.22.33.44\e55.66.77.88")'
    unless defined $addresses;
  $this-&gt;send ('SetClusterDeniedIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub SetClusterProtection {
  my ( $this, $settings ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterProtection(\%settings)'
    unless defined $settings;
  $this-&gt;send ('SetClusterProtection '.$this-&gt;printWords($settings));
  $this-&gt;_parseResponse();
}

sub GetServerRules {
  my $this = shift;
  $this-&gt;send('GetServerRules');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetServerRules {
  my ($this, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetServerRules(\@rules)'
    unless defined $rules;
  $this-&gt;send('SetServerRules '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}


sub GetClusterRules {
  my $this = shift;
  $this-&gt;send('GetClusterRules');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterRules {
  my ($this, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterRules(\@rules)'
    unless defined $rules;
  $this-&gt;send('SetClusterRules '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

sub GetServerMailRules {
  my $this = shift;
  $this-&gt;send('GetServerMailRules');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetServerMailRules {
  my ($this, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetServerMailRules(\@rules)'
    unless defined $rules;
  $this-&gt;send('SetServerMailRules '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

#sub UpdateServerMailRule {
#  my ($this, $rule) = @_;
#  croak 'usage CGP::CLI-&gt;UpdateServerMailRules(\@rule)'
#    unless defined $rule;
#  $this-&gt;send('UpdateServerMailRule '.$this-&gt;printWords($rule));
#  $this-&gt;_parseResponse();
#}

sub GetServerSignalRules {
  my $this = shift;
  $this-&gt;send('GetServerSignalRules');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetServerSignalRules {
  my ($this, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetServerSignalRules(\@rules)'
    unless defined $rules;
  $this-&gt;send('SetServerSignalRules '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

#sub UpdateServerSignalRule {
#  my ($this, $rule) = @_;
#  croak 'usage CGP::CLI-&gt;UpdateServerSignalRule(\@rule)'
#    unless defined $rule;
#  $this-&gt;send('UpdateServerSignalRule '.$this-&gt;printWords($rule));
#  $this-&gt;_parseResponse();
#}

sub GetClusterMailRules {
  my $this = shift;
  $this-&gt;send('GetClusterMailRules');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterMailRules {
  my ($this, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterMailRules(\@rules)'
    unless defined $rules;
  $this-&gt;send('SetClusterMailRules '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

#sub UpdateClusterMailRule {
#  my ($this, $rule) = @_;
#  croak 'usage CGP::CLI-&gt;UpdateClusterMailRule(\@rule)'
#    unless defined $rule;
#  $this-&gt;send('UpdateClusterMailRule '.$this-&gt;printWords($rule));
#  $this-&gt;_parseResponse();
#}

sub GetClusterSignalRules {
  my $this = shift;
  $this-&gt;send('GetClusterSignalRules');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterSignalRules {
  my ($this, $rules) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterSignalRules(\@rules)'
    unless defined $rules;
  $this-&gt;send('SetClusterSignalRules '.$this-&gt;printWords($rules));
  $this-&gt;_parseResponse();
}

#sub UpdateClusterSignalRule {
#  my ($this, $rule) = @_;
#  croak 'usage CGP::CLI-&gt;UpdateClusterSignalRule(\@rule)'
#    unless defined $rule;
#  $this-&gt;send('UpdateClusterSignalRule '.$this-&gt;printWords($rule));
#  $this-&gt;_parseResponse();
#}



sub RefreshOSData {
  my ($this) = @_;
  $this-&gt;send('RefreshOSData');
  $this-&gt;_parseResponse();
}

sub GetRouterTable {
  my $this = shift;
  $this-&gt;send('GetRouterTable');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetRouterTable {
  my ($this, $table) = @_;
  croak 'usage CGP::CLI-&gt;GetRouterTable("&lt;addr1&gt;=addr1\@domain.com\\e&lt;addr2&gt;=addr2\@domain.com\\e")'
    unless defined $table;
  $this-&gt;send('SetRouterTable '.$this-&gt;printWords($table));
  $this-&gt;_parseResponse();
}

sub GetRouterSettings {
  my $this = shift;
  $this-&gt;send('GetRouterSettings');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetRouterSettings {
  my ($this, $settings) = @_;
  croak 'usage CGP::CLI-&gt;SetRouterSettings(\@settings)'
    unless defined $settings;
  $this-&gt;send('SetRouterSettings '.$this-&gt;printWords($settings));
  $this-&gt;_parseResponse();
}


sub GetClusterRouterTable {
  my $this = shift;
  $this-&gt;send('GetClusterRouterTable');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub SetClusterRouterTable {
  my ($this, $table) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterRouterTable("&lt;addr1&gt;=addr1\@domain.com\\e&lt;addr2&gt;=addr2\@domain.com\\e")'
    unless defined $table;
  $this-&gt;send('SetClusterRouterTable '.$this-&gt;printWords($table));
  $this-&gt;_parseResponse();
}


sub GetServerIntercept {
  my ( $this ) = @_;
  $this-&gt;send('GetServerIntercept');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub SetServerIntercept {
  my ( $this, $settings ) = @_;
  croak 'usage CGP::CLI-&gt;SetServerIntercept(\%settings)'
    unless defined $settings;
  $this-&gt;send ('SetServerIntercept '.$this-&gt;printWords($settings));
  $this-&gt;_parseResponse();
}

sub GetClusterIntercept {
  my ( $this ) = @_;
  $this-&gt;send('GetClusterIntercept');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub SetClusterIntercept {
  my ( $this, $settings ) = @_;
  croak 'usage CGP::CLI-&gt;SetClusterIntercept(\%settings)'
    unless defined $settings;
  $this-&gt;send ('SetClusterIntercept '.$this-&gt;printWords($settings));
  $this-&gt;_parseResponse();
}


sub Route {
  my ($this, $address, $mail) = @_;
  croak 'usage CGP::CLI-&gt;Route(address[,"mail"])'
    unless defined $address;
  my $line='Route '.$address;
  $line .= ' mail' if($mail);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

#############################################
#  Monitoring commands

sub GetSNMPElement {
  my ($this, $element) = @_;
  $this-&gt;send('GetSNMPElement '.$element);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetDialogInfo {
  my ($this, $dialogID) = @_;
  $this-&gt;send('GetDialogInfo '.$dialogID);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub Shutdown {
  my $this = shift;
  $this-&gt;send('SHUTDOWN');
  $this-&gt;_parseResponse();
}

#############################################
#  Statistics commands

sub GetAccountStat {
  my ($this, $account, $key) = @_;
  croak 'usage CGP::CLI-&gt;GetAccountStat($account[,$key])'
    unless defined $account;
  my $line = 'GetAccountStat '.$account;
  $line .= ' Key '.$key if $key;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ResetAccountStat {
  my ($this, $account, $key) = @_;
  croak 'usage CGP::CLI-&gt;ResetAccountStat($account[,$key])'
    unless defined $account;
  my $line = 'ResetAccountStat '.$account;
  $line .= ' Key '.$key if $key;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

sub GetDomainStat {
  my ($this, $domain, $key) = @_;
  croak 'usage CGP::CLI-&gt;GetDomainStat($domain[,$key])'
    unless defined $domain;
  my $line = 'GetDomainStat '.$domain;
  $line .= ' Key '.$key if $key;
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub ResetDomainStat {
  my ($this, $domain, $key) = @_;
  croak 'usage CGP::CLI-&gt;ResetDomainStat($domain[,$key])'
    unless defined $domain;
  my $line = 'ResetDomainStat '.$domain;
  $line .= ' Key '.$key if $key;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}

#############################################
#  Miscellaneous commands

sub WriteLog {
  my ($this, $level, $msg) = @_;
  croak 'usage CGP::CLI-&gt;WriteLog($level,$message)'
    unless defined $level &amp;&amp; defined $msg;
  $this-&gt;send('WriteLog '.$level.' '.$this-&gt;printWords($msg));
  $this-&gt;_parseResponse();
}
sub ReleaseSMTPQueue {
  my ($this, $queue) = @_;
  croak 'usage CGP::CLI-&gt;ReleaseSMTPQueue($queueName)'
    unless defined $queue;
  $this-&gt;send('ReleaseSMTPQueue '.$this-&gt;printWords($queue));
  $this-&gt;_parseResponse();
}
sub RejectQueueMessage {
  my ($this, $msg, $text) = @_;
  croak 'usage CGP::CLI-&gt;RejectQueueMessage($msgID [,$errorText])'
    unless defined $msg;
  my $line = 'RejectQueueMessage '.$msg;
  $line .= $this-&gt;printWords($text) if $text;
  $this-&gt;send($line);
  $this-&gt;_parseResponse();
}
sub GetMessageQueueInfo {
  my ($this, $moduleName, $queueName) = @_;
  croak 'usage CGP::CLI-&gt;GetMessageQueueInfo($moduleName,$queueName)'
    unless (defined $moduleName &amp;&amp; defined $queueName);
  my $line = 'GetMessageQueueInfo '.$moduleName.' QUEUE '.$this-&gt;printWords($queueName);
  $this-&gt;send($line);
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}

sub GetCurrentController {
  my ($this) = @_;
  $this-&gt;send('GetCurrentController');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetTempClientIPs  {
  my ($this) = @_;
  $this-&gt;send('GetTempClientIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub GetTempBlacklistedIPs  {
  my ($this) = @_;
  $this-&gt;send('GetTempBlacklistedIPs');
  return undef unless $this-&gt;_parseResponse();
  $this-&gt;parseWords($this-&gt;getWords);
}
sub SetTempBlacklistedIPs  {
  my ( $this, $addresses ) = @_;
  croak 'usage CGP::CLI-&gt;SetTempBlacklistedIPs("111.11.1.1\e222.2.2.2")'
    unless defined $addresses;
  $this-&gt;send ('SetTempBlacklistedIPs '.$this-&gt;printWords($addresses));
  $this-&gt;_parseResponse();
}

sub RemoveAccountSubset  {
  my ($this, $account, $subset) = @_;
  croak 'usage CGP::CLI-&gt;RemoveAccountSubset($account,$subset)'
    unless defined $account &amp;&amp; defined $subset;       
  $this-&gt;send('RemoveAccountSubset '.$account.' SUBSET '.$this-&gt;printWords($subset));
  return undef unless $this-&gt;_parseResponse();
}


#########################################################################
#########################################################################
##  Internal routines

sub _setStrangeError
{
    my ($this, $line, $code) = @_;
    if ($code)
    {
        $this-&gt;{errCode} = $code;
    }
    else
    {
        $this-&gt;{errCode} = $CGP::CLI_CODE_STRANGE;
    }
    $this-&gt;{errMsg} = $line;
    return 0;
}

sub _parseResponse
{
  my $this = shift;

  my $responseLine = $this-&gt;{theSocket}-&gt;getline();


  print STDERR "CGP::CLI-&gt;_parseResponse::responseLine = $responseLine\n\n"
      if $this-&gt;{'debug'};

  $responseLine =~ /^(\d+)\s(.*)$/;
  return $this-&gt;_setStrangeError($responseLine) unless ($1);
  $this-&gt;{errCode} = $1;
  if($1 == $CGP::CLI_CODE_OK_INLINE) {
    $this-&gt;{'inlineResponse'} = $2;	
    $this-&gt;{errMsg} = 'OK';
  } else {
    $this-&gt;{errMsg} = $2;
    chomp($this-&gt;{errMsg});
    $this-&gt;{errMsg} =~ s/\r$//;
  }
  $this-&gt;{'lastAccess'}=time();
  $this-&gt;isSuccess;
}

sub convertOutput {
  my $data = $_[0];
  my $translate = $_[1];
  if(!defined($data)) {
    return '#NULL#';
  } elsif(ref($data) eq 'HASH') {
    my $outp='{';
    #$outp.="\n";
    foreach (sort keys %$data) {
      my $value=@$data{$_};
      $outp .= convertOutput($_,$translate).'='.convertOutput($value,$translate).';';
      #$outp.="\n";
    }
    $outp.= '}';
    #$outp.="\n";
    return $outp;
  } elsif(ref($data) eq 'ARRAY') {
    my $outp='(';
    my $first=1;
    foreach (@$data) {
      if(!$first) { $outp.=','; } else { $first=0; }
      $outp.=convertOutput($_,$translate);
    }
    $outp.= ')';
    return $outp;
  } else {
    if($data =~ /[\W_]/ || $data eq '') {
      if($translate) {
        $data =~ s/\\((?![enr\d]))/\\\\$1/g;
        $data =~ s/\"/\\\"/g;
      }
      $data =~ s/([\x00-\x1F\x7F])/'\\'.('0'x(3-length(ord($1)))).ord($1)/ge;

      return '"' . $data . '"';
    } else {
      return $data;
    }
  }
}

sub printWords {
  my ($this,$data)= @_;
  return convertOutput($data,$this-&gt;{'translateStrings'});
}

sub strip
{
    my $line = shift;
    $line =~ s/^\s+//;
    $line =~ s/\s+$//;
    return $line;
}

sub getWords {
  my $this = shift;
  if($this-&gt;{errCode} == $CGP::CLI_CODE_OK_INLINE) {
	return $this-&gt;{'inlineResponse'};
  }
  my ($bag, $line) = ('', '');
  my $firstLine = 1;
  my $lastLine = '';
  while (1) {
    $line = $this-&gt;{theSocket}-&gt;getline();
    chomp $line;
    $line = strip($line);
    if($firstLine) {
      $line =~ /^(.)/;
      if ($1) {
        $lastLine = '\)' if $1 eq '(';
        $lastLine = '\}' if $1 eq '{';
        $lastLine = $lastLine . '$';
        $firstLine = 0;
      }
    }
    $bag .= $line;
    last if $line =~ /$lastLine/;
  }
  return $bag;
}


sub send {
  my ($this, $command) = @_;

  if(time()-$this-&gt;{'lastAccess'} &gt; $CGP::TIMEOUT ||
     !($this-&gt;{theSocket}) ||
     $this-&gt;{theSocket}-&gt;error()) {
    $this-&gt;{theSocket}-&gt;shutdown(SHUT_RDWR) if($this-&gt;{theSocket});
    unless($this-&gt;connect()) {
      die "Failure: Can't reopen CLI connection";
    }
  }

  $this-&gt;{currentCGateCommand} = $command;
  print STDERR ref($this) . "-&gt;send($command)\n\n"
    if $this-&gt;{'debug'};
  $this-&gt;{'lastAccess'}=time();
  print {$this-&gt;{theSocket}} $command."\012";
}


###########################

sub skipSpaces {
  my $this = shift;
  while($this-&gt;{'span'} &lt; $this-&gt;{'len'} &amp;&amp; substr($this-&gt;{'data'},$this-&gt;{'span'},1) =~ /\s/) { ++$this-&gt;{'span'}; }
}

sub readWord {
  my $this = shift;
  my $isQuoted=0;
  my $isBlock=0;
  my $result="";

  $this-&gt;skipSpaces();
  if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq '"') {
    $isQuoted=1; ++$this-&gt;{'span'};
  } elsif(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq '[') {
    $isBlock=1;
  }
  while($this-&gt;{'span'} &lt; $this-&gt;{'len'}) {
    my $ch=substr($this-&gt;{'data'},$this-&gt;{'span'},1);

    if($isQuoted) {
      if($ch eq '\\') {
        if(substr($this-&gt;{'data'},$this-&gt;{'span'}+1,3) =~ /^(?:\"|\\|\d\d\d)/) { 
          $ch=substr($this-&gt;{'data'},++$this-&gt;{'span'},3);
          if($ch =~ /\d\d\d/) {
            $this-&gt;{'span'}+=2;
            $ch=chr($ch);
          } else {
            $ch=substr($ch,0,1);
            $ch='\\'.$ch unless($this-&gt;{'translateStrings'}); 
          }
        }
      } elsif($ch eq '"') {
        ++$this-&gt;{'span'};
        $this-&gt;skipSpaces();
        if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq '"') {
          ++$this-&gt;{'span'};
        } else {
          last;
        }  
      }
    } elsif($isBlock) {
      if($ch eq ']') {
        ++$this-&gt;{'span'};
        $this-&gt;skipSpaces();
        if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq '[') {
          ++$this-&gt;{'span'};
        } else {
          $result .= ']';
          last;
        }  

      }
    } elsif($ch =~ /[-a-zA-Z0-9\x80-\xff_\.\@\!\#\%\:]/) {    
    } else {
      last;
    }
    $result .= $ch;
    ++$this-&gt;{'span'};
  }
  return $result;
}


sub readKey() {
  my $this = shift;
  return $this-&gt;readWord();
}


sub readValue() {
  my $this = shift;
  $this-&gt;skipSpaces();
  my $ch=substr($this-&gt;{'data'},$this-&gt;{'span'},1);
  if($ch eq '{') {
    ++$this-&gt;{'span'};
    return $this-&gt;readDictionary();
  } elsif($ch eq '(') {
    ++$this-&gt;{'span'};
    return $this-&gt;readArray();
  } else {
    return $this-&gt;readWord();
  }
}

sub readArray() {
  my $this = shift;
  my $result=[];
  while($this-&gt;{'span'}&lt;$this-&gt;{'len'}) {
    $this-&gt;skipSpaces();
    if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq ')') {
      ++$this-&gt;{'span'};
      last;
    } else {
      my $theValue=$this-&gt;readValue();
      $this-&gt;skipSpaces();
      push(@$result,$theValue);
      if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq ',') {
        ++$this-&gt;{'span'};
      } elsif(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq ')') {
      } else { 
        croak "CGPro output format error:",substr($this-&gt;{'data'},$this-&gt;{'span'},10);
      }     
    }
  }
  return $result;
}

sub readDictionary {
  my $this = shift;
  my $result={};
  while($this-&gt;{'span'} &lt; $this-&gt;{'len'}) {
    $this-&gt;skipSpaces();
    if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) eq '}') {
      ++$this-&gt;{'span'};
      last;
    } else {
      my $theKey=$this-&gt;readKey();
      $this-&gt;skipSpaces();
      if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) ne '=') { croak "CGPro output format error:",substr($this-&gt;{'data'},$this-&gt;{'span'},10); }
      ++$this-&gt;{'span'};
      @$result{$theKey}=$this-&gt;readValue();
      $this-&gt;skipSpaces();
      if(substr($this-&gt;{'data'},$this-&gt;{'span'},1) ne ';') { croak "CGPro output format error:",substr($this-&gt;{'data'},$this-&gt;{'span'},10); }
      ++$this-&gt;{'span'};
    }
  }
  return $result;
}

sub parseWords {
  my $this = shift;

  $this-&gt;{'data'}=shift;
  $this-&gt;{'span'}=0;
  $this-&gt;{'len'}=length($this-&gt;{'data'});
  return $this-&gt;readValue();
}

1;
 
</pre></body></html>