1 ####################################################################
2 # Perl interface to CommuniGate Pro CLI.
6 # Original location: <http://www.communigate.com/CGPerl/>
7 # Revision history: <http://www.communigate.com/CGPerl/History.html>
9 # See <http://www.communigate.com/CommuniGatePro/CLI.html> for the related info.
11 # Mail your comments and error reports to <support@stalker.com>
13 ############################## Commands:
20 # setStringsTranslateMode
25 ############################## Accounts commands
32 # GetAccountEffectiveSettings
33 # UpdateAccountSettings
36 # VerifyAccountPassword
39 # [Get|Set]AccountTelnums
40 # [Get|Set]AccountRules
41 # [Get|Set]Account[Mail|Signal]Rules
42 # UpdateAccount[Mail|Signal]Rule
43 # [Get|Set]Account[RPOPs|SIPs];
48 # [Get|Set|Update]AccountPrefs
49 # GetAccountEffectivePrefs
54 ############################## Group Commands
62 ############################## Forwarder Commands
70 ############################## Named Tasks
71 # List[Domain|Account]NamedTasks
72 # [Create|Rename|Delete]NamedTask
73 # [Get|Update]NamedTask
76 ############################## Domain commands
79 # [Get|Update|Set]DomainSettings
80 # GetDomainEffectiveSettings
81 # [Create|Rename|Delete]Domain
82 # [Suspend|Resume]Domain
84 # CreateDirectoryDomain
85 # [Get|Set]DomainRules
86 # [Get|Set]DomainAliases
88 # [Insert|Delete]DirectoryRecords
89 # [Get|Set][Server|Cluster]TrustedCerts
91 # [Get|Set]DirectoryIntegration
92 # [Get|Set]ClusterDirectoryIntegration
95 # [Get|Update|Set]DomainDefaults
96 # [Get|Update|Set]ClusterDomainDefaults
97 # [Get|Update|Set]AllAccountsDefaults *
98 # [Get|Update|Set]ServerAccountsDefaults
101 # [Get|Update|Set]AccountDefaults
102 # [Get|Update|Set]ClusterAccountDefaults
103 # [Get|Set|Update]AccountDefaultPrefs
104 # [Get|Set|Update][Server|Cluster]AccountPrefs
105 # [Get|Update|Set]AccountTemplate
107 ############################## Mailbox Administration
109 # [Create|Rename|Delete]Mailbox
110 # [Rename|Delete]Mailboxes
112 # [Get|Set]MailboxACL
116 # [Get|Set]AccountSubscription *
117 # [Get|Set]MailboxSubscription
118 # [Get|Set]MailboxAliases
120 ############################## Alerts Administration
121 # Get[Domain|Account|Server|Cluster]Alerts
122 # Set[Domain|Account|Server|Cluster]Alerts
123 # Post[Domain|Account|Server|Cluster]Alert
124 # Remove[Domain|Account|Server|Cluster]Alert
126 ############################## Personal Web Site Administration
134 # [Read|Write|Rename|Delete]StorageFile
137 # [Read|Update]StorageFileAttr
138 # [Get|Set]FileSubscription
140 ############################## Lists commands
144 # [Create|Rename|Delete|Get|Update]List
151 ############################## Web Skins Administration
152 # ListDomainSkins( [domainName] )
153 # CreateDomainSkin(domainName,skinName)
154 # RenameDomainSkin(domainName,oldSkinName,newSkinName)
155 # DeleteDomainSkin(domainName,skinName)
156 # ListDomainSkinFiles(domainName,skinName)
157 # ReadDomainSkinFile(domainName,skinName,fileName)
158 # StoreDomainSkinFile(domainName,skinName,fileName,base64data)
159 # DeleteDomainSkinFile(domainName,skinName,fileName)
162 # CreateServerSkin(skinName)
163 # RenameServerSkin(oldSkinName,newSkinName)
164 # DeleteServerSkin(skinName)
165 # ListServerSkinFiles(skinName)
166 # ReadServerSkinFile(skinName,fileName)
167 # StoreServerSkinFile(skinName,fileName,base64data)
168 # DeleteServerSkinFile(skinName,fileName)
171 # CreateClusterSkin(skinName)
172 # RenameClusterSkin(oldSkinName,newSkinName)
173 # DeleteClusterSkin(skinName)
174 # ListClusterSkinFiles(skinName)
175 # ReadClusterSkinFile(skinName,fileName)
176 # StoreClusterSkinFile(skinName,fileName,base64data)
177 # DeleteClusterSkinFile(skinName,fileName)
179 ############################## Web Interface Tuning
180 # [List|Get|Put|Delete]WebUserInterface
183 ############################## Web Interface Integration
184 # [Create|Get|Kill|Find]WebUserSession
189 ############################## Real-Time Application Administration
190 # Create[Domain|Server|Cluster]PBX
191 # List[Domain|Server|Cluster]PBXFiles
192 # [Read|Store|Delete][Domain|Server|Cluster]PBXFile
194 ############################## Real-Time Application Control
200 ############################## Account Services
201 # RemoveAccountSubset
205 ############################## Server commands
206 # [Get|Update|Set]Module
207 # [Get|Set][Queue|Signal|Session|Cluster|MediaServer]Settings
209 # [Get|Set]BlacklistedIPs
211 # [Get|Set]WhiteHoleIPs
212 # [Get|Set]Protection
215 # [Get|Set]ClusterLANIPs
216 # [Get|Set]ClusterBlacklistedIPs
217 # [Get|Set]ClusterClientIPs
218 # [Get|Set]ClusterWhiteHoleIPs
219 # [Get|Set]ClusterProtection
222 # [Get|Set][Server|Cluster]Rules
223 # [Get|Set][Server|Cluster][Mail|Signal]Rules
224 ## Update[Server|Cluster][Mail|Signal]Rule
227 # [Get|Set]RouterTable
228 # [Get|Set]RouterSettings
229 # [Get|Set]ClusterRouterTable
230 # [Get|Set][Server|Cluster]Intercept
234 ############################## Monitoring commands
235 # GetSNMPElement-GetStateElement
239 ############################## Statistics commands
240 # [Get|Reset]AccountStat
241 # [Get|Reset]DomainStat
243 ############################## Miscellaneous commands
247 # GetMessageQueueInfo
248 # GetCurrentController
250 # [Get|Set]TempBlacklistedIPs
251 # List[Domain|Server|Cluster]Telnums
253 ##############################################################
260 # You may need to change this to "use IO::Socket::INET;" if you have INET.pm
263 # You may need to install this module.
264 # See <http://search.cpan.org/search?module=Digest::MD5>
267 use vars qw($VERSION);
271 $CGP::SECURE_LOGIN = 1;
272 $CGP::WEBUSER_LOGIN = 0;
273 $CGP::TIMEOUT = 60*5-5; # 5 minutes timeout
275 $CGP::ERR_STRING = "No error";
277 $CGP::CLI_CODE_OK = 200;
278 $CGP::CLI_CODE_OK_INLINE = 201;
280 $CGP::CLI_CODE_PASSWORD = 300;
281 $CGP::CLI_CODE_UNKNOW_USER = 500;
282 $CGP::CLI_CODE_GEN_ERR = 501;
283 $CGP::CLI_CODE_STRANGE = 10000;
290 $this->{isConnected}=0;
292 delete $this->{theSocket} if(exists($this->{theSocket}));
294 $this->{theSocket} = new IO::Socket::INET( %{$this->{connParams}} );
296 unless(defined $this->{theSocket} && $this->{theSocket}) {
297 $CGP::ERR_STRING="Can't open connection to CGPro Server";
300 $this->{theSocket}->autoflush(1);
302 unless($this->_parseResponse()) {
303 $CGP::ERR_STRING="Can't read CGPro Server prompt";
307 if($this->{isSecureLogin} && $this->{errMsg} =~ /(\<.*\@.*\>)/) {
308 my $md5=Digest::MD5->new;
310 $md5->add($1.$this->{password});
311 $this->send('APOP '.$this->{login}.' '.$md5->hexdigest);
312 $this->_parseResponse();
314 $CGP::ERR_STRING="Can't create MD5 object";
315 close($this->{theSocket});
318 } elsif($this->{isWebUserLogin}) {
319 $this->send('AUTH WEBUSER '.$this->{login}.' '.$this->{password});
320 $this->_parseResponse();
323 $this->send('USER '.$this->{login});
324 $this->_parseResponse();
325 unless( $this->{errCode} == $CGP::CLI_CODE_PASSWORD) {
326 $CGP::ERR_STRING="Unexpected answer: ".$this->{errCode};
327 close($this->{theSocket});
330 $this->send('PASS '.$this->{password});
331 $this->_parseResponse();
334 unless($this->isSuccess) {
335 $CGP::ERR_STRING=$this->{errMsg};
336 close($this->{theSocket});
339 $this->send('INLINE');
340 $this->_parseResponse();
341 $this->setStringsTranslateMode(0);
342 $this->{isConnected}=1;
348 my ($class, $params) = @_;
351 $this->{login} = delete $params->{'login'};
352 $this->{password} = delete $params->{'password'};
354 $this->{isSecureLogin} = delete $params->{'SecureLogin'};
355 $this->{isWebUserLogin} = delete $params->{'WebUserLogin'};
358 $this->{isSecureLogin} = $CGP::SECURE_LOGIN unless defined $this->{isSecureLogin};
359 $this->{isWebUserLogin} = $CGP::WEBUSER_LOGIN unless defined $this->{isWebUserLogin};
362 croak 'You must pass login parameter to CGP::CLI::new'
363 unless defined $this->{login};
364 croak 'You must pass password parameter to CGP::CLI::new'
365 unless defined $this->{password};
367 croak 'SecureLogin and WebUserLogin are mutually exclusive'
368 if($this->{isSecureLogin} && $this->{isWebUserLogin});
372 $this->{connParams}=$params;
374 if(!(defined $params->{'connectNow'}) || $params->{'connectNow'}) {
375 unless($this->connect()) {
384 $this->Logout() if($this->{isConnected});
389 return $this->{errCode};
394 return $this->{errMsg};
399 return $this->{'currentCGateCommand'};
404 return ($this->{errCode} == $CGP::CLI_CODE_OK || $this->{errCode} == $CGP::CLI_CODE_OK_INLINE);
408 my ($this, $debugFlag) = @_;
409 $this->{'debug'} = $debugFlag;
412 sub setStringsTranslateMode {
413 my ($this, $onFlag) = @_;
414 $this->{'translateStrings'} = $onFlag;
420 $this->_parseResponse();
421 $this->{isConnected}=0;
425 my ($this, $newPassword) = @_;
426 croak 'usage CGP::CLI->NewPassword($newPassword)'
427 unless defined $newPassword;
428 $this->send('NEWPASS '.$newPassword);
429 $this->_parseResponse();
433 my ($this, $command) = @_;
434 croak 'usage CGP::CLI->SendCommand($commandString)'
435 unless defined $command;
436 $this->send($command);
437 $this->_parseResponse();
440 sub GetResponseData {
442 $this->parseWords($this->getWords);
446 ####################################################################
449 sub ListDomainObjects {
450 my ($this, $domainName,$limit,$filter,$what,$cookie) = @_;
451 croak 'usage CGP::CLI->ListDomainObjects($domainName,$limit[,$filter][,$what][,$cookie])'
452 unless defined $domainName && defined $limit;
453 my $line = "ListDomainObjects $domainName";
454 $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
456 $line .= " $what" if $what;
457 $line .= " COOKIE ".$this->printWords($cookie) if defined $cookie;
459 return undef unless $this->_parseResponse();
460 $this->parseWords($this->getWords);
465 my ($this, $domainName) = @_;
466 my $line = 'ListAccounts';
467 $line .= ' '.$domainName if $domainName;
469 return undef unless $this->_parseResponse();
470 $this->parseWords($this->getWords);
473 sub ListDomainTelnums {
474 my ($this, $domainName,$limit,$filter) = @_;
475 croak 'usage CGP::CLI->ListDomainTelnums($domainName,$limit[,$filter])'
476 unless defined $domainName && defined $limit;
477 my $line = "ListDomainTelnums $domainName";
478 $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
481 return undef unless $this->_parseResponse();
482 $this->parseWords($this->getWords);
491 croak 'usage CGP::CLI->CreateAccount(accountName => \'newAccountName\',
492 accountType => \'accountType\',
493 externalFlag => \'externalFlag\',
494 settings => $settings)'
495 unless exists $params{accountName};
496 my $line = 'CreateAccount '.$params{accountName};
497 $line .= ' ' . $params{accountType} if exists $params{accountType};
498 $line .= ' ' . 'external' if exists $params{externalFlag};
499 $line .= ' ' . $this->printWords($params{settings}) if exists $params{settings};
502 $this->_parseResponse();
506 my ($this, $oldAccountName, $newAccountName) = @_;
507 croak 'usage CGP::CLI->RenameAccount($oldAccountName, $newAccountName)'
508 unless defined $oldAccountName && defined $newAccountName;
509 $this->send('RenameAccount '.$oldAccountName.' into '.$newAccountName);
510 $this->_parseResponse();
514 my ($this, $accountName) = @_;
515 croak 'usage CGP::CLI->DeleteAccount($accountName)'
516 unless defined $accountName;
517 $this->send('DeleteAccount '.$accountName);
518 $this->_parseResponse();
521 my ($this, $accountName,$type) = @_;
522 croak 'usage CGP::CLI->SetAccountType($accountName,$type)'
523 unless (defined $accountName && defined $type);
524 $this->send('SetAccountType '.$accountName.' '.$type);
525 $this->_parseResponse();
528 sub GetAccountSettings {
529 my ($this, $accountName) = @_;
530 croak 'usage CGP::CLI->GetAccountSettings($accountName)'
531 unless defined $accountName;
532 $this->send('GetAccountSettings '.$accountName);
533 return undef unless $this->_parseResponse();
534 $this->parseWords($this->getWords);
538 GetAccountSettings(@_);
541 sub GetAccountEffectiveSettings {
542 my ($this, $accountName) = @_;
543 croak 'usage CGP::CLI->GetAccountEffectiveSettings($accountName)'
544 unless defined $accountName;
545 $this->send('GetAccountEffectiveSettings '.$accountName);
546 return undef unless $this->_parseResponse();
547 $this->parseWords($this->getWords);
550 sub UpdateAccountSettings {
551 my ($this, $accountName, $params) = @_;
552 croak 'usage CGP::CLI->UpdateAccountSettings($accountName, \%settings)'
553 unless defined $accountName;
554 $this->send('UpdateAccountSettings '.$accountName.' '.$this->printWords($params));
555 $this->_parseResponse();
559 UpdateAccountSettings(@_);
562 sub SetAccountSettings {
563 my ($this, $accountName, $params) = @_;
564 croak 'usage CGP::CLI->SetAccountSettings($accountName, \%settings)'
565 unless defined $accountName;
566 $this->send('SetAccountSettings '.$accountName.' '.$this->printWords($params));
567 $this->_parseResponse();
571 SetAccountSettings(@_);
574 sub SetAccountPassword {
575 my ($this, $accountName, $newPass) = @_;
576 croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword)'
577 unless defined $accountName && defined $newPass;
578 $this->send('SetAccountPassword '.$accountName.' TO '.$this->printWords($newPass));
579 $this->_parseResponse();
582 sub VerifyAccountPassword {
583 my ($this, $accountName, $pass) = @_;
584 croak 'usage CGP::CLI->VerifyAccountPassword($accountName, $password)'
585 unless defined $accountName && defined $pass;
586 $this->send('VerifyAccountPassword '.$accountName.' PASSWORD '.$this->printWords($pass));
587 $this->_parseResponse();
591 sub GetAccountAliases {
592 my ($this, $accountName) = @_;
593 croak 'usage CGP::CLI->GetAccountAliases($accountName)'
594 unless defined $accountName;
595 $this->send('GetAccountAliases '.$accountName);
596 return undef unless $this->_parseResponse();
597 $this->parseWords($this->getWords);
600 sub SetAccountAliases {
601 my ($this, $accountName, $aliases) = @_;
602 croak 'usage CGP::CLI->SetAccountAliases($accountName, \@aliases)'
603 unless defined $accountName && defined $aliases;
604 $this->send('SetAccountAliases '.$accountName.' '.$this->printWords($aliases));
605 $this->_parseResponse();
608 sub GetAccountTelnums {
609 my ($this, $accountName) = @_;
610 croak 'usage CGP::CLI->GetAccountTelnums($accountName)'
611 unless defined $accountName;
612 $this->send('GetAccountTelnums '.$accountName);
613 return undef unless $this->_parseResponse();
614 $this->parseWords($this->getWords);
617 sub SetAccountTelnums {
618 my ($this, $accountName, $aliases) = @_;
619 croak 'usage CGP::CLI->SetAccountTelnums($accountName, \@telnums)'
620 unless defined $accountName && defined $aliases;
621 $this->send('SetAccountTelnums '.$accountName.' '.$this->printWords($aliases));
622 $this->_parseResponse();
626 sub GetAccountRules {
627 my ($this, $accountName) = @_;
628 croak 'usage CGP::CLI->GetAccountRules($accountName)'
629 unless defined $accountName;
630 $this->send('GetAccountRules '.$accountName);
631 return undef unless $this->_parseResponse();
632 $this->parseWords($this->getWords);
635 sub SetAccountRules {
636 my ($this, $accountName, $rules) = @_;
637 croak 'usage CGP::CLI->SetAccountRules($accountName, \@rules)'
638 unless defined $accountName && defined $rules;
639 $this->send('SetAccountRules '.$accountName.' '.$this->printWords($rules));
640 $this->_parseResponse();
643 sub GetAccountMailRules {
644 my ($this, $accountName) = @_;
645 croak 'usage CGP::CLI->GetAccountMailRules($accountName)'
646 unless defined $accountName;
647 $this->send('GetAccountMailRules '.$accountName);
648 return undef unless $this->_parseResponse();
649 $this->parseWords($this->getWords);
652 sub SetAccountMailRules {
653 my ($this, $accountName, $rules) = @_;
654 croak 'usage CGP::CLI->SetAccountMailRules($accountName, \@rules)'
655 unless defined $accountName && defined $rules;
656 $this->send('SetAccountMailRules '.$accountName.' '.$this->printWords($rules));
657 $this->_parseResponse();
659 sub UpdateAccountMailRule {
660 my ($this, $accountName, $rule) = @_;
661 croak 'usage CGP::CLI->UpdateAccountMailRule($accountName, \@rule)'
662 unless defined $accountName && defined $rule;
663 $this->send('UpdateAccountMailRule '.$accountName.' '.$this->printWords($rule));
664 $this->_parseResponse();
667 sub GetAccountSignalRules {
668 my ($this, $accountName) = @_;
669 croak 'usage CGP::CLI->GetAccountSignalRules($accountName)'
670 unless defined $accountName;
671 $this->send('GetAccountSignalRules '.$accountName);
672 return undef unless $this->_parseResponse();
673 $this->parseWords($this->getWords);
676 sub SetAccountSignalRules {
677 my ($this, $accountName, $rules) = @_;
678 croak 'usage CGP::CLI->SetAccountSignalRules($accountName, \@rules)'
679 unless defined $accountName && defined $rules;
680 $this->send('SetAccountSignalRules '.$accountName.' '.$this->printWords($rules));
681 $this->_parseResponse();
683 sub UpdateAccountSignalRule {
684 my ($this, $accountName, $rule) = @_;
685 croak 'usage CGP::CLI->UpdateAccountSignalRule($accountName, \@rule)'
686 unless defined $accountName && defined $rule;
687 $this->send('UpdateAccountSignalRule '.$accountName.' '.$this->printWords($rule));
688 $this->_parseResponse();
691 sub GetAccountRPOPs {
692 my ($this, $accountName) = @_;
693 croak 'usage CGP::CLI->GetAccountRPOPs($accountName)'
694 unless defined $accountName;
695 $this->send('GetAccountRPOPs '.$accountName);
696 return undef unless $this->_parseResponse();
697 $this->parseWords($this->getWords);
700 sub SetAccountRPOPs {
701 my ($this, $accountName, $newRecords) = @_;
702 croak 'usage CGP::CLI->SetAccountRPOPs($accountName, \@newRecords)'
703 unless defined $accountName && defined $newRecords;
704 $this->send('SetAccountRPOPs '.$accountName.' '.$this->printWords($newRecords));
705 $this->_parseResponse();
708 sub GetAccountRSIPs {
709 my ($this, $accountName) = @_;
710 croak 'usage CGP::CLI->GetAccountRSIPs($accountName)'
711 unless defined $accountName;
712 $this->send('GetAccountRSIPs '.$accountName);
713 return undef unless $this->_parseResponse();
714 $this->parseWords($this->getWords);
717 sub SetAccountRSIPs {
718 my ($this, $accountName, $newRecords) = @_;
719 croak 'usage CGP::CLI->SetAccountRPSIs($accountName, \@newRecords)'
720 unless defined $accountName && defined $newRecords;
721 $this->send('SetAccountRSIPs '.$accountName.' '.$this->printWords($newRecords));
722 $this->_parseResponse();
726 my ($this, $accountName) = @_;
727 croak 'usage CGP::CLI->GetAccountRPOP($accountName)'
728 unless defined $accountName;
729 $this->send('GetAccountRPOP '.$accountName);
730 return undef unless $this->_parseResponse();
731 $this->parseWords($this->getWords);
735 my ($this, $accountName, $newRecords) = @_;
736 croak 'usage CGP::CLI->SetAccountRPOP($accountName, \@newRecords)'
737 unless defined $accountName && defined $newRecords;
738 $this->send('SetAccountRPOP '.$accountName.' '.$this->printWords($newRecords));
739 $this->_parseResponse();
742 sub GetAccountRights {
743 my ($this, $account) = @_;
744 croak 'usage CGP::CLI->GetAccountRights($account)'
745 unless defined $account;
746 $this->send('GetAccountRights '.$account);
747 return undef unless $this->_parseResponse();
748 $this->parseWords($this->getWords);
751 sub SetAccountRights {
752 my ($this, $account, $list) = @_;
753 croak 'usage CGP::CLI->SetAccountRigthts($acount, \@list)'
754 unless defined $account && defined $list;
755 my $line = 'SetAccountRights '.$account.' '.$this->printWords($list);
758 $this->_parseResponse();
762 my ($this, $account, $key) = @_;
763 croak 'usage CGP::CLI->GetAccountInfo($account[,$key | ($key1,...)])'
764 unless defined $account;
765 my $line='GetAccountInfo '.$account;
767 if(ref($key) eq 'ARRAY') {
768 $line.=' '.$this->printWords($key);
770 $line.=' Key '.$this->printWords($key);
774 return undef unless $this->_parseResponse();
775 $this->parseWords($this->getWords);
779 my ($this, $account) = @_;
780 croak 'usage CGP::CLI->GetWebUser($account)'
781 unless defined $account;
782 $this->send('GetWebUser '.$account);
783 return undef unless $this->_parseResponse();
784 $this->parseWords($this->getWords);
788 sub GetAccountPrefs {
789 my ($this, $account) = @_;
790 croak 'usage CGP::CLI->GetAccountPrefs($account)'
791 unless defined $account;
792 $this->send('GetAccountPrefs '.$account);
793 return undef unless $this->_parseResponse();
794 $this->parseWords($this->getWords);
798 my ($this, $account, $settings) = @_;
799 croak 'usage CGP::CLI->SetWebUser($acount, \%settings)'
800 unless defined $account && defined $settings;
801 my $line = 'SetWebUser '.$account.' '.$this->printWords($settings);
804 $this->_parseResponse();
807 sub SetAccountPrefs {
808 my ($this, $account, $settings) = @_;
809 croak 'usage CGP::CLI->SetAccountPrefs($acount, \%settings)'
810 unless defined $account && defined $settings;
811 my $line = 'SetAccountPrefs '.$account.' '.$this->printWords($settings);
814 $this->_parseResponse();
816 sub UpdateAccountPrefs {
817 my ($this, $account, $settings) = @_;
818 croak 'usage CGP::CLI->UpdateAccountPrefs($acount, \%settings)'
819 unless defined $account && defined $settings;
820 my $line = 'UpdateAccountPrefs '.$account.' '.$this->printWords($settings);
823 $this->_parseResponse();
827 sub GetEffectiveWebUser {
828 my ($this, $account) = @_;
829 croak 'usage CGP::CLI->GetEffectiveWebUser($account)'
830 unless defined $account;
831 $this->send('GetEffectiveWebUser '.$account);
832 return undef unless $this->_parseResponse();
833 $this->parseWords($this->getWords);
836 sub GetAccountEffectivePrefs {
837 my ($this, $account) = @_;
838 croak 'usage CGP::CLI->GetAccountEffectivePrefs($account)'
839 unless defined $account;
840 $this->send('GetAccountEffectivePrefs '.$account);
841 return undef unless $this->_parseResponse();
842 $this->parseWords($this->getWords);
846 sub KillAccountSessions {
847 my ($this, $account) = @_;
848 croak 'usage CGP::CLI->KillAccountSessions($account)'
849 unless defined $account;
850 $this->send('KillAccountSessions '.$account);
851 $this->_parseResponse();
855 my ($this, $account,$authAccountName) = @_;
856 croak 'usage CGP::CLI->GetAccountACL($accountName [,authAccountName])'
857 unless defined $account;
859 my $line = 'GetAccountACL '.$account;
860 $line .= ' AUTH '.$authAccountName if($authAccountName);
862 return undef unless $this->_parseResponse();
863 $this->parseWords($this->getWords);
867 my ($this, $account, $newACL,$authAccountName) = @_;
868 croak 'usage CGP::CLI->SetAccountACL($acountACL, \%newACL [,$authAccountName])'
869 unless defined $account && defined $newACL;
870 my $line = 'SetAccountACL '.$account;
871 $line .= ' AUTH '.$authAccountName if($authAccountName);
872 $line.=' '.$this->printWords($newACL);
874 $this->_parseResponse();
877 sub GetAccountACLRights {
878 my ($this, $account,$authAccountName) = @_;
879 croak 'usage CGP::CLI->GetAccountACLRights($accountName ,authAccountName)'
880 unless (defined $account && defined $authAccountName);
882 my $line = 'GetAccountACLRights '.$account.' AUTH '.$authAccountName ;
884 return undef unless $this->_parseResponse();
885 $this->parseWords($this->getWords);
887 sub GetAccountPresence {
888 my ($this, $account) = @_;
889 croak 'usage CGP::CLI->GetAccountPresence($accountName)'
890 unless (defined $account);
892 my $line = 'GetAccountPresence '.$account;
894 return undef unless $this->_parseResponse();
895 $this->parseWords($this->getWords);
897 #################################################################
898 # Group managent commands
901 my ($this, $domainName) = @_;
902 my $line = 'ListGroups';
903 $line .= ' '.$domainName if $domainName;
905 return undef unless $this->_parseResponse();
906 $this->parseWords($this->getWords);
910 my ($this, $groupName, $params) = @_;
911 croak 'usage CGP::CLI->CreateGroup($groupName[, \%params])'
912 unless defined $groupName;
913 my $line = 'CreateGroup '.$groupName;
914 $line .= ' '.$this->printWords($params) if $params;
916 $this->_parseResponse();
920 my ($this, $oldGroupName, $newGroupName) = @_;
921 croak 'usage CGP::CLI->RenameGroup($oldGroupName, $newGroupName)'
922 unless defined $oldGroupName && defined $newGroupName;
923 $this->send('RenameGroup '.$oldGroupName.' into '.$newGroupName);
924 $this->_parseResponse();
928 my ($this, $groupName) = @_;
929 croak 'usage CGP::CLI->DeleteGroup($groupName)'
930 unless defined $groupName;
931 $this->send('DeleteGroup '.$groupName);
932 $this->_parseResponse();
936 my ($this, $groupName) = @_;
937 croak 'usage CGP::CLI->GetGroup($groupName)'
938 unless defined $groupName;
939 $this->send('GetGroup '.$groupName);
940 return undef unless $this->_parseResponse();
941 $this->parseWords($this->getWords);
945 my ($this, $groupName, $params) = @_;
946 croak 'usage CGP::CLI->SetGroup($groupName, \%settings)'
947 unless defined $groupName && defined $params;
948 $this->send('SetGroup '.$groupName.' '.$this->printWords($params));
949 $this->_parseResponse();
953 #################################################################
954 # Forwarder managent commands
957 my ($this, $domainName) = @_;
958 my $line = 'ListForwarders';
959 $line .= ' ' .$domainName if $domainName;
961 return undef unless $this->_parseResponse();
962 $this->parseWords($this->getWords);
965 sub CreateForwarder {
966 my ($this, $forwarderName, $address) = @_;
967 croak 'usage CGP::CLI->CreateForwarder($forwarderName, $address)'
968 unless defined $forwarderName && defined $address;
969 $this->send('CreateForwarder '.$forwarderName.' TO '.$this->printWords($address));
970 $this->_parseResponse();
972 sub RenameForwarder {
973 my ($this, $forwarderName, $newName) = @_;
974 croak 'usage CGP::CLI->RenameForwarder($forwarderName, $newName)'
975 unless defined $forwarderName && defined $newName;
976 $this->send('RenameForwarder '.$forwarderName.' into '.$newName);
977 $this->_parseResponse();
980 sub DeleteForwarder {
981 my ($this, $forwarderName) = @_;
982 croak 'usage CGP::CLI->DeleteForwarder($forwarderName)'
983 unless defined $forwarderName;
984 $this->send('DeleteForwarder '.$forwarderName);
985 $this->_parseResponse();
989 my ($this, $forwarderName) = @_;
990 croak 'usage CGP::CLI->GetForwarder($forwarderName)'
991 unless defined $forwarderName;
992 $this->send('GetForwarder '.$forwarderName);
993 return undef unless $this->_parseResponse();
994 $this->parseWords($this->getWords);
997 my ($this, $domain,$forwarderAddress) = @_;
998 croak 'usage CGP::CLI->FindForwarders($domainName,$forwarderAddress)'
999 unless (defined $domain && defined $forwarderAddress);
1000 $this->send('FindForwarders '.$domain.' TO '.$this->printWords($forwarderAddress));
1001 return undef unless $this->_parseResponse();
1002 $this->parseWords($this->getWords);
1005 #################################################################
1006 # Named Tasks managent commands
1008 sub ListDomainNamedTasks {
1009 my ($this, $domainName) = @_;
1010 my $line = 'ListDomainNamedTasks';
1011 $line .= ' ' .$domainName if $domainName;
1013 return undef unless $this->_parseResponse();
1014 $this->parseWords($this->getWords);
1016 sub ListAccountNamedTasks {
1017 my ($this, $accountName) = @_;
1018 croak 'usage CGP::CLI->ListAccountNamedTasks($account)'
1019 unless defined $accountName;
1020 $this->send('ListAccountNamedTasks '.$accountName);
1021 return undef unless $this->_parseResponse();
1022 $this->parseWords($this->getWords);
1025 sub CreateNamedTask {
1026 my ($this, $taskName, $account) = @_;
1027 croak 'usage CGP::CLI->CreateNamedTask($taskName, $accountName)'
1028 unless defined $taskName && defined $account;
1029 $this->send('CreateNamedTask '.$taskName.' FOR '.$account);
1030 $this->_parseResponse();
1032 sub RenameNamedTask {
1033 my ($this, $taskName, $newName) = @_;
1034 croak 'usage CGP::CLI->RenameNamedTask($taskName, $newName)'
1035 unless defined $taskName && defined $newName;
1036 $this->send('RenameNamedTask '.$taskName.' into '.$newName);
1037 $this->_parseResponse();
1040 sub DeleteNamedTask {
1041 my ($this, $taskName) = @_;
1042 croak 'usage CGP::CLI->DeleteNamedTask($taskName)'
1043 unless defined $taskName;
1044 $this->send('DeleteNamedTask '.$taskName);
1045 $this->_parseResponse();
1049 my ($this, $taskName) = @_;
1050 croak 'usage CGP::CLI->GetNamedTask($taskName)'
1051 unless defined $taskName;
1052 $this->send('GetNamedTask '.$taskName);
1053 return undef unless $this->_parseResponse();
1054 $this->parseWords($this->getWords);
1057 sub UpdateNamedTask {
1058 my ($this, $taskName, $settings) = @_;
1059 croak 'usage CGP::CLI->UpdateNamedTask($taskName, \%settings)'
1060 unless defined $taskName && defined $settings;
1061 my $line = 'UpdateNamedTask '.$taskName.' '.$this->printWords($settings);
1063 $this->_parseResponse();
1066 #################################################################
1067 # Domain managent commands
1071 $this->send('ListDomains');
1072 return undef unless $this->_parseResponse();
1073 $this->parseWords($this->getWords);
1076 sub MainDomainName {
1078 $this->send('MainDomainName');
1079 return undef unless $this->_parseResponse();
1080 $this->parseWords($this->getWords);
1083 sub GetDomainSettings {
1084 my ($this, $domainName) = @_;
1086 my $line = 'GetDomainSettings';
1087 $line .= ' '.$domainName if($domainName);
1090 return undef unless $this->_parseResponse();
1091 $this->parseWords($this->getWords);
1095 GetDomainSettings(@_);
1098 sub GetDomainEffectiveSettings {
1099 my ($this, $domainName) = @_;
1100 my $line = 'GetDomainEffectiveSettings';
1101 $line .= ' '.$domainName if($domainName);
1103 return undef unless $this->_parseResponse();
1104 $this->parseWords($this->getWords);
1107 sub UpdateDomainSettings {
1111 croak 'usage CGP::CLI->UpdateDomainSettings(domain => \'domainName\',settings => {settings})'
1112 unless exists $params{settings};
1114 my $line = 'UpdateDomainSettings';
1115 $line .= ' '.$params{domain} if exists $params{domain};
1116 $this->send($line.' '.$this->printWords($params{settings}));
1117 $this->_parseResponse();
1121 UpdateDomainSettings(@_);
1124 sub SetDomainSettings {
1128 croak 'usage CGP::CLI->SetDomainSettings(domain => \'domainName\',settings => {settings})'
1129 unless exists $params{settings};
1131 my $line = 'SetDomainSettings';
1132 $line .= ' '.$params{domain} if exists $params{domain};
1133 $this->send($line.' '.$this->printWords($params{settings}));
1134 $this->_parseResponse();
1138 SetDomainSettings(@_);
1143 my ($this, $domainName, $params) = @_;
1144 croak 'usage CGP::CLI->CreateDomain($domainName[, \%params])'
1145 unless defined $domainName;
1146 my $line = 'CreateDomain '.$domainName;
1147 $line .= ' '.$this->printWords($params) if $params;
1149 $this->_parseResponse();
1153 my ($this, $oldDomainName, $newDomainName) = @_;
1154 croak 'usage CGP::CLI->RenameDomain($oldDomainName, $newDomainName)'
1155 unless defined $oldDomainName && defined $newDomainName;
1156 $this->send('RenameDomain '.$oldDomainName.' into '.$newDomainName );
1157 $this->_parseResponse();
1161 my ($this, $domainName, $force) = @_;
1162 croak 'usage CGP::CLI->DeleteDomain($domainName[, $force])'
1163 unless defined $domainName;
1164 my $line = 'DeleteDomain '.$domainName;
1165 $line .= ' force' if $force;
1167 $this->_parseResponse();
1171 my ($this, $domainName) = @_;
1172 croak 'usage CGP::CLI->SuspendDomain($domainName)'
1173 unless defined $domainName;
1174 $this->send('SuspendDomain '.$domainName);
1175 $this->_parseResponse();
1178 my ($this, $domainName) = @_;
1179 croak 'usage CGP::CLI->ResumeDomain($domainName)'
1180 unless defined $domainName;
1181 $this->send('ResumeDomain '.$domainName);
1182 $this->_parseResponse();
1185 sub CreateSharedDomain {
1186 my ($this, $domainName, $params) = @_;
1187 croak 'usage CGP::CLI->CreateSharedDomain($domainName[, \%params])'
1188 unless defined $domainName;
1189 my $line = 'CreateSharedDomain '.$domainName;
1190 $line .= ' '.$this->printWords($params) if $params;
1192 $this->_parseResponse();
1195 sub CreateDirectoryDomain {
1196 my ($this, $domainName, $params) = @_;
1197 croak 'usage CGP::CLI->CreateDirectoryDomain($domainName[, \%params])'
1198 unless defined $domainName;
1199 my $line = 'CreateDirectoryDomain '.$domainName;
1200 $line .= ' '.$this->printWords($params) if $params;
1202 $this->_parseResponse();
1205 sub ReloadDirectoryDomains {
1207 $this->send('ReloadDirectoryDomains');
1208 $this->_parseResponse();
1211 sub GetDomainRules {
1212 my ($this, $domainName) = @_;
1213 croak 'usage CGP::CLI->GetDomainRules($domainName)'
1214 unless defined $domainName;
1215 $this->send('GetDomainRules '.$domainName);
1216 return undef unless $this->_parseResponse();
1217 $this->parseWords($this->getWords);
1220 sub SetDomainRules {
1221 my ($this, $domainName, $rules) = @_;
1222 croak 'usage CGP::CLI->SetDomainRules($domainName, \@rules)'
1223 unless defined $domainName && defined $rules;
1224 $this->send('SetDomainRules '.$domainName.' '.$this->printWords($rules));
1225 $this->_parseResponse();
1228 sub GetDomainMailRules {
1229 my ($this, $domainName) = @_;
1230 croak 'usage CGP::CLI->GetDomainMailRules($domainName)'
1231 unless defined $domainName;
1232 $this->send('GetDomainMailRules '.$domainName);
1233 return undef unless $this->_parseResponse();
1234 $this->parseWords($this->getWords);
1237 sub SetDomainMailRules {
1238 my ($this, $domainName, $rules) = @_;
1239 croak 'usage CGP::CLI->SetDomainMailRules($domainName, \@rules)'
1240 unless defined $domainName && defined $rules;
1241 $this->send('SetDomainMailRules '.$domainName.' '.$this->printWords($rules));
1242 $this->_parseResponse();
1245 #sub UpdateDomainMailRule {
1246 # my ($this, $domainName, $rule) = @_;
1247 # croak 'usage CGP::CLI->UpdateDomainMailRules($domainName, \@rule)'
1248 # unless defined $domainName && defined $rule;
1249 # $this->send('UpdateDomainMailRule '.$domainName.' '.$this->printWords($rule));
1250 # $this->_parseResponse();
1252 sub GetDomainSignalRules {
1253 my ($this, $domainName) = @_;
1254 croak 'usage CGP::CLI->GetDomainSignalRules($domainName)'
1255 unless defined $domainName;
1256 $this->send('GetDomainSignalRules '.$domainName);
1257 return undef unless $this->_parseResponse();
1258 $this->parseWords($this->getWords);
1261 sub SetDomainSignalRules {
1262 my ($this, $domainName, $rules) = @_;
1263 croak 'usage CGP::CLI->SetDomainSignalRules($domainName, \@rules)'
1264 unless defined $domainName && defined $rules;
1265 $this->send('SetDomainSignalRules '.$domainName.' '.$this->printWords($rules));
1266 $this->_parseResponse();
1269 #sub UpdateDomainSignalRule {
1270 # my ($this, $domainName, $rule) = @_;
1271 # croak 'usage CGP::CLI->UpdateDomainSignalRules($domainName, \@rule)'
1272 # unless defined $domainName && defined $rule;
1273 # $this->send('UpdateDomainSignalRule '.$domainName.' '.$this->printWords($rule));
1274 # $this->_parseResponse();
1278 sub GetDomainAliases {
1279 my ($this, $domain) = @_;
1281 my $line = 'GetDomainAliases';
1282 $line .= ' '.$domain if $domain;
1284 return undef unless $this->_parseResponse();
1285 $this->parseWords($this->getWords);
1289 sub SetDomainAliases {
1290 my ($this, $domain, $aliases) = @_;
1291 croak 'usage CGP::CLI->SetDomainAliases($domainName, \@aliases)'
1292 unless defined $domain && defined $aliases;
1293 $this->send('SetDomainAliases '.$domain.' '.$this->printWords($aliases));
1294 $this->_parseResponse();
1297 sub ListAdminDomains {
1298 my ($this, $domain) = @_;
1299 my $line = 'ListAdminDomains';
1300 $line .= ' '.$domain if $domain;
1302 return undef unless $this->_parseResponse();
1303 $this->parseWords($this->getWords);
1306 sub InsertDirectoryRecords {
1307 my ($this, $domain) = @_;
1308 my $line = 'InsertDirectoryRecords';
1309 $line .= ' '.$domain if $domain;
1311 $this->_parseResponse();
1313 sub DeleteDirectoryRecords {
1314 my ($this, $domain) = @_;
1315 my $line = 'DeleteDirectoryRecords';
1316 $line .= ' '.$domain if $domain;
1318 $this->_parseResponse();
1321 sub GetServerTrustedCerts {
1323 $this->send('GetServerTrustedCerts');
1324 return undef unless $this->_parseResponse();
1325 $this->parseWords($this->getWords);
1328 sub SetServerTrustedCerts {
1329 my ( $this, $certs ) = @_;
1330 croak 'usage CGP::CLI->SetServerTrustedCerts(\@certs)'
1331 unless defined $certs;
1332 $this->send('SetServerTrustedCerts '.$this->printWords($certs));
1333 $this->_parseResponse();
1336 sub GetClusterTrustedCerts {
1338 $this->send('GetClusterTrustedCerts');
1339 return undef unless $this->_parseResponse();
1340 $this->parseWords($this->getWords);
1343 sub SetClusterTrustedCerts {
1344 my ( $this, $certs ) = @_;
1345 croak 'usage CGP::CLI->SetClusterTrustedCerts(\@certs)'
1346 unless defined $certs;
1347 $this->send('SetClusterTrustedCerts '.$this->printWords($certs));
1348 $this->_parseResponse();
1352 sub GetDirectoryIntegration {
1354 $this->send('GetDirectoryIntegration');
1355 return undef unless $this->_parseResponse();
1356 $this->parseWords($this->getWords);
1359 sub SetDirectoryIntegration {
1360 my ( $this, $dict ) = @_;
1361 croak 'usage CGP::CLI->SetDirectoryIntegration(\%settings)'
1362 unless defined $dict;
1364 $this->send('SetDirectoryIntegration '.$this->printWords($dict));
1365 $this->_parseResponse();
1368 sub GetClusterDirectoryIntegration {
1370 $this->send('GetClusterDirectoryIntegration');
1371 return undef unless $this->_parseResponse();
1372 $this->parseWords($this->getWords);
1375 sub SetClusterDirectoryIntegration {
1376 my ( $this, $dict ) = @_;
1377 croak 'usage CGP::CLI->SetClusterDirectoryIntegration(\%settings)'
1378 unless defined $dict;
1380 $this->send('SetClusterDirectoryIntegration '.$this->printWords($dict));
1381 $this->_parseResponse();
1385 sub GetDomainDefaults {
1387 $this->send('GetDomainDefaults');
1388 return undef unless $this->_parseResponse();
1389 $this->parseWords($this->getWords);
1392 sub UpdateDomainDefaults {
1393 my ( $this, $dict ) = @_;
1394 croak 'usage CGP::CLI->UpdateDomainDefaults(\%settings)'
1395 unless defined $dict;
1397 $this->send('UpdateDomainDefaults '.$this->printWords($dict));
1398 $this->_parseResponse();
1401 sub SetDomainDefaults {
1402 my ( $this, $dict ) = @_;
1403 croak 'usage CGP::CLI->SetDomainDefaults(\%settings)'
1404 unless defined $dict;
1405 $this->send('SetDomainDefaults '.$this->printWords($dict));
1406 $this->_parseResponse();
1409 sub GetClusterDomainDefaults {
1411 $this->send('GetClusterDomainDefaults');
1412 return undef unless $this->_parseResponse();
1413 $this->parseWords($this->getWords);
1416 sub UpdateClusterDomainDefaults {
1417 my ( $this, $dict ) = @_;
1418 $this->send('UpdateClusterDomainDefaults '.$this->printWords($dict));
1419 $this->_parseResponse();
1422 sub SetClusterDomainDefaults {
1423 my ( $this, $dict ) = @_;
1424 $this->send('SetClusterDomainDefaults '.$this->printWords($dict));
1425 $this->_parseResponse();
1429 sub GetAllAccountsDefaults {
1431 $this->send('GetAllAccountsDefaults');
1432 return undef unless $this->_parseResponse();
1433 $this->parseWords($this->getWords);
1436 sub UpdateAllAccountsDefaults {
1437 my ( $this, $dict ) = @_;
1438 $this->send('UpdateAllAccountsDefaults '.$this->printWords($dict));
1439 $this->_parseResponse();
1442 sub SetAllAccountsDefaults {
1443 my ( $this, $dict ) = @_;
1444 $this->send('SetAllAccountsDefaults '.$this->printWords($dict));
1445 $this->_parseResponse();
1448 sub GetServerAccountDefaults {
1450 $this->send('GetServerAccountDefaults');
1451 return undef unless $this->_parseResponse();
1452 $this->parseWords($this->getWords);
1455 sub UpdateServerAccountDefaults {
1456 my ( $this, $dict ) = @_;
1457 $this->send('UpdateServerAccountDefaults '.$this->printWords($dict));
1458 $this->_parseResponse();
1461 sub SetServerAccountDefaults {
1462 my ( $this, $dict ) = @_;
1463 $this->send('SetServerAccountDefaults '.$this->printWords($dict));
1464 $this->_parseResponse();
1467 sub GetClusterAccountDefaults {
1469 $this->send('GetClusterAccountDefaults');
1470 return undef unless $this->_parseResponse();
1471 $this->parseWords($this->getWords);
1474 sub UpdateClusterAccountDefaults {
1475 my ( $this, $dict ) = @_;
1476 $this->send('UpdateClusterAccountDefaults '.$this->printWords($dict));
1477 $this->_parseResponse();
1480 sub SetClusterAccountDefaults {
1481 my ( $this, $dict ) = @_;
1482 $this->send('SetClusterAccountDefaults '.$this->printWords($dict));
1483 $this->_parseResponse();
1486 sub GetServerWebUserDefaults {
1488 $this->send('GetServerWebUserDefaults');
1489 return undef unless $this->_parseResponse();
1490 $this->parseWords($this->getWords);
1492 sub GetServerAccountPrefs {
1494 $this->send('GetServerAccountPrefs');
1495 return undef unless $this->_parseResponse();
1496 $this->parseWords($this->getWords);
1499 sub SetServerWebUserDefaults {
1500 my ( $this, $dict ) = @_;
1501 $this->send('SetServerWebUserDefaults '.$this->printWords($dict));
1502 $this->_parseResponse();
1504 sub SetServerAccountPrefs {
1505 my ( $this, $dict ) = @_;
1506 $this->send('SetServerAccountPrefs '.$this->printWords($dict));
1507 $this->_parseResponse();
1509 sub UpdateServerAccountPrefs {
1510 my ( $this, $dict ) = @_;
1511 $this->send('UpdateServerAccountPrefs '.$this->printWords($dict));
1512 $this->_parseResponse();
1515 sub GetClusterWebUserDefaults {
1517 $this->send('GetClusterWebUserDefaults');
1518 return undef unless $this->_parseResponse();
1519 $this->parseWords($this->getWords);
1521 sub GetClusterAccountPrefs {
1523 $this->send('GetClusterAccountPrefs');
1524 return undef unless $this->_parseResponse();
1525 $this->parseWords($this->getWords);
1527 sub SetClusterWebUserDefaults {
1528 my ( $this, $dict ) = @_;
1529 $this->send('SetClusterWebUserDefaults '.$this->printWords($dict));
1530 $this->_parseResponse();
1532 sub SetClusterAccountPrefs {
1533 my ( $this, $dict ) = @_;
1534 $this->send('SetClusterAccountPrefs '.$this->printWords($dict));
1535 $this->_parseResponse();
1537 sub UpdateClusterAccountPrefs {
1538 my ( $this, $dict ) = @_;
1539 $this->send('UpdateClusterAccountPrefs '.$this->printWords($dict));
1540 $this->_parseResponse();
1543 sub GetDomainLocation {
1544 my ( $this, $account ) = @_;
1545 $this->send('GetDomainLocation '.$account);
1546 return undef unless $this->_parseResponse();
1547 $this->parseWords($this->getWords);
1550 sub GetAccountLocation {
1551 my ( $this, $account ) = @_;
1552 $this->send('GetAccountLocation '.$account);
1553 return undef unless $this->_parseResponse();
1554 $this->parseWords($this->getWords);
1557 sub ListServerTelnums {
1558 my ($this, $limit,$filter) = @_;
1559 croak 'usage CGP::CLI->ListServerTelnums($limit[,$filter])'
1560 unless defined $limit;
1561 my $line = "ListServerTelnums";
1562 $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
1565 return undef unless $this->_parseResponse();
1566 $this->parseWords($this->getWords);
1569 sub ListClusterTelnums {
1570 my ($this, $limit,$filter) = @_;
1571 croak 'usage CGP::CLI->ListClusterTelnums($limit[,$filter])'
1572 unless defined $limit;
1573 my $line = "ListClusterTelnums";
1574 $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
1577 return undef unless $this->_parseResponse();
1578 $this->parseWords($this->getWords);
1582 sub GetAccountDefaults {
1583 my ($this, $domain) = @_;
1585 my $line = 'GetAccountDefaults';
1586 $line .= ' '.$domain if($domain);
1588 return undef unless $this->_parseResponse();
1589 $this->parseWords($this->getWords);
1592 sub UpdateAccountDefaults {
1596 croak 'usage CGP::CLI->UpdateAccountDefaults(domain => \'domainName\',settings => {settings})'
1597 unless exists $params{settings};
1599 my $line = 'UpdateAccountDefaults';
1600 $line .= ' '.$params{domain} if exists $params{domain};
1602 $this->send($line . ' ' . $this->printWords($params{settings}));
1603 $this->_parseResponse();
1606 sub SetAccountDefaults {
1610 croak 'usage CGP::CLI->SetAccountDefaults(domain => \'domainName\',settings => {settings})'
1611 unless exists $params{settings};
1613 my $line = 'SetAccountDefaults';
1614 $line .= ' '.$params{domain} if exists $params{domain};
1616 $this->send($line . ' ' . $this->printWords($params{settings}));
1617 $this->_parseResponse();
1620 sub GetWebUserDefaults {
1621 my ($this, $domain) = @_;
1623 my $line = 'GetWebUserDefaults';
1624 $line .= ' '.$domain if($domain);
1627 return undef unless $this->_parseResponse();
1628 $this->parseWords($this->getWords);
1631 sub GetAccountDefaultPrefs {
1632 my ($this, $domain) = @_;
1634 my $line = 'GetAccountDefaultPrefs';
1635 $line .= ' '.$domain if($domain);
1638 return undef unless $this->_parseResponse();
1639 $this->parseWords($this->getWords);
1642 sub SetWebUserDefaults {
1643 my ($this) = shift;;
1645 croak 'usage CGP::CLI->SetWebUserDefaults(domain => \'domainName\',settings => {settings})'
1646 unless exists $params{settings};
1648 my $line = 'SetWebUserDefaults';
1649 $line .= ' ' .$params{domain} if exists $params{domain};
1651 $this->send($line . ' ' . $this->printWords($params{settings}));
1652 $this->_parseResponse();
1654 sub SetAccountDefaultPrefs {
1655 my ($this) = shift;;
1657 croak 'usage CGP::CLI->SetAccountDefaultPrefs(domain => \'domainName\',settings => {settings})'
1658 unless exists $params{settings};
1660 my $line = 'SetAccountDefaultPrefs';
1661 $line .= ' ' .$params{domain} if exists $params{domain};
1663 $this->send($line . ' ' . $this->printWords($params{settings}));
1664 $this->_parseResponse();
1667 sub UpdateWebUserDefaults {
1668 my ($this) = shift;;
1670 croak 'usage CGP::CLI->UpdateWebUserDefaults(domain => \'domainName\',settings => {settings})'
1671 unless exists $params{settings};
1673 my $line = 'UpdateWebUserDefaults';
1674 $line .= ' ' .$params{domain} if exists $params{domain};
1676 $this->send($line . ' ' . $this->printWords($params{settings}));
1677 $this->_parseResponse();
1679 sub UpdateAccountDefaultPrefs {
1680 my ($this) = shift;;
1682 croak 'usage CGP::CLI->UpdateAccountDefaultPrefs(domain => \'domainName\',settings => {settings})'
1683 unless exists $params{settings};
1685 my $line = 'UpdateAccountDefaultPrefs';
1686 $line .= ' ' .$params{domain} if exists $params{domain};
1688 $this->send($line . ' ' . $this->printWords($params{settings}));
1689 $this->_parseResponse();
1692 sub GetAccountTemplate {
1693 my ($this, $domain) = @_;
1695 my $line = 'GetAccountTemplate';
1696 $line .= ' '.$domain if($domain);
1699 return undef unless $this->_parseResponse();
1700 $this->parseWords($this->getWords);
1703 sub UpdateAccountTemplate {
1704 my ($this) = shift;;
1707 croak 'usage CGP::CLI->UpdateAccountTemplate(domain => \'domainName\',settings => {settings})'
1708 unless exists $params{settings};
1710 my $line = 'UpdateAccountTemplate';
1711 $line .= ' '.$params{domain} if exists $params{domain};
1713 $this->send($line.' '.$this->printWords($params{settings}));
1714 $this->_parseResponse();
1717 sub SetAccountTemplate {
1718 my ($this) = shift;;
1721 croak 'usage CGP::CLI->SetAccountTemplate(domain => \'domainName\',settings => {settings})'
1722 unless exists $params{settings};
1724 my $line = 'SetAccountTemplate';
1725 $line .= ' '.$params{domain} if exists $params{domain};
1727 $this->send($line.' '.$this->printWords($params{settings}));
1728 $this->_parseResponse();
1731 #################################################################
1732 # Mailbox managent commands
1735 my ($this) = shift;;
1738 croak 'usage CGP::CLI->ListMailboxes(accountName => \'account\',filter => \'*\',authAccountName => \'extAccount\')'
1739 unless exists $params{accountName};
1741 my $line = 'ListMailboxes '.$params{accountName};
1742 $line .= ' FILTER '.$this->printWords($params{filter}) if exists $params{filter};
1743 $line .= ' AUTH '.$params{authAccountName} if exists $params{authAccountName};
1746 return undef unless $this->_parseResponse();
1747 $this->parseWords($this->getWords);
1751 my ($this,$accountName,$mailboxName,$authAccountName,$class) = @_;
1754 croak 'usage CGP::CLI->CreateMailbox(accountName,mailboxName,[authAccountName],[class])'
1755 unless (defined $accountName && defined $mailboxName);
1757 my $line = 'CREATEMAILBOX '.$accountName;
1758 $line .= ' MAILBOX '.$this->printWords($mailboxName);
1759 $line .= ' AUTH '.$authAccountName if($authAccountName);
1760 $line .= ' CLASS '.$class if($class);
1763 $this->_parseResponse();
1767 my ($this,$accountName,$oldMailboxName,$newMailboxName,$authAccountName) = @_;
1769 croak 'usage CGP::CLI->RenameMailbox(accountName,oldMailboxName,newMailboxName[,authAccountName])'
1770 unless (defined $accountName && defined $oldMailboxName && defined $newMailboxName);
1772 my $line = 'RENAMEMAILBOX '.$accountName;
1773 $line .= ' MAILBOX '.$this->printWords($oldMailboxName);
1774 $line .= ' INTO '.$this->printWords($newMailboxName);
1775 $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1778 $this->_parseResponse();
1781 sub RenameMailboxes {
1782 my ($this,$accountName,$oldMailboxName,$newMailboxName,$authAccountName) = @_;
1784 croak 'usage CGP::CLI->RenameMailboxes(accountName,oldMailboxName,newMailboxName[,authAccountName])'
1785 unless (defined $accountName && defined $oldMailboxName && defined $newMailboxName);
1787 my $line = 'RENAMEMAILBOX '.$accountName;
1788 $line .= ' MAILBOXES '.$this->printWords($oldMailboxName);
1789 $line .= ' INTO '.$this->printWords($newMailboxName);
1790 $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1793 $this->_parseResponse();
1797 my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1799 croak 'usage CGP::CLI->DeleteMailbox(accountName,mailboxName[,authAccountName])'
1800 unless (defined $accountName && defined $mailboxName);
1802 my $line = 'DELETEMAILBOX '.$accountName;
1803 $line .= ' MAILBOX '.$this->printWords($mailboxName);
1804 $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1807 $this->_parseResponse();
1810 sub DeleteMailboxes {
1811 my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1813 croak 'usage CGP::CLI->DeleteMailboxes(accountName,mailboxName[,authAccountName])'
1814 unless (defined $accountName && defined $mailboxName);
1816 my $line = 'DELETEMAILBOX '.$accountName;
1817 $line .= ' MAILBOXES '.$this->printWords($mailboxName);
1818 $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1821 $this->_parseResponse();
1824 sub GetMailboxInfo {
1825 my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1827 croak 'usage CGP::CLI->GetMailboxInfo(accountName,mailboxName[,authAccountName])'
1828 unless (defined $accountName && defined $mailboxName);
1830 my $line = 'GETMAILBOXINFO '.$accountName;
1831 $line .= ' MAILBOX '.$this->printWords($mailboxName);
1832 $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1835 return undef unless $this->_parseResponse();
1836 $this->parseWords($this->getWords);
1840 my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1842 croak 'usage CGP::CLI->GetMailboxACL(accountName,mailboxName[,authAccountName])'
1843 unless (defined $accountName && defined $mailboxName);
1845 my $line = 'GETMAILBOXACL '.$accountName;
1846 $line .= ' MAILBOX '.$this->printWords($mailboxName);
1847 $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1850 return undef unless $this->_parseResponse();
1851 $this->parseWords($this->getWords);
1855 my ($this,$accountName,$mailboxName,$newACL,$authAccountName) = @_;
1857 croak 'usage CGP::CLI->SetMailboxACL(accountName,mailboxName,\@newACL[,authAccountName])'
1858 unless (defined $accountName && defined $mailboxName && defined $newACL);
1860 my $line = 'SETMAILBOXACL '.$accountName;
1861 $line .= ' MAILBOX '.$this->printWords($mailboxName);
1862 $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1864 $this->send($line.' '.$this->printWords($newACL));
1865 $this->_parseResponse();
1869 sub GetMailboxRights {
1870 my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1872 croak 'usage CGP::CLI->GetMailboxRights(accountName,mailboxName,authAccountName)'
1873 unless (defined $accountName && defined $mailboxName && defined $authAccountName);
1875 my $line = 'GETMAILBOXRIGHTS '.$accountName;
1876 $line .= ' MAILBOX '.$this->printWords($mailboxName);
1877 $line .= ' AUTH '.$authAccountName;
1880 return undef unless $this->_parseResponse();
1881 $this->parseWords($this->getWords);
1884 sub SetMailboxClass {
1885 my ($this,$accountName,$mailboxName,$class,$authAccountName) = @_;
1887 croak 'usage CGP::CLI->SetMailboxClass(accountName,mailboxName,class [,authAccountName])'
1888 unless (defined $accountName && defined $mailboxName && defined $class);
1890 my $line = 'SetMailboxClass '.$accountName;
1891 $line .= ' MAILBOX '.$this->printWords($mailboxName);
1892 $line .= ' AUTH '.$authAccountName if(defined $authAccountName);
1893 $line .= ' CLASS '.$class;
1896 return undef unless $this->_parseResponse();
1900 sub GetAccountSubscription {
1901 my ($this,$accountName) = @_;
1902 croak 'usage CGP::CLI->GetAccountSubscription(accountName)'
1903 unless defined $accountName;
1905 $this->send('GetAccountSubscription '.$accountName);
1906 return undef unless $this->_parseResponse();
1907 $this->parseWords($this->getWords);
1910 sub SetAccountSubscription {
1911 my ($this,$accountName,$newSubscription) = @_;
1912 croak 'usage CGP::CLI->SetAccountSubscription(accountName,\%newSubscription)'
1913 unless (defined $accountName && defined $newSubscription);
1915 $this->send('SetAccountSubscription '.$accountName.' '.$this->printWords($newSubscription));
1916 $this->_parseResponse();
1919 sub GetMailboxSubscription {
1920 my ($this,$accountName) = @_;
1921 croak 'usage CGP::CLI->GetMailboxSubscription(accountName)'
1922 unless defined $accountName;
1924 $this->send('GetMailboxSubscription '.$accountName);
1925 return undef unless $this->_parseResponse();
1926 $this->parseWords($this->getWords);
1929 sub SetMailboxSubscription {
1930 my ($this,$accountName,$newSubscription) = @_;
1931 croak 'usage CGP::CLI->SetMailboxSubscription(accountName,\%newSubscription)'
1932 unless (defined $accountName && defined $newSubscription);
1934 $this->send('SetMailboxSubscription '.$accountName.' '.$this->printWords($newSubscription));
1935 $this->_parseResponse();
1938 sub GetMailboxAliases {
1939 my ($this,$accountName) = @_;
1940 croak 'usage CGP::CLI->GetMailboxAliases(accountName)'
1941 unless defined $accountName;
1943 $this->send('GetMailboxAliases '.$accountName);
1944 return undef unless $this->_parseResponse();
1945 $this->parseWords($this->getWords);
1948 sub SetMailboxAliases {
1949 my ($this,$accountName,$newAliases) = @_;
1950 croak 'usage CGP::CLI->SetMailboxAliases(accountName,\%newAliases)'
1951 unless (defined $accountName && defined $newAliases);
1953 $this->send('SetMailboxAliases '.$accountName.' '.$this->printWords($newAliases));
1954 $this->_parseResponse();
1958 #################################################################
1959 # Alerts Administration
1961 sub GetDomainAlerts {
1962 my ($this, $domain) = @_;
1964 my $line = 'GetDomainAlerts';
1965 $line .= ' '.$domain if $domain;
1967 return undef unless $this->_parseResponse();
1968 $this->parseWords($this->getWords);
1971 sub SetDomainAlerts {
1972 my ($this, $domain, $alerts) = @_;
1973 croak 'usage CGP::CLI->SetDomainAlerts($domainName, \@alerts)'
1974 unless defined $domain && defined $alerts;
1975 $this->send('SetDomainAlerts '.$domain.' '.$this->printWords($alerts));
1976 $this->_parseResponse();
1979 sub PostDomainAlert {
1980 my ($this, $domain, $alert) = @_;
1981 croak 'usage CGP::CLI->PostDomainAlert($domainName, $alertString)'
1982 unless defined $domain && defined $alert;
1983 $this->send('PostDomainAlert '.$domain.' ALERT '.$this->printWords($alert));
1984 $this->_parseResponse();
1987 sub RemoveDomainAlert {
1988 my ($this, $domain, $timeStamp) = @_;
1989 croak 'usage CGP::CLI->RemoveDomainAlert($domainName, $timeStamp)'
1990 unless defined $domain && defined $timeStamp;
1991 $this->send('RemoveDomainAlert '.$domain.' ALERT '.$timeStamp);
1992 $this->_parseResponse();
1995 sub GetAccountAlerts {
1996 my ($this, $account) = @_;
1997 $this->send('GetAccountAlerts '.$account);
1998 return undef unless $this->_parseResponse();
1999 $this->parseWords($this->getWords);
2002 sub SetAccountAlerts {
2003 my ($this, $account, $alerts) = @_;
2004 croak 'usage CGP::CLI->SetAccountAlerts($account, \@alerts)'
2005 unless defined $account && defined $alerts;
2006 $this->send('SetAccountAlerts '.$account.' '.$this->printWords($alerts));
2007 $this->_parseResponse();
2010 sub PostAccountAlert {
2011 my ($this, $account, $alert) = @_;
2012 croak 'usage CGP::CLI->PostAccountAlert($account, $alertString)'
2013 unless defined $account && defined $alert;
2014 $this->send('PostAccountAlert '.$account.' ALERT '.$this->printWords($alert));
2015 $this->_parseResponse();
2018 sub RemoveAccountAlert {
2019 my ($this, $account, $timeStamp) = @_;
2020 croak 'usage CGP::CLI->RemoveAccountAlert($account, $timeStamp)'
2021 unless defined $account && defined $timeStamp;
2022 $this->send('RemoveAccountAlert '.$account.' ALERT '.$timeStamp);
2023 $this->_parseResponse();
2027 sub GetServerAlerts {
2029 $this->send('GetServerAlerts');
2030 return undef unless $this->_parseResponse();
2031 $this->parseWords($this->getWords);
2034 sub SetServerAlerts {
2035 my ($this, $alerts) = @_;
2036 croak 'usage CGP::CLI->SetServerAlerts(\@alerts)'
2037 unless defined $alerts;
2038 $this->send('SetServerAlerts '.$this->printWords($alerts));
2039 $this->_parseResponse();
2042 sub PostServerAlert {
2043 my ($this, $alert) = @_;
2044 croak 'usage CGP::CLI->PostServerAlert($alertString)'
2045 unless defined $alert;
2046 $this->send('PostServerAlert '.$this->printWords($alert));
2047 $this->_parseResponse();
2050 sub RemoveServerAlert {
2051 my ($this, $timeStamp) = @_;
2052 croak 'usage CGP::CLI->RemoveServerAlert($timeStamp)'
2053 unless defined $timeStamp;
2054 $this->send('RemoveServerAlert '.$timeStamp);
2055 $this->_parseResponse();
2058 sub GetClusterAlerts {
2060 $this->send('GetClusterAlerts');
2061 return undef unless $this->_parseResponse();
2062 $this->parseWords($this->getWords);
2065 sub SetClusterAlerts {
2066 my ($this, $alerts) = @_;
2067 croak 'usage CGP::CLI->SetClusterAlerts(\@alerts)'
2068 unless defined $alerts;
2069 $this->send('SetClusterAlerts '.$this->printWords($alerts));
2070 $this->_parseResponse();
2073 sub PostClusterAlert {
2074 my ($this, $alert) = @_;
2075 croak 'usage CGP::CLI->PostClusterAlert($alertString)'
2076 unless defined $alert;
2077 $this->send('PostClusterAlert '.$this->printWords($alert));
2078 $this->_parseResponse();
2081 sub RemoveClusterAlert {
2082 my ($this, $timeStamp) = @_;
2083 croak 'usage CGP::CLI->RemoveClusterAlert($timeStamp)'
2084 unless defined $timeStamp;
2085 $this->send('RemoveClusterAlert '.$timeStamp);
2086 $this->_parseResponse();
2089 #################################################################
2090 # Personal Web Site Administration
2093 my ($this,$accountName,$fileName,$position,$sliceSize) = @_;
2095 croak 'usage CGP::CLI->GetWebFile(accountName,fileName[,position,sliceSize])'
2096 unless (defined $accountName && defined $fileName);
2097 my $line='GetWebFile '.$accountName.' FILE '.$this->printWords($fileName);
2098 $line .= ' OFFSET '. $position if(defined $position && $position!=0);
2099 $line .= ' SIZE '. $sliceSize if(defined $sliceSize);
2102 return undef unless $this->_parseResponse;
2103 $this->parseWords($this->getWords);
2107 my ($this,$accountName,$fileName,$data,$position) = @_;
2109 croak 'usage CGP::CLI->PutWebFile(accountName,fileName,data [,position])'
2110 unless (defined $accountName && defined $fileName && defined $data);
2111 my $line='PutWebFile '.$accountName.' FILE '.$this->printWords($fileName);
2112 $line .= ' OFFSET '. $position if(defined $position && $position!=0);
2113 if($data=~/\[.*\]$/) {
2114 $line .= ' DATA '.$data;
2116 $line .= ' DATA ['.$data.']';
2119 $this->_parseResponse;
2123 my ($this,$accountName,$oldFileName,$newFileName) = @_;
2125 croak 'usage CGP::CLI->RenameWebFile(accountName,oldFileName,newFileName)'
2126 unless (defined $accountName && defined $oldFileName && defined $newFileName);
2127 $this->send('RenameWebFile '.$accountName.' FILE '.$this->printWords($oldFileName).' INTO '.$this->printWords($newFileName));
2128 $this->_parseResponse;
2132 my ($this,$accountName,$fileName) = @_;
2134 croak 'usage CGP::CLI->DeleteWebFile(accountName,fileName)'
2135 unless (defined $accountName && defined $fileName);
2136 $this->send('DeleteWebFile '.$accountName.' FILE '.$this->printWords($fileName));
2137 $this->_parseResponse;
2141 my ($this,$accountName,$filePath) = @_;
2143 croak 'usage CGP::CLI->ListWebFiles(accountName [,filePath])'
2144 unless defined $accountName;
2145 my $line = 'ListWebFiles '.$accountName;
2146 $line .= ' PATH '.$this->printWords($filePath) if $filePath;
2148 return undef unless $this->_parseResponse;
2149 $this->parseWords($this->getWords);
2152 sub GetWebFilesInfo {
2153 my ($this,$accountName) = @_;
2155 croak 'usage CGP::CLI->InfoWebFiles(accountName)'
2156 unless defined $accountName;
2157 $this->send('GetWebFilesInfo '.$accountName);
2158 return undef unless $this->_parseResponse;
2159 $this->parseWords($this->getWords);
2162 #################################################################
2163 # File Storage Administration
2165 sub ReadStorageFile {
2166 my ($this,$accountName,$fileName,$position,$sliceSize,$authAccountName) = @_;
2168 croak 'usage CGP::CLI->ReadStorageFile(accountName,fileName[,position,sliceSize[,authAccountName]])'
2169 unless (defined $accountName && defined $fileName);
2170 my $line='ReadStorageFile '.$accountName.' FILE '.$this->printWords($fileName);
2171 $line .= ' OFFSET '. $position if(defined $position && $position!=0);
2172 $line .= ' SIZE '. $sliceSize if(defined $sliceSize);
2173 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2176 return undef unless $this->_parseResponse;
2177 $this->parseWords($this->getWords);
2180 sub WriteStorageFile {
2181 my ($this,$accountName,$fileName,$data,$position,$authAccountName) = @_;
2183 croak 'usage CGP::CLI->WriteStorageFile(accountName,fileName,data [,position[,authAccountName]])'
2184 unless (defined $accountName && defined $fileName && defined $data);
2185 my $line='WriteStorageFile '.$accountName.' FILE '.$this->printWords($fileName);
2186 $line .= ' OFFSET '. $position if(defined $position && $position!=0);
2187 if($data=~/\[.*\]$/) {
2188 $line .= ' DATA '.$data;
2190 $line .= ' DATA ['.$data.']';
2192 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2194 $this->_parseResponse;
2197 sub RenameStorageFile {
2198 my ($this,$accountName,$oldFileName,$newFileName,$authAccountName) = @_;
2200 croak 'usage CGP::CLI->RenameStorageFile(accountName,oldFileName,newFileName[,authAccountName])'
2201 unless (defined $accountName && defined $oldFileName && defined $newFileName);
2202 my $line='RenameStorageFile '.$accountName.' FILE '.$this->printWords($oldFileName).' INTO '.$this->printWords($newFileName);
2203 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2205 $this->_parseResponse;
2208 sub DeleteStorageFile {
2209 my ($this,$accountName,$fileName,$authAccountName) = @_;
2211 croak 'usage CGP::CLI->DeleteStorageFile(accountName,fileName[,authAccountName])'
2212 unless (defined $accountName && defined $fileName);
2213 my $line='DeleteStorageFile '.$accountName.' FILE '.$this->printWords($fileName);
2214 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2216 $this->_parseResponse;
2219 sub ListStorageFiles {
2220 my ($this,$accountName,$filePath,$authAccountName) = @_;
2222 croak 'usage CGP::CLI->ListStorageFiles(accountName [,filePath[,authAccountName]])'
2223 unless defined $accountName;
2224 my $line = 'ListStorageFiles '.$accountName;
2225 $line .= ' PATH '.$this->printWords($filePath) if $filePath;
2226 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2228 return undef unless $this->_parseResponse;
2229 $this->parseWords($this->getWords);
2232 sub GetStorageFileInfo {
2233 my ($this,$accountName,$filePath,$authAccountName) = @_;
2235 croak 'usage CGP::CLI->GetStorageFileInfo(accountName[,filePath[,authAccountName])'
2236 unless defined $accountName;
2237 my $line='GetStorageFileInfo '.$accountName;
2238 $line .= ' PATH '.$this->printWords($filePath) if $filePath;
2239 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2242 return undef unless $this->_parseResponse;
2243 $this->parseWords($this->getWords);
2246 sub ReadStorageFileAttr {
2247 my ($this,$accountName,$fileName,$atributes,$authAccountName) = @_;
2249 croak 'usage CGP::CLI->ReadStorageFileAttr(accountName,fileName[,attributes[,authAccountName]])'
2250 unless (defined $accountName && defined $fileName);
2251 my $line='ReadStorageFileAttr '.$accountName.' FILE '.$this->printWords($fileName);
2252 $line .= $atributes if(defined $atributes);
2253 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2256 return undef unless $this->_parseResponse;
2257 $this->parseWords($this->getWords);
2260 sub UpdateStorageFileAttr {
2261 my ($this,$accountName,$fileName,$attributes,$authAccountName) = @_;
2263 croak 'usage CGP::CLI->UpdateStorageFileAttr(accountName,fileName,attributes[,authAccountName])'
2264 unless (defined $accountName && defined $fileName && defined $attributes);
2265 my $line='UpdateStorageFileAttr '.$accountName.' FILE '.$this->printWords($fileName).' '.$attributes;
2266 $line .= ' AUTH '. $authAccountName if(defined $authAccountName);
2268 $this->_parseResponse;
2271 sub GetFileSubscription {
2272 my ($this, $accountName) = @_;
2273 croak 'usage CGP::CLI->GetFileSubscription($accountName)'
2274 unless defined $accountName;
2275 $this->send('GetFileSubscription '.$accountName);
2276 return undef unless $this->_parseResponse();
2277 $this->parseWords($this->getWords);
2280 sub SetFileSubscription {
2281 my ($this, $accountName, $newSubscription) = @_;
2282 croak 'usage CGP::CLI->SetFileSubscription($accountName, \@newSubscription)'
2283 unless defined $accountName && defined $newSubscription;
2284 $this->send('SetFileSubscription '.$accountName.' '.$this->printWords($newSubscription));
2285 $this->_parseResponse();
2289 #################################################################
2290 # List management commands
2293 my ( $this, $domain ) = @_;
2294 my $line = 'LISTLISTS';
2295 $line .= ' '.$domain if $domain;
2297 return undef unless $this->_parseResponse;
2298 $this->parseWords($this->getWords);
2301 sub GetDomainLists {
2302 my ( $this, $domain ) = @_;
2303 my $line = 'GetDomainLists';
2304 $line .= ' '.$domain if $domain;
2306 return undef unless $this->_parseResponse;
2307 $this->parseWords($this->getWords);
2310 sub GetAccountLists {
2311 my ( $this, $accountName ) = @_;
2312 croak 'usage CGP::CLI->GetAccoountLists($accountName)'
2313 unless defined $accountName;
2315 $this->send('GetAccountLists '.$accountName);
2316 return undef unless $this->_parseResponse;
2317 $this->parseWords($this->getWords);
2321 my ($this, $listName, $accountName) = @_;
2322 croak 'usage CGP::CLI->CreateList($listName, $accountName)'
2323 unless defined $listName && defined $accountName;
2324 $this->send('CREATELIST '.$listName.' for '.$accountName);
2325 $this->_parseResponse();
2329 my ($this, $oldListName, $newListName) = @_;
2330 croak 'usage CGP::CLI->RenameList($oldListName, $newListName)'
2331 unless defined $oldListName && defined $newListName;
2332 $this->send('RENAMELIST '.$oldListName.' into '.$newListName);
2333 $this->_parseResponse();
2337 my ( $this, $listName ) = @_;
2338 croak 'usage CGP::CLI->DeleteList($listName)'
2339 unless defined $listName;
2341 $this->send('DELETELIST '.$listName);
2342 $this->_parseResponse();
2346 my ( $this, $listName ) = @_;
2347 croak 'usage CGP::CLI->GetList($listName)'
2348 unless defined $listName;
2350 $this->send('GETLIST '.$listName);
2351 return undef unless $this->_parseResponse();
2352 $this->parseWords($this->getWords);
2356 my ( $this, $listName, $dict ) = @_;
2357 croak 'usage CGP::CLI->UpdateList($listName,\%params)'
2358 unless defined $listName && defined $dict;
2360 $this->send('UPDATELIST '.$listName.' '.$this->printWords($dict) );
2361 $this->_parseResponse();
2365 my ( $this, $listName, $command, $subscriber, @options ) = @_;
2366 croak 'usage CGP::CLI->List($listName, $command, $subscriber, @options)'
2367 unless defined $listName && defined $command && defined $subscriber;
2369 $this->send('LIST '.$listName.' '.$command.' '.join(' ',@options).' '.$subscriber);
2370 $this->_parseResponse();
2373 sub ListSubscribers {
2374 my ( $this, $listName,$filter,$limit ) = @_;
2375 croak 'usage CGP::CLI->ListSubscribers($listName [,$filter[,$limit]])'
2376 unless defined $listName;
2378 my $line = 'ListSubscribers '.$listName;
2379 $line .= ' FILTER '. ($filter eq '' ? '""' : $this->printWords($filter)) if($filter || $limit);
2380 $line .= " $limit" if($limit);
2382 $this->send($line );
2383 return undef unless $this->_parseResponse();
2384 $this->parseWords($this->getWords);
2387 sub GetSubscriberInfo {
2388 my ( $this, $listName,$address ) = @_;
2389 croak 'usage CGP::CLI->GetSubscriberInfo($listName ,$subscriberAddress)'
2390 unless defined $listName && defined $address;
2391 $this->send('GetSubscriberInfo '.$listName.' NAME '.$address);
2392 return undef unless $this->_parseResponse();
2393 $this->parseWords($this->getWords);
2396 sub SetPostingMode {
2397 my ($this, $listName, $address, $mode) = @_;
2398 croak 'usage CGP::CLI->SetPostingMode($listName,$subscriberAddress,$mode)'
2399 unless defined $listName && defined $address && defined $mode;
2400 $this->send('SetPostingMode '.$listName.' FOR '.$address.' '.$mode);
2401 $this->_parseResponse();
2405 my ($this, $listName, $address, $fatal) = @_;
2406 croak 'usage CGP::CLI->ProcessBounce($listName,$subscriberAddress,"fatal")'
2407 unless defined $listName && defined $address;
2408 my $line = 'ProcessBounce '.$listName;
2409 $line .= ' FATAL' if($fatal);
2410 $this->send($line. ' FOR '.$address);
2411 $this->_parseResponse();
2414 #############################################
2415 # Web Skins Administration
2417 sub ListDomainSkins {
2418 my ($this, $domainName) = @_;
2419 my $line = 'ListDomainSkins';
2420 $line .= ' '.$domainName if($domainName);
2422 return undef unless $this->_parseResponse();
2423 $this->parseWords($this->getWords);
2426 sub CreateDomainSkin {
2427 my ( $this, $domain, $skin ) = @_;
2428 croak 'usage CGP::CLI->CreateDomainSkin($domainName,$skinName)'
2429 unless defined $domain && defined $skin;
2431 $this->send('CreateDomainSkin '.$domain.' SKIN '.$this->printWords($skin));
2432 $this->_parseResponse();
2435 sub RenameDomainSkin {
2436 my ( $this, $domain, $skin, $newName ) = @_;
2437 croak 'usage CGP::CLI->RenameDomainSkin($domainName,$oldSkinName,$newSkinName)'
2438 unless defined $domain && defined $skin && defined $newName;
2440 $this->send('RenameDomainSkin '.$domain.' SKIN '.$this->printWords($skin).' INTO '.$this->printWords($newName));
2441 $this->_parseResponse();
2444 sub DeleteDomainSkin {
2445 my ( $this, $domain, $skin ) = @_;
2446 croak 'usage CGP::CLI->DeleteDomainSkin($domainName,$skinName)'
2447 unless defined $domain && defined $skin;
2449 $this->send('DeleteDomainSkin '.$domain.' SKIN '.$this->printWords($skin));
2450 $this->_parseResponse();
2453 sub ListDomainSkinFiles {
2454 my ( $this, $domain, $skin ) = @_;
2455 croak 'usage CGP::CLI->ListDomainSkinFiles($domainName,$skinName)'
2456 unless defined $domain && defined $skin;
2458 $this->send('ListDomainSkinFiles '.$domain.' SKIN '.$this->printWords($skin));
2459 return undef unless $this->_parseResponse();
2460 $this->parseWords($this->getWords);
2463 sub ReadDomainSkinFile {
2464 my ( $this, $domain, $skin, $fileName ) = @_;
2465 croak 'usage CGP::CLI->ReadDomainSkinFile($domainName,$skinName,$fileName)'
2466 unless defined $domain && defined $skin && defined $fileName;
2468 $this->send('ReadDomainSkinFile '.$domain.' SKIN '.$this->printWords($skin).' FILE '.$this->printWords($fileName));
2469 return undef unless $this->_parseResponse();
2470 $this->parseWords($this->getWords);
2473 sub StoreDomainSkinFile {
2474 my ( $this, $domain, $skin, $fileName,$base64data ) = @_;
2475 croak 'usage CGP::CLI->StoreDomainSkinFile($domainName,$skinName,$fileName,$base64data)'
2476 unless defined $domain && defined $skin && defined $fileName && defined $base64data;
2477 $this->send('StoreDomainSkinFile '.$domain.' SKIN '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DATA ['.$base64data.']');
2478 $this->_parseResponse();
2481 sub DeleteDomainSkinFile {
2482 my ( $this, $domain, $skin, $fileName ) = @_;
2483 croak 'usage CGP::CLI->DeleteDomainSkinFile($domainName,$skinName,$fileName)'
2484 unless defined $domain && defined $skin && defined $fileName;
2486 $this->send('StoreDomainSkinFile '.$domain.' SKIN '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DELETE');
2487 $this->_parseResponse();
2491 sub ListServerSkins {
2493 $this->send('ListServerSkins');
2494 return undef unless $this->_parseResponse();
2495 $this->parseWords($this->getWords);
2498 sub CreateServerSkin {
2499 my ( $this, $skin ) = @_;
2500 croak 'usage CGP::CLI->CreateServerSkin($skinName)'
2501 unless defined $skin;
2503 $this->send('CreateServerSkin '.$this->printWords($skin));
2504 $this->_parseResponse();
2507 sub RenameServerSkin {
2508 my ( $this, $skin, $newName ) = @_;
2509 croak 'usage CGP::CLI->RenameServerSkin($oldSkinName,$newSkinName)'
2510 unless defined $skin && defined $newName;
2512 $this->send('RenameServerSkin '.$this->printWords($skin).' INTO '.$this->printWords($newName));
2513 $this->_parseResponse();
2516 sub DeleteServerSkin {
2517 my ( $this, $skin ) = @_;
2518 croak 'usage CGP::CLI->DeleteServerSkin($skinName)'
2519 unless defined $skin;
2521 $this->send('DeleteServerSkin '.$this->printWords($skin));
2522 $this->_parseResponse();
2525 sub ListServerSkinFiles {
2526 my ( $this, $skin ) = @_;
2527 croak 'usage CGP::CLI->ListServerSkinFiles($skinName)'
2528 unless defined $skin;
2530 $this->send('ListServerSkinFiles '.$this->printWords($skin));
2531 return undef unless $this->_parseResponse();
2532 $this->parseWords($this->getWords);
2535 sub ReadServerSkinFile {
2536 my ( $this, $skin, $fileName ) = @_;
2537 croak 'usage CGP::CLI->ReadServerSkinFile($skinName,$fileName)'
2538 unless defined $skin && defined $fileName;
2540 $this->send('ReadServerSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName));
2541 return undef unless $this->_parseResponse();
2542 $this->parseWords($this->getWords);
2545 sub StoreServerSkinFile {
2546 my ( $this, $skin, $fileName,$data ) = @_;
2547 croak 'usage CGP::CLI->StoreServerSkinFile($skinName,$fileName,$base64data)'
2548 unless defined $skin && defined $fileName && defined $data;
2550 $this->send('StoreServerSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DATA ['.$data.']');
2551 $this->_parseResponse();
2554 sub DeleteServerSkinFile {
2555 my ( $this, $skin, $fileName ) = @_;
2556 croak 'usage CGP::CLI->DeleteServerSkinFile($skinName,$fileName)'
2557 unless defined $skin && defined $fileName;
2559 $this->send('StoreServerSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DELETE');
2560 $this->_parseResponse();
2564 sub ListClusterSkins {
2566 $this->send('ListClusterSkins');
2567 return undef unless $this->_parseResponse();
2568 $this->parseWords($this->getWords);
2571 sub CreateClusterSkin {
2572 my ( $this, $skin ) = @_;
2573 croak 'usage CGP::CLI->CreateClusterSkin($skinName)'
2574 unless defined $skin;
2576 $this->send('CreateClusterSkin '.$this->printWords($skin));
2577 $this->_parseResponse();
2580 sub RenameClusterSkin {
2581 my ( $this, $skin, $newName ) = @_;
2582 croak 'usage CGP::CLI->RenameClusterSkin($oldSkinName,$newSkinName)'
2583 unless defined $skin && defined $newName;
2585 $this->send('RenameClusterSkin '.$this->printWords($skin).' INTO '.$this->printWords($newName));
2586 $this->_parseResponse();
2589 sub DeleteClusterSkin {
2590 my ( $this, $skin ) = @_;
2591 croak 'usage CGP::CLI->DeleteClusterSkin($skinName)'
2592 unless defined $skin;
2594 $this->send('DeleteClusterSkin '.$this->printWords($skin));
2595 $this->_parseResponse();
2598 sub ListClusterSkinFiles {
2599 my ( $this, $skin ) = @_;
2600 croak 'usage CGP::CLI->ListClusterSkinFiles($skinName)'
2601 unless defined $skin;
2603 $this->send('ListClusterSkinFiles '.$this->printWords($skin));
2604 return undef unless $this->_parseResponse();
2605 $this->parseWords($this->getWords);
2608 sub ReadClusterSkinFile {
2609 my ( $this, $skin, $fileName ) = @_;
2610 croak 'usage CGP::CLI->ReadClusterSkinFile($skinName,$fileName)'
2611 unless defined $skin && defined $fileName;
2613 $this->send('ReadClusterSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName));
2614 return undef unless $this->_parseResponse();
2615 $this->parseWords($this->getWords);
2618 sub StoreClusterSkinFile {
2619 my ( $this, $skin, $fileName,$data ) = @_;
2620 croak 'usage CGP::CLI->StoreClusterSkinFile($skinName,$fileName,$base64data)'
2621 unless defined $skin && defined $fileName && defined $data;
2623 $this->send('StoreClusterSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DATA ['.$data.']');
2624 $this->_parseResponse();
2627 sub DeleteClusterSkinFile {
2628 my ( $this, $skin, $fileName ) = @_;
2629 croak 'usage CGP::CLI->DeleteClusterSkinFile($skinName,$fileName)'
2630 unless defined $skin && defined $fileName;
2632 $this->send('StoreClusterSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DELETE');
2633 $this->_parseResponse();
2636 #############################################
2637 # Web Interface Tuning
2639 sub ListWebUserInterface {
2640 my ($this, $domainName, $path) = @_;
2642 my $line = 'ListWebUserInterface';
2643 $line .= ' '.$domainName if($domainName);
2644 $line .= ' PATH '.$this->printWords($path) if($path);
2647 return undef unless $this->_parseResponse();
2648 $this->parseWords($this->getWords);
2651 sub GetWebUserInterface {
2652 my ($this, $domainName, $path) = @_;
2653 croak 'usage CGP::CLI->GetWebUserInterface($domainName, $fileName)'
2654 unless defined $domainName && defined $path;
2656 my $line = 'GetWebUserInterface '.$domainName.' FILE '.$this->printWords($path);
2658 return undef unless $this->_parseResponse();
2659 $this->parseWords($this->getWords);
2662 sub PutWebUserInterface {
2663 my ($this, $domainName, $path, $data) = @_;
2664 croak 'usage CGP::CLI->PutWebUserInterface($domainName, $fileName, $base64data)'
2665 unless defined $domainName && defined $path && defined $data;
2667 my $line = 'PutWebUserInterface '.$domainName;
2668 $line .= ' FILE '.$this->printWords($path).' DATA ['.$data.']';
2670 $this->_parseResponse();
2673 sub DeleteWebUserInterface {
2674 my ($this, $domainName, $path) = @_;
2675 croak 'usage CGP::CLI->DeleteWebUserInterface($domainName, $fileName)'
2676 unless defined $domainName && defined $path;
2678 my $line = 'DeleteWebUserInterface ';
2679 $line .= ' '.$domainName if($domainName);
2680 $line .= ' FILE '.$this->printWords($path) if($path);
2683 $this->_parseResponse();
2686 sub ClearWebUserCache {
2687 my ($this, $domainName) = @_;
2689 my $line = 'ClearWebUserCache';
2690 $line .= ' '.$domainName if($domainName);
2693 $this->_parseResponse();
2696 #############################################
2697 # Web Interface Integration
2699 sub CreateWebUserSession {
2700 my ($this, $accountName, $ipAddress, $wml,$skin,$origAddress) = @_;
2701 croak 'usage CGP::CLI->CreateWebUserSession($accountName, $IP_Address[, "WML"[,"mySkin"]][,$origAddress )'
2702 unless defined $accountName && defined $ipAddress;
2703 my $line='CreateWebUserSession '.$accountName.' ADDRESS '.$ipAddress;
2704 $line .= " FOR $origAddress" if($origAddress);
2705 $line .= " $wml" if($wml);
2706 $line .= " SKIN $skin" if($skin);
2709 return undef unless $this->_parseResponse();
2710 $this->parseWords($this->getWords);
2713 sub CreateXIMSSSession {
2714 my ($this, $accountName, $ipAddress,$origAddress) = @_;
2715 croak 'usage CGP::CLI->CreateXIMSSSession($accountName, $IP_Address,[$origAddress] )'
2716 unless defined $accountName && defined $ipAddress;
2717 my $line='CreateXIMSSSession '.$accountName.' ADDRESS '.$ipAddress;
2718 $line .= " FOR $origAddress" if($origAddress);
2720 return undef unless $this->_parseResponse();
2721 $this->parseWords($this->getWords);
2724 sub FindWebUserSession {
2725 my ($this, $accountName,$address) = @_;
2726 croak 'usage CGP::CLI->FindWebUserSession($accountName [,$address])' unless defined $accountName;
2728 my $line='FindWebUserSession '.$accountName;
2729 $line .= ' ADDRESS '.$address if($address);
2732 return undef unless $this->_parseResponse();
2733 $this->parseWords($this->getWords);
2736 sub GetWebUserSession {
2737 my ($this, $sessionID,$domain) = @_;
2738 croak 'usage CGP::CLI->GetWebUserSession($sessionID [,$domain])' unless defined $sessionID;
2740 my $line='GetWebUserSession '.$sessionID;
2741 $line .= ' DOMAIN '.$domain if($domain);
2744 return undef unless $this->_parseResponse();
2745 $this->parseWords($this->getWords);
2748 sub FindAccountSession {
2749 my ($this, $accountName,$address,$proxiedAddress,$protocol,$transport,$client) = @_;
2750 croak 'usage CGP::CLI->FindAccountSession($accountName [,$address,$proxiedAddress,$protocol,$transport,$client])' unless defined $accountName;
2752 my $line='FindAccountSession '.$accountName;
2753 $line .= ' ADDRESS '.$address if($address);
2754 $line .= ' FOR '.$proxiedAddress if($proxiedAddress);
2755 $line .= ' PROTOCOL '.$protocol if($protocol);
2756 $line .= ' TRANSPORT '.$transport if($transport);
2757 $line .= ' CLIENT '.$client if($client);
2759 return undef unless $this->_parseResponse();
2760 $this->parseWords($this->getWords);
2764 my ($this, $sessionID,$domain) = @_;
2765 croak 'usage CGP::CLI->GetSession($sessionID [,$domain])' unless defined $sessionID;
2767 my $line='GetSession '.$sessionID;
2768 $line .= ' DOMAIN '.$domain if($domain);
2771 return undef unless $this->_parseResponse();
2772 $this->parseWords($this->getWords);
2777 sub KillWebUserSession {
2778 my ($this, $sessionID,$domain) = @_;
2779 croak 'usage CGP::CLI->KillWebUserSession($sessionID [,$domain])' unless defined $sessionID;
2780 my $line='KillWebUserSession '.$sessionID;
2781 $line .= ' DOMAIN '.$domain if($domain);
2784 $this->_parseResponse();
2787 my ($this, $sessionID,$domain) = @_;
2788 croak 'usage CGP::CLI->KillSession($sessionID [,$domain])' unless defined $sessionID;
2789 my $line='KillSession '.$sessionID;
2790 $line .= ' DOMAIN '.$domain if($domain);
2793 $this->_parseResponse();
2796 #############################################
2797 # Real-Time Application Administration
2799 sub CreateDomainPBX {
2800 my ( $this, $domain, $language ) = @_;
2801 croak 'usage CGP::CLI->CreateDomainPBX($domainName,$language)'
2802 unless defined $domain;
2803 my $line = 'CreateDomainPBX '.$domain;
2804 $line .= ' FILE '.$this->printWords($language) if($language);
2807 $this->_parseResponse();
2809 sub DeleteDomainPBX {
2810 my ( $this, $domain, $language ) = @_;
2811 croak 'usage CGP::CLI->Deleref($ret)teDomainPBX($domainName,$language)'
2812 unless defined $domain && defined $language;
2813 my $line = 'DeleteDomainPBX '.$domain . ' FILE '.$this->printWords($language);
2816 $this->_parseResponse();
2819 sub ListDomainPBXFiles {
2820 my ($this, $domain,$language) = @_;
2821 croak 'usage CGP::CLI->ListDomainPBXFiles($domainName,$language)'
2822 unless defined $domain;
2823 my $line = 'ListDomainPBXFiles '.$domain;
2824 $line .= ' FILE '.$this->printWords($language) if($language);
2826 return undef unless $this->_parseResponse();
2827 $this->parseWords($this->getWords);
2830 sub ReadDomainPBXFile {
2831 my ( $this, $domain, $fileName ) = @_;
2832 croak 'usage CGP::CLI->ReadDomainPBXFile($domainName,$fileName)'
2833 unless defined $domain && defined $fileName;
2835 $this->send('ReadDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName));
2836 return undef unless $this->_parseResponse();
2837 $this->parseWords($this->getWords);
2840 sub StoreDomainPBXFile {
2841 my ( $this, $domain, $fileName,$base64data ) = @_;
2842 croak 'usage CGP::CLI->StoreDomainPBXFile($domainName,$fileName,$base64data)'
2843 unless defined $domain && defined $fileName && defined $base64data;
2844 $base64data='['.$base64data.']' unless($base64data=~/^\[.*\]$/);
2845 $this->send('StoreDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName).' DATA '.$base64data);
2846 $this->_parseResponse();
2849 sub DeleteDomainPBXFile {
2850 my ( $this, $domain, $fileName ) = @_;
2851 croak 'usage CGP::CLI->DeleteDomainPBXFile($domainName,$fileName)'
2852 unless defined $domain && defined $fileName;
2854 $this->send('StoreDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName).' DELETE');
2855 $this->_parseResponse();
2860 sub CreateServerPBX {
2861 my ( $this, $language ) = @_;
2862 croak 'usage CGP::CLI->CreateServerPBX($language)'
2863 unless defined $language;
2864 my $line = 'CreateServerPBX '.$this->printWords($language);
2866 $this->_parseResponse();
2868 sub DeleteServerPBX {
2869 my ( $this, $language ) = @_;
2870 croak 'usage CGP::CLI->DeleteServerPBX($language)'
2871 unless defined $language;
2872 my $line = 'DeleteServerPBX ' .$this->printWords($language);
2874 $this->_parseResponse();
2877 sub ListServerPBXFiles {
2878 my ($this,$language) = @_;
2880 my $line = 'ListServerPBXFiles ';
2881 $line .= $this->printWords($language) if($language);
2883 return undef unless $this->_parseResponse();
2884 $this->parseWords($this->getWords);
2887 sub ReadServerPBXFile {
2888 my ( $this, $fileName ) = @_;
2889 croak 'usage CGP::CLI->ReadServerPBXFile($fileName)'
2890 unless defined $fileName;
2892 $this->send('ReadServerPBXFile '.$this->printWords($fileName));
2893 return undef unless $this->_parseResponse();
2894 $this->parseWords($this->getWords);
2897 sub StoreServerPBXFile {
2898 my ( $this, $fileName,$base64data ) = @_;
2899 croak 'usage CGP::CLI->StoreServerPBXFile($fileName,$base64data)'
2900 unless defined $fileName && defined $base64data;
2901 $base64data='['.$base64data.']' unless($base64data=~/^\[.*\]$/);
2902 $this->send('StoreServerPBXFile ' .$this->printWords($fileName).' DATA '.$base64data);
2903 $this->_parseResponse();
2906 sub DeleteServerPBXFile {
2907 my ( $this, $fileName ) = @_;
2908 croak 'usage CGP::CLI->DeleteServerPBXFile($fileName)'
2909 unless defined $fileName;
2911 $this->send('StoreServerPBXFile '.$this->printWords($fileName).' DELETE');
2912 $this->_parseResponse();
2917 sub CreateClusterPBX {
2918 my ( $this, $language ) = @_;
2919 croak 'usage CGP::CLI->CreateClusterPBX($language)'
2920 unless defined $language;
2921 my $line = 'CreateClusterPBX ' .$this->printWords($language);
2923 $this->_parseResponse();
2925 sub DeleteClusterPBX {
2926 my ( $this, $language ) = @_;
2927 croak 'usage CGP::CLI->DeleteClusterPBX($language)'
2928 unless defined $language;
2929 my $line = 'DeleteClusterPBX ' .$this->printWords($language);
2931 $this->_parseResponse();
2934 sub ListClusterPBXFiles {
2935 my ($this,$language) = @_;
2937 my $line = 'ListClusterPBXFiles ';
2938 $line .= $this->printWords($language) if($language);
2940 return undef unless $this->_parseResponse();
2941 $this->parseWords($this->getWords);
2944 sub ReadClusterPBXFile {
2945 my ( $this, $fileName ) = @_;
2946 croak 'usage CGP::CLI->ReadClusterPBXFile($fileName)'
2947 unless defined $fileName;
2949 $this->send('ReadClusterPBXFile '.$this->printWords($fileName));
2950 return undef unless $this->_parseResponse();
2951 $this->parseWords($this->getWords);
2954 sub StoreClusterPBXFile {
2955 my ( $this, $fileName,$base64data ) = @_;
2956 croak 'usage CGP::CLI->StoreClusterPBXFile($fileName,$base64data)'
2957 unless defined $fileName && defined $base64data;
2958 $base64data='['.$base64data.']' unless($base64data=~/^\[.*\]$/);
2959 $this->send('StoreClusterPBXFile ' .$this->printWords($fileName).' DATA '.$base64data);
2960 $this->_parseResponse();
2963 sub DeleteClusterPBXFile {
2964 my ( $this, $fileName ) = @_;
2965 croak 'usage CGP::CLI->DeleteClusterPBXFile($fileName)'
2966 unless defined $fileName;
2968 $this->send('StoreClusterPBXFile '.$this->printWords($fileName).' DELETE');
2969 $this->_parseResponse();
2972 #############################################
2973 # Real-Time Application Control
2976 my ($this, $account,$program,$entry,$param) = @_;
2977 croak 'usage CGP::CLI->StartPBXTask($account,$program[,$entryName,$param])'
2978 unless (defined $account && defined $program);
2979 my $line = "StartPBXTask $account PROGRAM $program";
2980 $line .= ' ENTRY '.$entry if($entry);
2981 $line .= ' PARAM '.$param if($param);
2983 return undef unless $this->_parseResponse();
2984 $this->parseWords($this->getWords);
2988 my ($this, $taskID,$eventName,$param) = @_;
2989 croak 'usage CGP::CLI->SendTaskEvent($taskID,$eventName[,$param])'
2990 unless (defined $taskID && defined $eventName);
2991 my $line = "SendTaskEvent $taskID EVENT ".$this->printWords($eventName);
2992 $line .= ' PARAM '.$param if($param);
2994 return undef unless $this->_parseResponse();
2995 $this->parseWords($this->getWords);
2998 my ($this, $taskID) = @_;
2999 croak 'usage CGP::CLI->KillNode($taskID)'
3000 unless (defined $taskID);
3001 my $line = "KillNode $taskID";
3003 $this->_parseResponse();
3006 sub ReadNodeStatus {
3007 my ($this, $taskID) = @_;
3008 croak 'usage CGP::CLI->ReadNodeStatus($taskID)'
3009 unless (defined $taskID);
3010 my $line = "ReadNodeStatus $taskID";
3012 return undef unless $this->_parseResponse();
3013 $this->parseWords($this->getWords);
3016 #############################################
3019 sub RemoveAccountSubset {
3020 my ($this, $account, $subset) = @_;
3021 croak 'usage CGP::CLI->RemoveAccountSubset($account,$subset)'
3022 unless defined $account && defined $subset;
3023 $this->send('RemoveAccountSubset '.$account.' SUBSET '.$this->printWords($subset));
3024 return undef unless $this->_parseResponse();
3028 my ($this, $account, $params) = @_;
3029 croak 'usage CGP::CLI->Roster($account,\%params)'
3030 unless defined $account && defined $params;
3031 $this->send('Roster '.$account.' '.$this->printWords($params));
3032 return undef unless $this->_parseResponse();
3033 $this->parseWords($this->getWords);
3037 my ($this, $account, $params) = @_;
3038 croak 'usage CGP::CLI->Balance($account,\%params)'
3039 unless defined $account && defined $params;
3040 $this->send('Balance '.$account.' '.$this->printWords($params));
3041 return undef unless $this->_parseResponse();
3042 $this->parseWords($this->getWords);
3045 #############################################
3049 my ( $this, $moduleName ) = @_;
3050 $this->send('GetModule '.$moduleName);
3051 return undef unless $this->_parseResponse();
3052 $this->parseWords($this->getWords);
3056 my ( $this, $moduleName, $newSettings ) = @_;
3057 croak 'usage CGP::CLI->UpdateModule($moduleName, \%newSettings)'
3058 unless defined $moduleName && defined $newSettings;
3059 $this->send ('UpdateModule '.$moduleName.' '.$this->printWords($newSettings) );
3060 $this->_parseResponse();
3064 my ( $this, $moduleName, $newSettings ) = @_;
3065 croak 'usage CGP::CLI->SetModule($moduleName, \%newSettings)'
3066 unless defined $moduleName && defined $newSettings;
3067 $this->send ('SetModule '.$moduleName.' '.$this->printWords($newSettings) );
3068 $this->_parseResponse();
3071 sub GetQueueSettings {
3073 $this->send('GetQueueSettings');
3074 return undef unless $this->_parseResponse();
3075 $this->parseWords($this->getWords);
3077 sub SetQueueSettings {
3078 my ( $this, $newSettings ) = @_;
3079 croak 'usage CGP::CLI->SetQueueSettings(\%newSettings)'
3080 unless defined $newSettings;
3081 $this->send ('SetQueueSettings '.$this->printWords($newSettings) );
3082 $this->_parseResponse();
3085 sub GetSignalSettings {
3087 $this->send('GetSignalSettings');
3088 return undef unless $this->_parseResponse();
3089 $this->parseWords($this->getWords);
3091 sub SetSignalSettings {
3092 my ( $this, $newSettings ) = @_;
3093 croak 'usage CGP::CLI->SetSignalSettings(\%newSettings)'
3094 unless defined $newSettings;
3095 $this->send ('SetSignalSettings '.$this->printWords($newSettings) );
3096 $this->_parseResponse();
3098 sub GetMediaServerSettings {
3100 $this->send('GetMediaServerSettings');
3101 return undef unless $this->_parseResponse();
3102 $this->parseWords($this->getWords);
3104 sub SetMediaServerSettings {
3105 my ( $this, $newSettings ) = @_;
3106 croak 'usage CGP::CLI->SetMediaServerSettings(\%newSettings)'
3107 unless defined $newSettings;
3108 $this->send ('SetMediaServerSettings '.$this->printWords($newSettings) );
3109 $this->_parseResponse();
3112 sub GetSessionSettings {
3114 $this->send('GetSessionSettings');
3115 return undef unless $this->_parseResponse();
3116 $this->parseWords($this->getWords);
3118 sub SetSessionSettings {
3119 my ( $this, $newSettings ) = @_;
3120 croak 'usage CGP::CLI->SetSessionSettings(\%newSettings)'
3121 unless defined $newSettings;
3122 $this->send ('SetSessionSettings '.$this->printWords($newSettings) );
3123 $this->_parseResponse();
3127 sub GetClusterSettings {
3129 $this->send('GetClusterSettings');
3130 return undef unless $this->_parseResponse();
3131 $this->parseWords($this->getWords);
3133 sub SetClusterSettings {
3134 my ( $this, $newSettings ) = @_;
3135 croak 'usage CGP::CLI->SetClusterSettings(\%newSettings)'
3136 unless defined $newSettings;
3137 $this->send ('SetClusterSettings '.$this->printWords($newSettings) );
3138 $this->_parseResponse();
3144 $this->send('GetLANIPs');
3145 return undef unless $this->_parseResponse();
3146 $this->parseWords($this->getWords);
3149 sub GetBlacklistedIPs {
3151 $this->send('GetBlacklistedIPs');
3152 return undef unless $this->_parseResponse();
3153 $this->parseWords($this->getWords);
3158 $this->send('GetClientIPs');
3159 return undef unless $this->_parseResponse();
3160 $this->parseWords($this->getWords);
3163 sub GetWhiteHoleIPs {
3165 $this->send('GetWhiteHoleIPs');
3166 return undef unless $this->_parseResponse();
3167 $this->parseWords($this->getWords);
3171 $this->send('GetNATedIPs');
3172 return undef unless $this->_parseResponse();
3173 $this->parseWords($this->getWords);
3177 $this->send('GetDebugIPs');
3178 return undef unless $this->_parseResponse();
3179 $this->parseWords($this->getWords);
3183 $this->send('GetDeniedIPs');
3184 return undef unless $this->_parseResponse();
3185 $this->parseWords($this->getWords);
3190 $this->send('GetProtection');
3191 return undef unless $this->_parseResponse();
3192 $this->parseWords($this->getWords);
3197 $this->send('GetBanned');
3198 return undef unless $this->_parseResponse();
3199 $this->parseWords($this->getWords);
3203 my ( $this, $addresses ) = @_;
3204 croak 'usage CGP::CLI->SetLANIPs("10.0.0.1\e192.168.0.1")'
3205 unless defined $addresses;
3206 $this->send ('SetLANIPs '.$this->printWords($addresses));
3207 $this->_parseResponse();
3211 sub SetBlacklistedIPs {
3212 my ( $this, $addresses ) = @_;
3213 croak 'usage CGP::CLI->SetBlacklistedIPs("11.22.33.44\e55.66.77.88")'
3214 unless defined $addresses;
3215 $this->send ('SetBlacklistedIPs '.$this->printWords($addresses));
3216 $this->_parseResponse();
3220 my ( $this, $addresses ) = @_;
3221 croak 'usage CGP::CLI->SetClientIPs("11.22.33.44\e55.66.77.88")'
3222 unless defined $addresses;
3223 $this->send ('SetClientIPs '.$this->printWords($addresses));
3224 $this->_parseResponse();
3227 sub SetWhiteHoleIPs {
3228 my ( $this, $addresses ) = @_;
3229 croak 'usage CGP::CLI->SetWhiteHoleIPs("11.22.33.44\e55.66.77.88")'
3230 unless defined $addresses;
3231 $this->send ('SetWhiteHoleIPs '.$this->printWords($addresses));
3232 $this->_parseResponse();
3235 my ( $this, $addresses ) = @_;
3236 croak 'usage CGP::CLI->SetNATedIPs("192.168.0.1\e10.0.0.1")'
3237 unless defined $addresses;
3238 $this->send ('SetNATedIPs '.$this->printWords($addresses));
3239 $this->_parseResponse();
3242 my ( $this, $addresses ) = @_;
3243 croak 'usage CGP::CLI->SetDebugIPs("11.22.33.44\e55.66.77.88")'
3244 unless defined $addresses;
3245 $this->send ('SetDebugIPs '.$this->printWords($addresses));
3246 $this->_parseResponse();
3249 my ( $this, $addresses ) = @_;
3250 croak 'usage CGP::CLI->SetDeniedIPs("11.22.33.44\e55.66.77.88")'
3251 unless defined $addresses;
3252 $this->send ('SetDeniedIPs '.$this->printWords($addresses));
3253 $this->_parseResponse();
3257 my ( $this, $settings ) = @_;
3258 croak 'usage CGP::CLI->SetProtection(\%settings)'
3259 unless defined $settings;
3260 $this->send ('SetProtection '.$this->printWords($settings));
3261 $this->_parseResponse();
3265 my ( $this, $settings ) = @_;
3266 croak 'usage CGP::CLI->SetBanned(\%settings)'
3267 unless defined $settings;
3268 $this->send ('SetBanned '.$this->printWords($settings));
3269 $this->_parseResponse();
3272 sub GetClusterLANIPs {
3274 $this->send('GetClusterLANIPs');
3275 return undef unless $this->_parseResponse();
3276 $this->parseWords($this->getWords);
3279 sub GetClusterBlacklistedIPs {
3281 $this->send('GetClusterBlacklistedIPs');
3282 return undef unless $this->_parseResponse();
3283 $this->parseWords($this->getWords);
3286 sub GetClusterClientIPs {
3288 $this->send('GetClusterClientIPs');
3289 return undef unless $this->_parseResponse();
3290 $this->parseWords($this->getWords);
3293 sub GetClusterWhiteHoleIPs {
3295 $this->send('GetClusterWhiteHoleIPs');
3296 return undef unless $this->_parseResponse();
3297 $this->parseWords($this->getWords);
3299 sub GetClusterNATedIPs {
3301 $this->send('GetClusterNATedIPs');
3302 return undef unless $this->_parseResponse();
3303 $this->parseWords($this->getWords);
3305 sub GetClusterDebugIPs {
3307 $this->send('GetClusterDebugIPs');
3308 return undef unless $this->_parseResponse();
3309 $this->parseWords($this->getWords);
3311 sub GetClusterDeniedIPs {
3313 $this->send('GetClusterDeniedIPs');
3314 return undef unless $this->_parseResponse();
3315 $this->parseWords($this->getWords);
3318 sub GetClusterProtection {
3320 $this->send('GetClusterProtection');
3321 return undef unless $this->_parseResponse();
3322 $this->parseWords($this->getWords);
3324 sub GetClusterBanned {
3326 $this->send('GetClusterBanned');
3327 return undef unless $this->_parseResponse();
3328 $this->parseWords($this->getWords);
3331 sub SetClusterLANIPs {
3332 my ( $this, $addresses ) = @_;
3333 croak 'usage CGP::CLI->SetClusterLANIPs("10.0.0.1\e192.168.0.1")'
3334 unless defined $addresses;
3335 $this->send ('SetClusterLANIPs '.$this->printWords($addresses));
3336 $this->_parseResponse();
3339 sub SetClusterBlacklistedIPs {
3340 my ( $this, $addresses ) = @_;
3341 croak 'usage CGP::CLI->SetClusterBlacklistedIPs("11.22.33.44\e55.66.77.88")'
3342 unless defined $addresses;
3343 $this->send ('SetClusterBlacklistedIPs '.$this->printWords($addresses));
3344 $this->_parseResponse();
3347 sub SetClusterClientIPs {
3348 my ( $this, $addresses ) = @_;
3349 croak 'usage CGP::CLI->SetClusterClientIPs("11.22.33.44\e55.66.77.88")'
3350 unless defined $addresses;
3351 $this->send ('SetClusterClientIPs '.$this->printWords($addresses));
3352 $this->_parseResponse();
3355 sub SetClusterWhiteHoleIPs {
3356 my ( $this, $addresses ) = @_;
3357 croak 'usage CGP::CLI->SetClusterWhiteHoleIPs("11.22.33.44\e55.66.77.88")'
3358 unless defined $addresses;
3359 $this->send ('SetClusterWhiteHoleIPs '.$this->printWords($addresses));
3360 $this->_parseResponse();
3362 sub SetClusterNATedIPs {
3363 my ( $this, $addresses ) = @_;
3364 croak 'usage CGP::CLI->SetClusterNATedIPs("192.168.0.1\e10.0.0.1")'
3365 unless defined $addresses;
3366 $this->send ('SetClusterNATedIPs '.$this->printWords($addresses));
3367 $this->_parseResponse();
3369 sub SetClusterDebugIPs {
3370 my ( $this, $addresses ) = @_;
3371 croak 'usage CGP::CLI->SetClusterDebugIPs("11.22.33.44\e55.66.77.88")'
3372 unless defined $addresses;
3373 $this->send ('SetClusterDebugIPs '.$this->printWords($addresses));
3374 $this->_parseResponse();
3376 sub SetClusterDeniedIPs {
3377 my ( $this, $addresses ) = @_;
3378 croak 'usage CGP::CLI->SetClusterDeniedIPs("11.22.33.44\e55.66.77.88")'
3379 unless defined $addresses;
3380 $this->send ('SetClusterDeniedIPs '.$this->printWords($addresses));
3381 $this->_parseResponse();
3384 sub SetClusterProtection {
3385 my ( $this, $settings ) = @_;
3386 croak 'usage CGP::CLI->SetClusterProtection(\%settings)'
3387 unless defined $settings;
3388 $this->send ('SetClusterProtection '.$this->printWords($settings));
3389 $this->_parseResponse();
3392 sub GetServerRules {
3394 $this->send('GetServerRules');
3395 return undef unless $this->_parseResponse();
3396 $this->parseWords($this->getWords);
3399 sub SetServerRules {
3400 my ($this, $rules) = @_;
3401 croak 'usage CGP::CLI->SetServerRules(\@rules)'
3402 unless defined $rules;
3403 $this->send('SetServerRules '.$this->printWords($rules));
3404 $this->_parseResponse();
3408 sub GetClusterRules {
3410 $this->send('GetClusterRules');
3411 return undef unless $this->_parseResponse();
3412 $this->parseWords($this->getWords);
3415 sub SetClusterRules {
3416 my ($this, $rules) = @_;
3417 croak 'usage CGP::CLI->SetClusterRules(\@rules)'
3418 unless defined $rules;
3419 $this->send('SetClusterRules '.$this->printWords($rules));
3420 $this->_parseResponse();
3423 sub GetServerMailRules {
3425 $this->send('GetServerMailRules');
3426 return undef unless $this->_parseResponse();
3427 $this->parseWords($this->getWords);
3430 sub SetServerMailRules {
3431 my ($this, $rules) = @_;
3432 croak 'usage CGP::CLI->SetServerMailRules(\@rules)'
3433 unless defined $rules;
3434 $this->send('SetServerMailRules '.$this->printWords($rules));
3435 $this->_parseResponse();
3438 #sub UpdateServerMailRule {
3439 # my ($this, $rule) = @_;
3440 # croak 'usage CGP::CLI->UpdateServerMailRules(\@rule)'
3441 # unless defined $rule;
3442 # $this->send('UpdateServerMailRule '.$this->printWords($rule));
3443 # $this->_parseResponse();
3446 sub GetServerSignalRules {
3448 $this->send('GetServerSignalRules');
3449 return undef unless $this->_parseResponse();
3450 $this->parseWords($this->getWords);
3453 sub SetServerSignalRules {
3454 my ($this, $rules) = @_;
3455 croak 'usage CGP::CLI->SetServerSignalRules(\@rules)'
3456 unless defined $rules;
3457 $this->send('SetServerSignalRules '.$this->printWords($rules));
3458 $this->_parseResponse();
3461 #sub UpdateServerSignalRule {
3462 # my ($this, $rule) = @_;
3463 # croak 'usage CGP::CLI->UpdateServerSignalRule(\@rule)'
3464 # unless defined $rule;
3465 # $this->send('UpdateServerSignalRule '.$this->printWords($rule));
3466 # $this->_parseResponse();
3469 sub GetClusterMailRules {
3471 $this->send('GetClusterMailRules');
3472 return undef unless $this->_parseResponse();
3473 $this->parseWords($this->getWords);
3476 sub SetClusterMailRules {
3477 my ($this, $rules) = @_;
3478 croak 'usage CGP::CLI->SetClusterMailRules(\@rules)'
3479 unless defined $rules;
3480 $this->send('SetClusterMailRules '.$this->printWords($rules));
3481 $this->_parseResponse();
3484 #sub UpdateClusterMailRule {
3485 # my ($this, $rule) = @_;
3486 # croak 'usage CGP::CLI->UpdateClusterMailRule(\@rule)'
3487 # unless defined $rule;
3488 # $this->send('UpdateClusterMailRule '.$this->printWords($rule));
3489 # $this->_parseResponse();
3492 sub GetClusterSignalRules {
3494 $this->send('GetClusterSignalRules');
3495 return undef unless $this->_parseResponse();
3496 $this->parseWords($this->getWords);
3499 sub SetClusterSignalRules {
3500 my ($this, $rules) = @_;
3501 croak 'usage CGP::CLI->SetClusterSignalRules(\@rules)'
3502 unless defined $rules;
3503 $this->send('SetClusterSignalRules '.$this->printWords($rules));
3504 $this->_parseResponse();
3507 #sub UpdateClusterSignalRule {
3508 # my ($this, $rule) = @_;
3509 # croak 'usage CGP::CLI->UpdateClusterSignalRule(\@rule)'
3510 # unless defined $rule;
3511 # $this->send('UpdateClusterSignalRule '.$this->printWords($rule));
3512 # $this->_parseResponse();
3519 $this->send('RefreshOSData');
3520 $this->_parseResponse();
3523 sub GetRouterTable {
3525 $this->send('GetRouterTable');
3526 return undef unless $this->_parseResponse();
3527 $this->parseWords($this->getWords);
3530 sub SetRouterTable {
3531 my ($this, $table) = @_;
3532 croak 'usage CGP::CLI->GetRouterTable("<addr1>=addr1\@domain.com\\e<addr2>=addr2\@domain.com\\e")'
3533 unless defined $table;
3534 $this->send('SetRouterTable '.$this->printWords($table));
3535 $this->_parseResponse();
3538 sub GetRouterSettings {
3540 $this->send('GetRouterSettings');
3541 return undef unless $this->_parseResponse();
3542 $this->parseWords($this->getWords);
3545 sub SetRouterSettings {
3546 my ($this, $settings) = @_;
3547 croak 'usage CGP::CLI->SetRouterSettings(\@settings)'
3548 unless defined $settings;
3549 $this->send('SetRouterSettings '.$this->printWords($settings));
3550 $this->_parseResponse();
3554 sub GetClusterRouterTable {
3556 $this->send('GetClusterRouterTable');
3557 return undef unless $this->_parseResponse();
3558 $this->parseWords($this->getWords);
3561 sub SetClusterRouterTable {
3562 my ($this, $table) = @_;
3563 croak 'usage CGP::CLI->SetClusterRouterTable("<addr1>=addr1\@domain.com\\e<addr2>=addr2\@domain.com\\e")'
3564 unless defined $table;
3565 $this->send('SetClusterRouterTable '.$this->printWords($table));
3566 $this->_parseResponse();
3570 sub GetServerIntercept {
3572 $this->send('GetServerIntercept');
3573 return undef unless $this->_parseResponse();
3574 $this->parseWords($this->getWords);
3576 sub SetServerIntercept {
3577 my ( $this, $settings ) = @_;
3578 croak 'usage CGP::CLI->SetServerIntercept(\%settings)'
3579 unless defined $settings;
3580 $this->send ('SetServerIntercept '.$this->printWords($settings));
3581 $this->_parseResponse();
3584 sub GetClusterIntercept {
3586 $this->send('GetClusterIntercept');
3587 return undef unless $this->_parseResponse();
3588 $this->parseWords($this->getWords);
3590 sub SetClusterIntercept {
3591 my ( $this, $settings ) = @_;
3592 croak 'usage CGP::CLI->SetClusterIntercept(\%settings)'
3593 unless defined $settings;
3594 $this->send ('SetClusterIntercept '.$this->printWords($settings));
3595 $this->_parseResponse();
3600 my ($this, $address, $mail) = @_;
3601 croak 'usage CGP::CLI->Route(address[,"mail"])'
3602 unless defined $address;
3603 my $line='Route '.$address;
3604 $line .= ' mail' if($mail);
3606 return undef unless $this->_parseResponse();
3607 $this->parseWords($this->getWords);
3610 #############################################
3611 # Monitoring commands
3613 sub GetSNMPElement {
3614 my ($this, $element) = @_;
3615 $this->send('GetSNMPElement '.$element);
3616 return undef unless $this->_parseResponse();
3617 $this->parseWords($this->getWords);
3619 sub GetStatElement {
3620 my ($this, $element) = @_;
3621 $this->send('GetStatElement '.$element);
3622 return undef unless $this->_parseResponse();
3623 $this->parseWords($this->getWords);
3625 sub GetNextStatName {
3626 my ($this, $element) = @_;
3627 $this->send('GetNextStatName '.$element);
3628 return undef unless $this->_parseResponse();
3629 $this->parseWords($this->getWords);
3633 my ($this, $dialogID) = @_;
3634 $this->send('GetDialogInfo '.$dialogID);
3635 return undef unless $this->_parseResponse();
3636 $this->parseWords($this->getWords);
3641 $this->send('SHUTDOWN');
3642 $this->_parseResponse();
3645 #############################################
3646 # Statistics commands
3648 sub GetAccountStat {
3649 my ($this, $account, $key) = @_;
3650 croak 'usage CGP::CLI->GetAccountStat($account[,$key])'
3651 unless defined $account;
3652 my $line = 'GetAccountStat '.$account;
3653 $line .= ' Key '.$key if $key;
3655 return undef unless $this->_parseResponse();
3656 $this->parseWords($this->getWords);
3659 sub ResetAccountStat {
3660 my ($this, $account, $key) = @_;
3661 croak 'usage CGP::CLI->ResetAccountStat($account[,$key])'
3662 unless defined $account;
3663 my $line = 'ResetAccountStat '.$account;
3664 $line .= ' Key '.$key if $key;
3666 $this->_parseResponse();
3670 my ($this, $domain, $key) = @_;
3671 croak 'usage CGP::CLI->GetDomainStat($domain[,$key])'
3672 unless defined $domain;
3673 my $line = 'GetDomainStat '.$domain;
3674 $line .= ' Key '.$key if $key;
3676 return undef unless $this->_parseResponse();
3677 $this->parseWords($this->getWords);
3680 sub ResetDomainStat {
3681 my ($this, $domain, $key) = @_;
3682 croak 'usage CGP::CLI->ResetDomainStat($domain[,$key])'
3683 unless defined $domain;
3684 my $line = 'ResetDomainStat '.$domain;
3685 $line .= ' Key '.$key if $key;
3687 $this->_parseResponse();
3690 #############################################
3691 # Miscellaneous commands
3694 my ($this, $level, $msg) = @_;
3695 croak 'usage CGP::CLI->WriteLog($level,$message)'
3696 unless defined $level && defined $msg;
3697 $this->send('WriteLog '.$level.' '.$this->printWords($msg));
3698 $this->_parseResponse();
3700 sub ReleaseSMTPQueue {
3701 my ($this, $queue) = @_;
3702 croak 'usage CGP::CLI->ReleaseSMTPQueue($queueName)'
3703 unless defined $queue;
3704 $this->send('ReleaseSMTPQueue '.$this->printWords($queue));
3705 $this->_parseResponse();
3707 sub RejectQueueMessage {
3708 my ($this, $msg, $text) = @_;
3709 croak 'usage CGP::CLI->RejectQueueMessage($msgID [,$errorText])'
3710 unless defined $msg;
3711 my $line = 'RejectQueueMessage '.$msg;
3712 $line .= " ".$this->printWords($text) if $text;
3714 $this->_parseResponse();
3716 sub GetMessageQueueInfo {
3717 my ($this, $moduleName, $queueName) = @_;
3718 croak 'usage CGP::CLI->GetMessageQueueInfo($moduleName,$queueName)'
3719 unless (defined $moduleName && defined $queueName);
3720 my $line = 'GetMessageQueueInfo '.$moduleName.' QUEUE '.$this->printWords($queueName);
3722 return undef unless $this->_parseResponse();
3723 $this->parseWords($this->getWords);
3726 sub GetCurrentController {
3728 $this->send('GetCurrentController');
3729 return undef unless $this->_parseResponse();
3730 $this->parseWords($this->getWords);
3732 sub GetTempClientIPs {
3734 $this->send('GetTempClientIPs');
3735 return undef unless $this->_parseResponse();
3736 $this->parseWords($this->getWords);
3738 sub GetTempBlacklistedIPs {
3740 $this->send('GetTempBlacklistedIPs');
3741 return undef unless $this->_parseResponse();
3742 $this->parseWords($this->getWords);
3744 sub SetTempBlacklistedIPs {
3745 my ( $this, $addresses ) = @_;
3746 croak 'usage CGP::CLI->SetTempBlacklistedIPs("111.11.1.1\e222.2.2.2")'
3747 unless defined $addresses;
3748 $this->send ('SetTempBlacklistedIPs '.$this->printWords($addresses));
3749 $this->_parseResponse();
3753 #########################################################################
3754 #########################################################################
3755 ## Internal routines
3757 sub _setStrangeError
3759 my ($this, $line, $code) = @_;
3762 $this->{errCode} = $code;
3766 $this->{errCode} = $CGP::CLI_CODE_STRANGE;
3768 $this->{errMsg} = $line;
3776 my $responseLine = $this->{theSocket}->getline();
3779 print STDERR "CGP::CLI->_parseResponse::responseLine = $responseLine\n\n"
3780 if $this->{'debug'};
3782 $responseLine =~ /^(\d+)\s(.*)$/;
3783 return $this->_setStrangeError($responseLine) unless ($1);
3784 $this->{errCode} = $1;
3785 if($1 == $CGP::CLI_CODE_OK_INLINE) {
3786 $this->{'inlineResponse'} = $2;
3787 $this->{errMsg} = 'OK';
3789 $this->{errMsg} = $2;
3790 chomp($this->{errMsg});
3791 $this->{errMsg} =~ s/\r$//;
3793 $this->{'lastAccess'}=time();
3799 my $translate = $_[1];
3800 if(!defined($data)) {
3802 } elsif(ref($data) eq 'HASH') {
3805 foreach (sort keys %$data) {
3806 my $value=@$data{$_};
3807 $outp .= convertOutput($_,$translate).'='.convertOutput($value,$translate).';';
3813 } elsif(ref($data) eq 'ARRAY') {
3817 if(!$first) { $outp.=','; } else { $first=0; }
3818 $outp.=convertOutput($_,$translate);
3823 if($data =~ /[\W_]/ || $data eq '') {
3825 $data =~ s/\\((?![enr\d]))/\\\\$1/g;
3826 $data =~ s/\"/\\\"/g;
3828 $data =~ s/([\x00-\x1F\x7F])/'\\'.('0'x(3-length(ord($1)))).ord($1)/ge;
3830 return '"' . $data . '"';
3838 my ($this,$data)= @_;
3839 return convertOutput($data,$this->{'translateStrings'});
3852 if($this->{errCode} == $CGP::CLI_CODE_OK_INLINE) {
3853 return $this->{'inlineResponse'};
3855 my ($bag, $line) = ('', '');
3859 $line = $this->{theSocket}->getline();
3861 $line = strip($line);
3865 $lastLine = '\)' if $1 eq '(';
3866 $lastLine = '\}' if $1 eq '{';
3867 $lastLine = $lastLine . '$';
3872 last if $line =~ /$lastLine/;
3879 my ($this, $command) = @_;
3881 if(time()-$this->{'lastAccess'} > $CGP::TIMEOUT ||
3882 !($this->{theSocket}) ||
3883 $this->{theSocket}->error()) {
3884 $this->{theSocket}->shutdown(SHUT_RDWR) if($this->{theSocket});
3885 unless($this->connect()) {
3886 die "Failure: Can't reopen CLI connection";
3890 $this->{currentCGateCommand} = $command;
3891 print STDERR ref($this) . "->send($command)\n\n"
3892 if $this->{'debug'};
3893 $this->{'lastAccess'}=time();
3894 print {$this->{theSocket}} $command."\012";
3898 ###########################
3902 while($this->{'span'} < $this->{'len'} && substr($this->{'data'},$this->{'span'},1) =~ /\s/) { ++$this->{'span'}; }
3911 $this->skipSpaces();
3912 if(substr($this->{'data'},$this->{'span'},1) eq '"') {
3913 $isQuoted=1; ++$this->{'span'};
3914 } elsif(substr($this->{'data'},$this->{'span'},1) eq '[') {
3917 while($this->{'span'} < $this->{'len'}) {
3918 my $ch=substr($this->{'data'},$this->{'span'},1);
3922 if(substr($this->{'data'},$this->{'span'}+1,3) =~ /^(?:\"|\\|\d\d\d)/) {
3923 $ch=substr($this->{'data'},++$this->{'span'},3);
3924 if($ch =~ /\d\d\d/) {
3928 $ch=substr($ch,0,1);
3929 $ch='\\'.$ch unless($this->{'translateStrings'});
3932 } elsif($ch eq '"') {
3934 $this->skipSpaces();
3935 if(substr($this->{'data'},$this->{'span'},1) eq '"') {
3944 $this->skipSpaces();
3945 if(substr($this->{'data'},$this->{'span'},1) eq '[') {
3953 } elsif($ch =~ /[-a-zA-Z0-9\x80-\xff_\.\@\!\#\%\:]/) {
3966 return $this->readWord();
3972 my $startSpan=$this->{'span'};
3974 $this->readXMLElem();
3975 if(substr($this->{'data'},$this->{'span'},1) ne '<') {
3981 return substr($this->{'data'},$startSpan-1,$this->{'span'}-$startSpan+1);
3988 my $endPos=index($this->{'data'},'>',$this->{'span'});
3989 if($endPos<$this->{'span'}-1) {
3990 croak "XML parsing error:",substr($this->{'data'},$this->{'span'}-1,100);
3992 if(substr($this->{'data'},$endPos-1,1) eq '/') { # <tag attr="..." />
3993 $this->{'span'}=$endPos+1;
3996 if(substr($this->{'data'},$this->{'span'},1)=~/[\!\?]/) { # <! or <?
3997 $this->{'span'}=$endPos+1;
4000 unless(substr($this->{'data'},$this->{'span'},$endPos - $this->{'span'}+1) =~/(.+?)[ \>]/) {
4001 croak "XML reading error:",substr($this->{'data'},$this->{'span'}-1,100);
4004 #print "endElement=$1\n";
4005 $this->{'span'}=$endPos+1;
4006 #print "parsed=".substr($this->{'data'},$this->{'span'},10)."\n";
4007 $this->{'span'}++ while($this->{'span'} < $this->{'len'} && substr($this->{'data'},$this->{'span'},1) ne '<');
4008 while($this->{'span'} < $this->{'len'}) {
4009 if(substr($this->{'data'},$this->{'span'},$this->{'len'} - $this->{'span'})=~/^\<\/$element\>/) { #found closing element
4010 my $endPos=index($this->{'data'},'>',$this->{'span'}+1);
4011 $this->{'span'}=$endPos+1;
4015 $this->readXMLElem();
4022 $this->skipSpaces();
4023 my $ch=substr($this->{'data'},$this->{'span'},1);
4026 return $this->readDictionary();
4027 } elsif($ch eq '(') {
4029 return $this->readArray();
4030 } elsif($ch eq '<') {
4032 return $this->readXML();
4034 return $this->readWord();
4041 while($this->{'span'}<$this->{'len'}) {
4042 $this->skipSpaces();
4043 if(substr($this->{'data'},$this->{'span'},1) eq ')') {
4047 my $theValue=$this->readValue();
4048 $this->skipSpaces();
4049 push(@$result,$theValue);
4050 if(substr($this->{'data'},$this->{'span'},1) eq ',') {
4052 } elsif(substr($this->{'data'},$this->{'span'},1) eq ')') {
4054 croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10);
4061 sub readDictionary {
4064 while($this->{'span'} < $this->{'len'}) {
4065 $this->skipSpaces();
4066 if(substr($this->{'data'},$this->{'span'},1) eq '}') {
4070 my $theKey=$this->readKey();
4071 $this->skipSpaces();
4072 if(substr($this->{'data'},$this->{'span'},1) ne '=') { croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10); }
4074 @$result{$theKey}=$this->readValue();
4075 $this->skipSpaces();
4076 if(substr($this->{'data'},$this->{'span'},1) ne ';') { croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10); }
4086 $this->{'data'}=shift;
4088 $this->{'len'}=length($this->{'data'});
4089 return $this->readValue();
4103 See http://www.stalker.com/CGPerl/
4107 CommunigatePro Command Line Interface perl module.
4109 This is Stalker's CLI.pm packaged for CPAN.
4110 The original CLI.pm file is available from Stalker's website at:
4112 http://www.stalker.com/CGPerl/CLI.pm
4114 The only changes are the addition of the VERSION variable for MakeMaker
4115 and this short POD at the end.
4119 Stalker, Inc. <support@stalker.com>