X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=lib%2FCGP%2FCLI.pm;h=4eee3674918123a25364da55f08e162d7f19b54e;hb=25251198421033aab52a6d63f6233c230f78d0e9;hp=e19fffd71b7070a412901cd1c9339e7a523e46f4;hpb=585dff3bc52b44c32d7dbbf5038c9885ee73da6b;p=CGP-CLI.git
diff --git a/lib/CGP/CLI.pm b/lib/CGP/CLI.pm
index e19fffd..4eee367 100644
--- a/lib/CGP/CLI.pm
+++ b/lib/CGP/CLI.pm
@@ -1,7 +1,7 @@
####################################################################
# Perl interface to CommuniGate Pro CLI.
#
-# Version 2.7.5
+# Version 2.8.2
#
# Original location:
# Revision history:
@@ -40,18 +40,17 @@
# [Get|Set]AccountRules
# [Get|Set]Account[Mail|Signal]Rules
# UpdateAccount[Mail|Signal]Rule
+# [Get|Set]Account[RPOPs|SIPs];
# SetAccountRules
-# GetAccountRPOP
-# SetAccountRPOP
# GetAccountRights
# SetAccountRights
# GetAccountInfo
# [Get|Set|Update]AccountPrefs
-# GetEffectiveaAccountPrefs
+# GetAccountEffectivePrefs
# KillAccountSessions
# [Get|Set]AccountACL
# GetAccountACLRights
-
+# GetAccountPresence
############################## Group Commands
# ListGroups
# CreateGroup
@@ -68,6 +67,12 @@
# GetForwarder
# FindForwarders
+############################## Named Tasks
+# List[Domain|Account]NamedTasks
+# [Create|Rename|Delete]NamedTask
+# [Get|Update]NamedTask
+
+
############################## Domain commands
# ListDomains
# MainDomainName
@@ -96,7 +101,7 @@
# [Get|Update|Set]AccountDefaults
# [Get|Update|Set]ClusterAccountDefaults
# [Get|Set|Update]AccountDefaultPrefs
-# [Get|Set][Server|Cluster]AccountPrefs
+# [Get|Set|Update][Server|Cluster]AccountPrefs
# [Get|Update|Set]AccountTemplate
############################## Mailbox Administration
@@ -108,7 +113,8 @@
# GetMailboxRights
# SetMailboxClass
-# [Get|Set]AccountSubscription
+# [Get|Set]AccountSubscription *
+# [Get|Set]MailboxSubscription
# [Get|Set]MailboxAliases
############################## Alerts Administration
@@ -125,6 +131,12 @@
# ListWebFiles
# GetWebFilesInfo
+# [Read|Write|Rename|Delete]StorageFile
+# ListStorageFiles
+# GetStorageFileInfo
+# [Read|Update]StorageFileAttr
+# [Get|Set]FileSubscription
+
############################## Lists commands
# ListLists
# GetDomainLists
@@ -170,20 +182,35 @@
############################## 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
+
+############################## Account Services
+# RemoveAccountSubset
+# Roster
+# Balance
+
############################## Server commands
# [Get|Update|Set]Module
-
+# [Get|Set][Queue|Signal|Session|Cluster|MediaServer]Settings
# [Get|Set]LANIPs
# [Get|Set]BlacklistedIPs
# [Get|Set]ClientIPs
# [Get|Set]WhiteHoleIPs
# [Get|Set]Protection
+# [Get|Set]Network
# [Get|Set]Banned
# [Get|Set]ClusterLANIPs
@@ -191,6 +218,7 @@
# [Get|Set]ClusterClientIPs
# [Get|Set]ClusterWhiteHoleIPs
# [Get|Set]ClusterProtection
+# [Get|Set]ClusterNetwork
# GetClusterBanned
# [Get|Set][Server|Cluster]Rules
@@ -206,7 +234,8 @@
# Route
############################## Monitoring commands
-# GetSNMPElement
+# GetSNMPElement-GetStateElement
+# GetNextStatName
# Shutdown
############################## Statistics commands
@@ -221,7 +250,6 @@
# GetCurrentController
# GetTempClientIPs
# [Get|Set]TempBlacklistedIPs
-# RemoveAccountSubset
# List[Domain|Server|Cluster]Telnums
##############################################################
@@ -239,7 +267,7 @@ use IO::Socket;
use Digest::MD5;
use vars qw($VERSION);
-($VERSION) = '2.7.5';
+$VERSION = '2.8.2';
$CGP::SECURE_LOGIN = 1;
@@ -263,7 +291,7 @@ sub connect {
my ($this) = @_;
$this->{isConnected}=0;
- delete $this->{theSocket};
+ delete $this->{theSocket} if(exists($this->{theSocket}));
$this->{theSocket} = new IO::Socket::INET( %{$this->{connParams}} );
@@ -278,7 +306,7 @@ sub connect {
return undef;
};
- if($this->{isSecureLogin} && $this->{errMsg} =~ /(\<.*\@*\>)/) {
+ if($this->{isSecureLogin} && $this->{errMsg} =~ /(\<.*\@.*\>)/) {
my $md5=Digest::MD5->new;
if($md5) {
$md5->add($1.$this->{password});
@@ -342,7 +370,7 @@ sub new {
if($this->{isSecureLogin} && $this->{isWebUserLogin});
#print %$params;
- bless $this;
+ bless $this, $class;
$this->{connParams}=$params;
if(!(defined $params->{'connectNow'}) || $params->{'connectNow'}) {
@@ -546,10 +574,12 @@ sub SetAccount {
}
sub SetAccountPassword {
- my ($this, $accountName, $newPass) = @_;
- croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword)'
+ my ($this, $accountName, $newPass,$check) = @_;
+ croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword,$check)'
unless defined $accountName && defined $newPass;
- $this->send('SetAccountPassword '.$accountName.' TO '.$this->printWords($newPass));
+ my $line = 'SetAccountPassword '.$accountName.' PASSWORD '.$this->printWords($newPass);
+ $line .= ' CHECK' if($check);
+ $this->send($line);
$this->_parseResponse();
}
@@ -662,6 +692,40 @@ sub UpdateAccountSignalRule {
$this->_parseResponse();
}
+sub GetAccountRPOPs {
+ my ($this, $accountName) = @_;
+ croak 'usage CGP::CLI->GetAccountRPOPs($accountName)'
+ unless defined $accountName;
+ $this->send('GetAccountRPOPs '.$accountName);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetAccountRPOPs {
+ my ($this, $accountName, $newRecords) = @_;
+ croak 'usage CGP::CLI->SetAccountRPOPs($accountName, \@newRecords)'
+ unless defined $accountName && defined $newRecords;
+ $this->send('SetAccountRPOPs '.$accountName.' '.$this->printWords($newRecords));
+ $this->_parseResponse();
+}
+
+sub GetAccountRSIPs {
+ my ($this, $accountName) = @_;
+ croak 'usage CGP::CLI->GetAccountRSIPs($accountName)'
+ unless defined $accountName;
+ $this->send('GetAccountRSIPs '.$accountName);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetAccountRSIPs {
+ my ($this, $accountName, $newRecords) = @_;
+ croak 'usage CGP::CLI->SetAccountRPSIs($accountName, \@newRecords)'
+ unless defined $accountName && defined $newRecords;
+ $this->send('SetAccountRSIPs '.$accountName.' '.$this->printWords($newRecords));
+ $this->_parseResponse();
+}
+
sub GetAccountRPOP {
my ($this, $accountName) = @_;
croak 'usage CGP::CLI->GetAccountRPOP($accountName)'
@@ -673,7 +737,7 @@ sub GetAccountRPOP {
sub SetAccountRPOP {
my ($this, $accountName, $newRecords) = @_;
- croak 'usage CGP::CLI->SetAccountAliases($accountName, \@newRecords)'
+ croak 'usage CGP::CLI->SetAccountRPOP($accountName, \@newRecords)'
unless defined $accountName && defined $newRecords;
$this->send('SetAccountRPOP '.$accountName.' '.$this->printWords($newRecords));
$this->_parseResponse();
@@ -700,9 +764,17 @@ sub SetAccountRights {
sub GetAccountInfo {
my ($this, $account, $key) = @_;
- croak 'usage CGP::CLI->GetAccountInfo($account,$key)'
- unless defined $account && defined $key;
- $this->send('GetAccountInfo '.$account.' Key '.$this->printWords($key));
+ croak 'usage CGP::CLI->GetAccountInfo($account[,$key | ($key1,...)])'
+ unless defined $account;
+ my $line='GetAccountInfo '.$account;
+ if(defined $key) {
+ if(ref($key) eq 'ARRAY') {
+ $line.=' '.$this->printWords($key);
+ } else {
+ $line.=' Key '.$this->printWords($key);
+ }
+ }
+ $this->send($line);
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
@@ -765,11 +837,11 @@ sub GetEffectiveWebUser {
$this->parseWords($this->getWords);
}
-sub GetEffectiveAccountPrefs {
+sub GetAccountEffectivePrefs {
my ($this, $account) = @_;
- croak 'usage CGP::CLI->GetEffectiveAccountPrefs($account)'
+ croak 'usage CGP::CLI->GetAccountEffectivePrefs($account)'
unless defined $account;
- $this->send('GetEffectiveAccountPrefs '.$account);
+ $this->send('GetAccountEffectivePrefs '.$account);
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
@@ -816,7 +888,16 @@ sub GetAccountACLRights {
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
+sub GetAccountPresence {
+ my ($this, $account) = @_;
+ croak 'usage CGP::CLI->GetAccountPresence($accountName)'
+ unless (defined $account);
+ my $line = 'GetAccountPresence '.$account;
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
#################################################################
# Group managent commands
@@ -926,6 +1007,67 @@ sub FindForwarders {
}
#################################################################
+# Named Tasks managent commands
+
+sub ListDomainNamedTasks {
+ my ($this, $domainName) = @_;
+ my $line = 'ListDomainNamedTasks';
+ $line .= ' ' .$domainName if $domainName;
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+sub ListAccountNamedTasks {
+ my ($this, $accountName) = @_;
+ croak 'usage CGP::CLI->ListAccountNamedTasks($account)'
+ unless defined $accountName;
+ $this->send('ListAccountNamedTasks '.$accountName);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub CreateNamedTask {
+ my ($this, $taskName, $account) = @_;
+ croak 'usage CGP::CLI->CreateNamedTask($taskName, $accountName)'
+ unless defined $taskName && defined $account;
+ $this->send('CreateNamedTask '.$taskName.' FOR '.$account);
+ $this->_parseResponse();
+}
+sub RenameNamedTask {
+ my ($this, $taskName, $newName) = @_;
+ croak 'usage CGP::CLI->RenameNamedTask($taskName, $newName)'
+ unless defined $taskName && defined $newName;
+ $this->send('RenameNamedTask '.$taskName.' into '.$newName);
+ $this->_parseResponse();
+}
+
+sub DeleteNamedTask {
+ my ($this, $taskName) = @_;
+ croak 'usage CGP::CLI->DeleteNamedTask($taskName)'
+ unless defined $taskName;
+ $this->send('DeleteNamedTask '.$taskName);
+ $this->_parseResponse();
+}
+
+sub GetNamedTask {
+ my ($this, $taskName) = @_;
+ croak 'usage CGP::CLI->GetNamedTask($taskName)'
+ unless defined $taskName;
+ $this->send('GetNamedTask '.$taskName);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub UpdateNamedTask {
+ my ($this, $taskName, $settings) = @_;
+ croak 'usage CGP::CLI->UpdateNamedTask($taskName, \%settings)'
+ unless defined $taskName && defined $settings;
+ my $line = 'UpdateNamedTask '.$taskName.' '.$this->printWords($settings);
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+#################################################################
# Domain managent commands
sub ListDomains {
@@ -1368,6 +1510,11 @@ sub SetServerAccountPrefs {
$this->send('SetServerAccountPrefs '.$this->printWords($dict));
$this->_parseResponse();
}
+sub UpdateServerAccountPrefs {
+ my ( $this, $dict ) = @_;
+ $this->send('UpdateServerAccountPrefs '.$this->printWords($dict));
+ $this->_parseResponse();
+}
sub GetClusterWebUserDefaults {
my $this = shift;
@@ -1391,6 +1538,11 @@ sub SetClusterAccountPrefs {
$this->send('SetClusterAccountPrefs '.$this->printWords($dict));
$this->_parseResponse();
}
+sub UpdateClusterAccountPrefs {
+ my ( $this, $dict ) = @_;
+ $this->send('UpdateClusterAccountPrefs '.$this->printWords($dict));
+ $this->_parseResponse();
+}
sub GetDomainLocation {
my ( $this, $account ) = @_;
@@ -1768,6 +1920,25 @@ sub SetAccountSubscription {
$this->_parseResponse();
}
+sub GetMailboxSubscription {
+ my ($this,$accountName) = @_;
+ croak 'usage CGP::CLI->GetMailboxSubscription(accountName)'
+ unless defined $accountName;
+
+ $this->send('GetMailboxSubscription '.$accountName);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetMailboxSubscription {
+ my ($this,$accountName,$newSubscription) = @_;
+ croak 'usage CGP::CLI->SetMailboxSubscription(accountName,\%newSubscription)'
+ unless (defined $accountName && defined $newSubscription);
+
+ $this->send('SetMailboxSubscription '.$accountName.' '.$this->printWords($newSubscription));
+ $this->_parseResponse();
+}
+
sub GetMailboxAliases {
my ($this,$accountName) = @_;
croak 'usage CGP::CLI->GetMailboxAliases(accountName)'
@@ -1943,9 +2114,11 @@ sub PutWebFile {
unless (defined $accountName && defined $fileName && defined $data);
my $line='PutWebFile '.$accountName.' FILE '.$this->printWords($fileName);
$line .= ' OFFSET '. $position if(defined $position && $position!=0);
-
- $line .= ' DATA ['.$data.']';
-
+ if($data=~/\[.*\]$/) {
+ $line .= ' DATA '.$data;
+ } else {
+ $line .= ' DATA ['.$data.']';
+ }
$this->send($line);
$this->_parseResponse;
}
@@ -1991,6 +2164,133 @@ sub GetWebFilesInfo {
}
#################################################################
+# File Storage Administration
+
+sub ReadStorageFile {
+ my ($this,$accountName,$fileName,$position,$sliceSize,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->ReadStorageFile(accountName,fileName[,position,sliceSize[,authAccountName]])'
+ unless (defined $accountName && defined $fileName);
+ my $line='ReadStorageFile '.$accountName.' FILE '.$this->printWords($fileName);
+ $line .= ' OFFSET '. $position if(defined $position && $position!=0);
+ $line .= ' SIZE '. $sliceSize if(defined $sliceSize);
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+
+ $this->send($line);
+ return undef unless $this->_parseResponse;
+ $this->parseWords($this->getWords);
+}
+
+sub WriteStorageFile {
+ my ($this,$accountName,$fileName,$data,$position,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->WriteStorageFile(accountName,fileName,data [,position[,authAccountName]])'
+ unless (defined $accountName && defined $fileName && defined $data);
+ my $line='WriteStorageFile '.$accountName.' FILE '.$this->printWords($fileName);
+ $line .= ' OFFSET '. $position if(defined $position && $position!=0);
+ if($data=~/\[.*\]$/) {
+ $line .= ' DATA '.$data;
+ } else {
+ $line .= ' DATA ['.$data.']';
+ }
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+ $this->send($line);
+ $this->_parseResponse;
+}
+
+sub RenameStorageFile {
+ my ($this,$accountName,$oldFileName,$newFileName,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->RenameStorageFile(accountName,oldFileName,newFileName[,authAccountName])'
+ unless (defined $accountName && defined $oldFileName && defined $newFileName);
+ my $line='RenameStorageFile '.$accountName.' FILE '.$this->printWords($oldFileName).' INTO '.$this->printWords($newFileName);
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+ $this->send($line);
+ $this->_parseResponse;
+}
+
+sub DeleteStorageFile {
+ my ($this,$accountName,$fileName,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->DeleteStorageFile(accountName,fileName[,authAccountName])'
+ unless (defined $accountName && defined $fileName);
+ my $line='DeleteStorageFile '.$accountName.' FILE '.$this->printWords($fileName);
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+ $this->send($line);
+ $this->_parseResponse;
+}
+
+sub ListStorageFiles {
+ my ($this,$accountName,$filePath,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->ListStorageFiles(accountName [,filePath[,authAccountName]])'
+ unless defined $accountName;
+ my $line = 'ListStorageFiles '.$accountName;
+ $line .= ' PATH '.$this->printWords($filePath) if $filePath;
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+ $this->send($line);
+ return undef unless $this->_parseResponse;
+ $this->parseWords($this->getWords);
+}
+
+sub GetStorageFileInfo {
+ my ($this,$accountName,$filePath,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->GetStorageFileInfo(accountName[,filePath[,authAccountName])'
+ unless defined $accountName;
+ my $line='GetStorageFileInfo '.$accountName;
+ $line .= ' PATH '.$this->printWords($filePath) if $filePath;
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+ $this->send($line);
+
+ return undef unless $this->_parseResponse;
+ $this->parseWords($this->getWords);
+}
+
+sub ReadStorageFileAttr {
+ my ($this,$accountName,$fileName,$atributes,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->ReadStorageFileAttr(accountName,fileName[,attributes[,authAccountName]])'
+ unless (defined $accountName && defined $fileName);
+ my $line='ReadStorageFileAttr '.$accountName.' FILE '.$this->printWords($fileName);
+ $line .= $atributes if(defined $atributes);
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+
+ $this->send($line);
+ return undef unless $this->_parseResponse;
+ $this->parseWords($this->getWords);
+}
+
+sub UpdateStorageFileAttr {
+ my ($this,$accountName,$fileName,$attributes,$authAccountName) = @_;
+
+ croak 'usage CGP::CLI->UpdateStorageFileAttr(accountName,fileName,attributes[,authAccountName])'
+ unless (defined $accountName && defined $fileName && defined $attributes);
+ my $line='UpdateStorageFileAttr '.$accountName.' FILE '.$this->printWords($fileName).' '.$attributes;
+ $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
+ $this->send($line);
+ $this->_parseResponse;
+}
+
+sub GetFileSubscription {
+ my ($this, $accountName) = @_;
+ croak 'usage CGP::CLI->GetFileSubscription($accountName)'
+ unless defined $accountName;
+ $this->send('GetFileSubscription '.$accountName);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetFileSubscription {
+ my ($this, $accountName, $newSubscription) = @_;
+ croak 'usage CGP::CLI->SetFileSubscription($accountName, \@newSubscription)'
+ unless defined $accountName && defined $newSubscription;
+ $this->send('SetFileSubscription '.$accountName.' '.$this->printWords($newSubscription));
+ $this->_parseResponse();
+}
+
+
+#################################################################
# List management commands
sub ListLists {
@@ -2448,6 +2748,22 @@ sub GetWebUserSession {
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
+
+sub FindAccountSession {
+ my ($this, $accountName,$address,$proxiedAddress,$protocol,$transport,$client) = @_;
+ croak 'usage CGP::CLI->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->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
sub GetSession {
my ($this, $sessionID,$domain) = @_;
croak 'usage CGP::CLI->GetSession($sessionID [,$domain])' unless defined $sessionID;
@@ -2494,6 +2810,15 @@ sub CreateDomainPBX {
$this->send($line);
$this->_parseResponse();
}
+sub DeleteDomainPBX {
+ my ( $this, $domain, $language ) = @_;
+ croak 'usage CGP::CLI->Deleref($ret)teDomainPBX($domainName,$language)'
+ unless defined $domain && defined $language;
+ my $line = 'DeleteDomainPBX '.$domain . ' FILE '.$this->printWords($language);
+
+ $this->send($line);
+ $this->_parseResponse();
+}
sub ListDomainPBXFiles {
my ($this, $domain,$language) = @_;
@@ -2520,7 +2845,8 @@ sub StoreDomainPBXFile {
my ( $this, $domain, $fileName,$base64data ) = @_;
croak 'usage CGP::CLI->StoreDomainPBXFile($domainName,$fileName,$base64data)'
unless defined $domain && defined $fileName && defined $base64data;
- $this->send('StoreDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName).' DATA ['.$base64data.']');
+ $base64data='['.$base64data.']' unless($base64data=~/^\[.*\]$/);
+ $this->send('StoreDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName).' DATA '.$base64data);
$this->_parseResponse();
}
@@ -2537,8 +2863,17 @@ sub DeleteDomainPBXFile {
sub CreateServerPBX {
my ( $this, $language ) = @_;
- my $line = 'CreateServerPBX';
- $line .= $this->printWords($language) if($language);
+ croak 'usage CGP::CLI->CreateServerPBX($language)'
+ unless defined $language;
+ my $line = 'CreateServerPBX '.$this->printWords($language);
+ $this->send($line);
+ $this->_parseResponse();
+}
+sub DeleteServerPBX {
+ my ( $this, $language ) = @_;
+ croak 'usage CGP::CLI->DeleteServerPBX($language)'
+ unless defined $language;
+ my $line = 'DeleteServerPBX ' .$this->printWords($language);
$this->send($line);
$this->_parseResponse();
}
@@ -2567,7 +2902,8 @@ sub StoreServerPBXFile {
my ( $this, $fileName,$base64data ) = @_;
croak 'usage CGP::CLI->StoreServerPBXFile($fileName,$base64data)'
unless defined $fileName && defined $base64data;
- $this->send('StoreServerPBXFile ' .$this->printWords($fileName).' DATA ['.$base64data.']');
+ $base64data='['.$base64data.']' unless($base64data=~/^\[.*\]$/);
+ $this->send('StoreServerPBXFile ' .$this->printWords($fileName).' DATA '.$base64data);
$this->_parseResponse();
}
@@ -2584,8 +2920,17 @@ sub DeleteServerPBXFile {
sub CreateClusterPBX {
my ( $this, $language ) = @_;
- my $line = 'CreateClusterPBX';
- $line .= $this->printWords($language) if($language);
+ croak 'usage CGP::CLI->CreateClusterPBX($language)'
+ unless defined $language;
+ my $line = 'CreateClusterPBX ' .$this->printWords($language);
+ $this->send($line);
+ $this->_parseResponse();
+}
+sub DeleteClusterPBX {
+ my ( $this, $language ) = @_;
+ croak 'usage CGP::CLI->DeleteClusterPBX($language)'
+ unless defined $language;
+ my $line = 'DeleteClusterPBX ' .$this->printWords($language);
$this->send($line);
$this->_parseResponse();
}
@@ -2614,7 +2959,8 @@ sub StoreClusterPBXFile {
my ( $this, $fileName,$base64data ) = @_;
croak 'usage CGP::CLI->StoreClusterPBXFile($fileName,$base64data)'
unless defined $fileName && defined $base64data;
- $this->send('StoreClusterPBXFile ' .$this->printWords($fileName).' DATA ['.$base64data.']');
+ $base64data='['.$base64data.']' unless($base64data=~/^\[.*\]$/);
+ $this->send('StoreClusterPBXFile ' .$this->printWords($fileName).' DATA '.$base64data);
$this->_parseResponse();
}
@@ -2628,6 +2974,79 @@ sub DeleteClusterPBXFile {
}
#############################################
+# Real-Time Application Control
+
+sub StartPBXTask {
+ my ($this, $account,$program,$entry,$param) = @_;
+ croak 'usage CGP::CLI->StartPBXTask($account,$program[,$entryName,$param])'
+ unless (defined $account && defined $program);
+ my $line = "StartPBXTask $account PROGRAM $program";
+ $line .= ' ENTRY '.$entry if($entry);
+ $line .= ' PARAM '.$param if($param);
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SendTaskEvent {
+ my ($this, $taskID,$eventName,$param) = @_;
+ croak 'usage CGP::CLI->SendTaskEvent($taskID,$eventName[,$param])'
+ unless (defined $taskID && defined $eventName);
+ my $line = "SendTaskEvent $taskID EVENT ".$this->printWords($eventName);
+ $line .= ' PARAM '.$param if($param);
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+sub KillNode {
+ my ($this, $taskID) = @_;
+ croak 'usage CGP::CLI->KillNode($taskID)'
+ unless (defined $taskID);
+ my $line = "KillNode $taskID";
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub ReadNodeStatus {
+ my ($this, $taskID) = @_;
+ croak 'usage CGP::CLI->ReadNodeStatus($taskID)'
+ unless (defined $taskID);
+ my $line = "ReadNodeStatus $taskID";
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+#############################################
+# Account Services
+
+sub RemoveAccountSubset {
+ my ($this, $account, $subset) = @_;
+ croak 'usage CGP::CLI->RemoveAccountSubset($account,$subset)'
+ unless defined $account && defined $subset;
+ $this->send('RemoveAccountSubset '.$account.' SUBSET '.$this->printWords($subset));
+ return undef unless $this->_parseResponse();
+}
+
+sub Roster {
+ my ($this, $account, $params) = @_;
+ croak 'usage CGP::CLI->Roster($account,\%params)'
+ unless defined $account && defined $params;
+ $this->send('Roster '.$account.' '.$this->printWords($params));
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub Balance {
+ my ($this, $account, $params) = @_;
+ croak 'usage CGP::CLI->Balance($account,\%params)'
+ unless defined $account && defined $params;
+ $this->send('Balance '.$account.' '.$this->printWords($params));
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+#############################################
# Server Settings
sub GetModule {
@@ -2680,6 +3099,35 @@ sub SetSignalSettings {
$this->send ('SetSignalSettings '.$this->printWords($newSettings) );
$this->_parseResponse();
}
+sub GetMediaServerSettings {
+ my ( $this ) = @_;
+ $this->send('GetMediaServerSettings');
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+sub SetMediaServerSettings {
+ my ( $this, $newSettings ) = @_;
+ croak 'usage CGP::CLI->SetMediaServerSettings(\%newSettings)'
+ unless defined $newSettings;
+ $this->send ('SetMediaServerSettings '.$this->printWords($newSettings) );
+ $this->_parseResponse();
+}
+
+sub GetSessionSettings {
+ my ( $this ) = @_;
+ $this->send('GetSessionSettings');
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+sub SetSessionSettings {
+ my ( $this, $newSettings ) = @_;
+ croak 'usage CGP::CLI->SetSessionSettings(\%newSettings)'
+ unless defined $newSettings;
+ $this->send ('SetSessionSettings '.$this->printWords($newSettings) );
+ $this->_parseResponse();
+}
+
+
sub GetClusterSettings {
my ( $this ) = @_;
$this->send('GetClusterSettings');
@@ -2747,6 +3195,12 @@ sub GetProtection {
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
+sub GetNetwork {
+ my ( $this ) = @_;
+ $this->send('GetNetwork');
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
sub GetBanned {
my ( $this ) = @_;
@@ -2816,6 +3270,13 @@ sub SetProtection {
$this->send ('SetProtection '.$this->printWords($settings));
$this->_parseResponse();
}
+sub SetNetwork {
+ my ( $this, $settings ) = @_;
+ croak 'usage CGP::CLI->SetNetwork(\%settings)'
+ unless defined $settings;
+ $this->send ('SetNetwork '.$this->printWords($settings));
+ $this->_parseResponse();
+}
sub SetBanned {
my ( $this, $settings ) = @_;
@@ -2877,6 +3338,12 @@ sub GetClusterProtection {
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
+sub GetClusterNetwork {
+ my ( $this ) = @_;
+ $this->send('GetClusterNetwork');
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
sub GetClusterBanned {
my ( $this ) = @_;
$this->send('GetClusterBanned');
@@ -2944,6 +3411,13 @@ sub SetClusterProtection {
$this->send ('SetClusterProtection '.$this->printWords($settings));
$this->_parseResponse();
}
+sub SetClusterNetwork {
+ my ( $this, $settings ) = @_;
+ croak 'usage CGP::CLI->SetClusterNetwork(\%settings)'
+ unless defined $settings;
+ $this->send ('SetClusterNetwork '.$this->printWords($settings));
+ $this->_parseResponse();
+}
sub GetServerRules {
my $this = shift;
@@ -3172,6 +3646,19 @@ sub GetSNMPElement {
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
+sub GetStatElement {
+ my ($this, $element) = @_;
+ $this->send('GetStatElement '.$element);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+sub GetNextStatName {
+ my ($this, $element) = @_;
+ $this->send('GetNextStatName '.$element);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
sub GetDialogInfo {
my ($this, $dialogID) = @_;
$this->send('GetDialogInfo '.$dialogID);
@@ -3231,6 +3718,90 @@ sub ResetDomainStat {
}
#############################################
+# Directory Administration commands
+
+sub ListDirectoryUnits {
+ my ($this, $shared) = @_;
+ my $line = 'ListDirectoryUnits';
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub CreateDirectoryUnit {
+ my ($this, $unitName,$mountPoint,$shared,$remote) = @_;
+ croak 'usage CGP::CLI->CreateDirectoryUnit($unitName,$mountPoint,[$shared,[$remote]])'
+ unless defined $unitName && defined $mountPoint;
+ my $line = 'CreateDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $line .= ' REMOTE' if $remote;
+ $line .= ' '.$mountPoint;
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub RelocateDirectoryUnit {
+ my ($this, $unitName,$newMountPoint,$shared) = @_;
+ croak 'usage CGP::CLI->RelocateDirectoryUnit($unitName,$newMountPoint,[$shared])'
+ unless defined $unitName && defined $newMountPoint;
+ my $line = 'RelocateDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $line .= ' '.$newMountPoint;
+}
+
+sub DeleteDirectoryUnit {
+ my ($this, $unitName,$shared) = @_;
+ croak 'usage CGP::CLI->DeleteDirectoryUnit($unitName,[$shared])'
+ unless defined $unitName;
+ my $line = 'DeleteDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub GetDirectoryUnit {
+ my ($this, $unitName,$shared) = @_;
+ croak 'usage CGP::CLI->GetDirectoryUnit($unitName,[$shared])'
+ unless defined $unitName;
+ my $line = 'GetDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetDirectoryUnit {
+ my ($this, $unitName,$newSettings,$shared) = @_;
+ croak 'usage CGP::CLI->SetDirectoryUnit($unitName,$newSettings,[$shared])'
+ unless defined $unitName && defined $newSettings;
+ my $line = 'SetDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $line .= ' '.$this->printWords($newSettings);
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub GetDirectoryAccessRights {
+ my ($this, $shared) = @_;
+ my $line = 'GetDirectoryAccessRights';
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetDirectoryAccessRights {
+ my ($this, $unitName,$newRights,$shared) = @_;
+ croak 'usage CGP::CLI->SetDirectoryAccessRights($newRights,[$shared])'
+ unless defined $newRights;
+ my $line = 'SetDirectoryAccessRights';
+ $line .= ' SHARED' if $shared;
+ $line .= ' '.$this->printWords($newRights);
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+#############################################
# Miscellaneous commands
sub WriteLog {
@@ -3252,7 +3823,7 @@ sub RejectQueueMessage {
croak 'usage CGP::CLI->RejectQueueMessage($msgID [,$errorText])'
unless defined $msg;
my $line = 'RejectQueueMessage '.$msg;
- $line .= $this->printWords($text) if $text;
+ $line .= " ".$this->printWords($text) if $text;
$this->send($line);
$this->_parseResponse();
}
@@ -3292,14 +3863,6 @@ sub SetTempBlacklistedIPs {
$this->_parseResponse();
}
-sub RemoveAccountSubset {
- my ($this, $account, $subset) = @_;
- croak 'usage CGP::CLI->RemoveAccountSubset($account,$subset)'
- unless defined $account && defined $subset;
- $this->send('RemoveAccountSubset '.$account.' SUBSET '.$this->printWords($subset));
- return undef unless $this->_parseResponse();
-}
-
#########################################################################
#########################################################################
@@ -3455,8 +4018,7 @@ sub skipSpaces {
sub readWord {
my $this = shift;
- my $isQuoted=0;
- my $isBlock=0;
+ my ($isQuoted,$isBlock,$isUnkData)=(0,0,0);
my $result="";
$this->skipSpaces();
@@ -3464,6 +4026,10 @@ sub readWord {
$isQuoted=1; ++$this->{'span'};
} elsif(substr($this->{'data'},$this->{'span'},1) eq '[') {
$isBlock=1;
+ } elsif(substr($this->{'data'},$this->{'span'},2) eq '#(') {
+ $isUnkData=1;
+ $result='#(';
+ $this->{'span'}+=2;
}
while($this->{'span'} < $this->{'len'}) {
my $ch=substr($this->{'data'},$this->{'span'},1);
@@ -3501,6 +4067,13 @@ sub readWord {
}
}
+ } elsif($isUnkData) {
+ if($ch eq ')') {
+ $result .= $ch;
+ ++$this->{'span'};
+ $this->skipSpaces();
+ last;
+ }
} elsif($ch =~ /[-a-zA-Z0-9\x80-\xff_\.\@\!\#\%\:]/) {
} else {
last;
@@ -3518,6 +4091,56 @@ sub readKey() {
}
+sub readXML {
+ my $this = shift;
+ my $startSpan=$this->{'span'};
+ for(;;) {
+ $this->readXMLElem();
+ if(substr($this->{'data'},$this->{'span'},1) ne '<') {
+ last;
+ } else {
+ $this->{'span'}++;
+ }
+ }
+ return substr($this->{'data'},$startSpan-1,$this->{'span'}-$startSpan+1);
+}
+
+sub readXMLElem {
+ my $this = shift;
+
+ my $element=undef;
+ my $endPos=index($this->{'data'},'>',$this->{'span'});
+ if($endPos<$this->{'span'}-1) {
+ croak "XML parsing error:",substr($this->{'data'},$this->{'span'}-1,100);
+ }
+ if(substr($this->{'data'},$endPos-1,1) eq '/') { #
+ $this->{'span'}=$endPos+1;
+ return;
+ }
+ if(substr($this->{'data'},$this->{'span'},1)=~/[\!\?]/) { # {'span'}=$endPos+1;
+ return;
+ }
+ unless(substr($this->{'data'},$this->{'span'},$endPos - $this->{'span'}+1) =~/(.+?)[ \>]/) {
+ croak "XML reading error:",substr($this->{'data'},$this->{'span'}-1,100);
+ }
+ $element=$1;
+#print "endElement=$1\n";
+ $this->{'span'}=$endPos+1;
+#print "parsed=".substr($this->{'data'},$this->{'span'},10)."\n";
+ $this->{'span'}++ while($this->{'span'} < $this->{'len'} && substr($this->{'data'},$this->{'span'},1) ne '<');
+ while($this->{'span'} < $this->{'len'}) {
+ if(substr($this->{'data'},$this->{'span'},$this->{'len'} - $this->{'span'})=~/^\<\/$element\>/) { #found closing element
+ my $endPos=index($this->{'data'},'>',$this->{'span'}+1);
+ $this->{'span'}=$endPos+1;
+ return;
+ }
+ $this->{'span'}++;
+ $this->readXMLElem();
+ }
+}
+
+
sub readValue() {
my $this = shift;
$this->skipSpaces();
@@ -3528,6 +4151,9 @@ sub readValue() {
} elsif($ch eq '(') {
++$this->{'span'};
return $this->readArray();
+ } elsif($ch eq '<') {
+ ++$this->{'span'};
+ return $this->readXML();
} else {
return $this->readWord();
}
@@ -3565,7 +4191,7 @@ sub readDictionary {
++$this->{'span'};
last;
} else {
- my $theKey=$this->readKey();
+ my $theKey=$this->readKey();
$this->skipSpaces();
if(substr($this->{'data'},$this->{'span'},1) ne '=') { croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10); }
++$this->{'span'};
@@ -3587,6 +4213,7 @@ sub parseWords {
return $this->readValue();
}
+
1;
=pod