e19fffd71b7070a412901cd1c9339e7a523e46f4
[CGP-CLI.git] / lib / CGP / CLI.pm
1 ####################################################################
2 #  Perl interface to CommuniGate Pro CLI.
3 #
4 #  Version 2.7.5
5 #
6 #  Original location: <http://www.communigate.com/CGPerl/>
7 #  Revision history: <http://www.communigate.com/CGPerl/History.html>
8 #
9 #  See <http://www.communigate.com/CommuniGatePro/CLI.html> for the related info.
10 #
11 #  Mail your comments and error reports to <support@stalker.com>
12
13 ############################## Commands: 
14 # new
15 # Logout
16 # getErrCode
17 # getErrMessage
18 # isSuccess
19 # getErrCommand
20 # setStringsTranslateMode
21 # NewPassword
22 # SendCommand
23 # GetResponseData
24
25 ############################## Accounts commands
26 # ListAccounts
27 # CreateAccount 
28 # RenameAccount 
29 # DeleteAccount
30 # SetAccountType
31 # GetAccountSettings
32 # GetAccountEffectiveSettings
33 # UpdateAccountSettings
34 # SetAccountSettings
35 # SetAccountPassword
36 # VerifyAccountPassword
37 # GetAccountAliases
38 # SetAccountAliases
39 # [Get|Set]AccountTelnums
40 # [Get|Set]AccountRules
41 # [Get|Set]Account[Mail|Signal]Rules
42 # UpdateAccount[Mail|Signal]Rule
43 # SetAccountRules
44 # GetAccountRPOP
45 # SetAccountRPOP
46 # GetAccountRights
47 # SetAccountRights
48 # GetAccountInfo
49 # [Get|Set|Update]AccountPrefs
50 # GetEffectiveaAccountPrefs
51 # KillAccountSessions
52 # [Get|Set]AccountACL
53 # GetAccountACLRights
54
55 ############################## Group Commands
56 # ListGroups
57 # CreateGroup
58 # RenameGroup
59 # DeleteGroup
60 # GetGroup
61 # SetGroup
62
63 ############################## Forwarder Commands
64 # ListForwarders
65 # CreateForwarder
66 # RenameForwarder
67 # DeleteForwarder
68 # GetForwarder
69 # FindForwarders
70
71 ############################## Domain commands
72 # ListDomains
73 # MainDomainName
74 # [Get|Update|Set]DomainSettings
75 # GetDomainEffectiveSettings
76 # [Create|Rename|Delete]Domain
77 # [Suspend|Resume]Domain
78 # CreateSharedDomain
79 # CreateDirectoryDomain
80 # [Get|Set]DomainRules
81 # [Get|Set]DomainAliases
82 # ListAdminDomains
83 # [Insert|Delete]DirectoryRecords
84 # [Get|Set][Server|Cluster]TrustedCerts
85
86 # [Get|Set]DirectoryIntegration
87 # [Get|Set]ClusterDirectoryIntegration
88
89
90 # [Get|Update|Set]DomainDefaults
91 # [Get|Update|Set]ClusterDomainDefaults
92 # [Get|Update|Set]AllAccountsDefaults *
93 # [Get|Update|Set]ServerAccountsDefaults
94 # GetDomainLocation
95 # GetAccountLocation
96 # [Get|Update|Set]AccountDefaults
97 # [Get|Update|Set]ClusterAccountDefaults
98 # [Get|Set|Update]AccountDefaultPrefs
99 # [Get|Set][Server|Cluster]AccountPrefs
100 # [Get|Update|Set]AccountTemplate
101
102 ############################## Mailbox Administration
103 # ListMailboxes
104 # [Create|Rename|Delete]Mailbox
105 # [Rename|Delete]Mailboxes
106 # GetMailboxInfo
107 # [Get|Set]MailboxACL
108 # GetMailboxRights
109 # SetMailboxClass
110
111 # [Get|Set]AccountSubscription
112 # [Get|Set]MailboxAliases
113
114 ############################## Alerts Administration
115 # Get[Domain|Account|Server|Cluster]Alerts
116 # Set[Domain|Account|Server|Cluster]Alerts
117 # Post[Domain|Account|Server|Cluster]Alert
118 # Remove[Domain|Account|Server|Cluster]Alert
119
120 ############################## Personal Web Site Administration
121 # GetWebFile
122 # PutWebFile
123 # RenameWebFile
124 # DeleteWebFile
125 # ListWebFiles
126 # GetWebFilesInfo
127
128 ############################## Lists commands
129 # ListLists
130 # GetDomainLists
131 # GetAccountLists
132 # [Create|Rename|Delete|Get|Update]List
133 # List
134 # ListSubscribers
135 # GetSubscriberInfo
136 # SetPostingMode
137 # ProcessBounce
138
139 ############################## Web Skins Administration 
140 # ListDomainSkins( [domainName] )
141 # CreateDomainSkin(domainName,skinName)
142 # RenameDomainSkin(domainName,oldSkinName,newSkinName)
143 # DeleteDomainSkin(domainName,skinName)
144 # ListDomainSkinFiles(domainName,skinName)
145 # ReadDomainSkinFile(domainName,skinName,fileName)
146 # StoreDomainSkinFile(domainName,skinName,fileName,base64data)
147 # DeleteDomainSkinFile(domainName,skinName,fileName)
148
149 # ListServerSkins()
150 # CreateServerSkin(skinName)
151 # RenameServerSkin(oldSkinName,newSkinName)
152 # DeleteServerSkin(skinName)
153 # ListServerSkinFiles(skinName)
154 # ReadServerSkinFile(skinName,fileName)
155 # StoreServerSkinFile(skinName,fileName,base64data)
156 # DeleteServerSkinFile(skinName,fileName)
157
158 # ListClusterSkins()
159 # CreateClusterSkin(skinName)
160 # RenameClusterSkin(oldSkinName,newSkinName)
161 # DeleteClusterSkin(skinName)
162 # ListClusterSkinFiles(skinName)
163 # ReadClusterSkinFile(skinName,fileName)
164 # StoreClusterSkinFile(skinName,fileName,base64data)
165 # DeleteClusterSkinFile(skinName,fileName)
166
167 ############################## Web Interface Tuning
168 # [List|Get|Put|Delete]WebUserInterface
169 # ClearWebUserCache
170
171 ############################## Web Interface Integration
172 # [Create|Get|Kill|Find]WebUserSession
173
174 ############################## Real-Time Application Administration
175 # Create[Domain|Server|Cluster]PBX
176 # List[Domain|Server|Cluster]PBXFiles
177 # [Read|Store|Delete][Domain|Server|Cluster]PBXFile
178
179 ############################## Server commands
180 # [Get|Update|Set]Module
181
182 # [Get|Set]LANIPs
183 # [Get|Set]BlacklistedIPs
184 # [Get|Set]ClientIPs 
185 # [Get|Set]WhiteHoleIPs 
186 # [Get|Set]Protection 
187 # [Get|Set]Banned
188
189 # [Get|Set]ClusterLANIPs
190 # [Get|Set]ClusterBlacklistedIPs
191 # [Get|Set]ClusterClientIPs 
192 # [Get|Set]ClusterWhiteHoleIPs 
193 # [Get|Set]ClusterProtection 
194 # GetClusterBanned
195
196 # [Get|Set][Server|Cluster]Rules
197 # [Get|Set][Server|Cluster][Mail|Signal]Rules
198 ## Update[Server|Cluster][Mail|Signal]Rule
199
200 # RefreshOSData
201 # [Get|Set]RouterTable
202 # [Get|Set]RouterSettings
203 # [Get|Set]ClusterRouterTable
204 # [Get|Set][Server|Cluster]Intercept
205
206 # Route
207
208 ############################## Monitoring commands
209 # GetSNMPElement
210 # Shutdown
211
212 ############################## Statistics commands
213 # [Get|Reset]AccountStat
214 # [Get|Reset]DomainStat
215
216 ############################## Miscellaneous commands
217 # WriteLog
218 # ReleaseSMTPQueue
219 # RejectQueueMessage
220 # GetMessageQueueInfo
221 # GetCurrentController
222 # GetTempClientIPs
223 # [Get|Set]TempBlacklistedIPs 
224 # RemoveAccountSubset
225 # List[Domain|Server|Cluster]Telnums
226
227 ##############################################################
228
229 package CGP::CLI;
230
231 use strict;
232 use Carp;
233
234 # You may need to change this to "use IO::Socket::INET;" if you have INET.pm
235 use IO::Socket;
236
237 # You may need to install this module.
238 # See <http://search.cpan.org/search?module=Digest::MD5>
239 use Digest::MD5;
240
241 use vars qw($VERSION);
242 ($VERSION) = '2.7.5';
243
244
245 $CGP::SECURE_LOGIN = 1;
246 $CGP::WEBUSER_LOGIN = 0;
247 $CGP::TIMEOUT = 60*5-5;  # 5 minutes timeout
248
249 $CGP::ERR_STRING = "No error";
250
251 $CGP::CLI_CODE_OK = 200;
252 $CGP::CLI_CODE_OK_INLINE = 201;
253
254 $CGP::CLI_CODE_PASSWORD = 300;
255 $CGP::CLI_CODE_UNKNOW_USER = 500;
256 $CGP::CLI_CODE_GEN_ERR = 501;
257 $CGP::CLI_CODE_STRANGE = 10000;
258
259
260
261
262 sub connect {
263   my ($this) = @_;
264   $this->{isConnected}=0;  
265   
266   delete $this->{theSocket};
267
268   $this->{theSocket} = new IO::Socket::INET( %{$this->{connParams}} );
269
270   unless(defined $this->{theSocket} && $this->{theSocket}) {
271     $CGP::ERR_STRING="Can't open connection to CGPro Server";
272     return undef;
273   };
274   $this->{theSocket}->autoflush(1);
275
276   unless($this->_parseResponse()) {
277     $CGP::ERR_STRING="Can't read CGPro Server prompt";
278     return undef;
279   };
280
281   if($this->{isSecureLogin} && $this->{errMsg} =~ /(\<.*\@*\>)/) {
282     my $md5=Digest::MD5->new;
283     if($md5) {
284       $md5->add($1.$this->{password});
285       $this->send('APOP '.$this->{login}.' '.$md5->hexdigest);
286       $this->_parseResponse();
287     } else {
288       $CGP::ERR_STRING="Can't create MD5 object";
289       close($this->{theSocket});
290       return undef;
291     }
292   } elsif($this->{isWebUserLogin}) {
293     $this->send('AUTH WEBUSER '.$this->{login}.' '.$this->{password});
294     $this->_parseResponse();
295   
296   } else {  
297     $this->send('USER '.$this->{login});
298     $this->_parseResponse();
299     unless( $this->{errCode} == $CGP::CLI_CODE_PASSWORD) {
300       $CGP::ERR_STRING="Unexpected answer: ".$this->{errCode};
301       close($this->{theSocket});
302       return undef;
303     }
304     $this->send('PASS '.$this->{password});
305     $this->_parseResponse();    
306   }
307
308   unless($this->isSuccess) {
309     $CGP::ERR_STRING=$this->{errMsg};
310     close($this->{theSocket});
311     return undef;
312   }
313   $this->send('INLINE');
314   $this->_parseResponse();
315   $this->setStringsTranslateMode(0);
316   $this->{isConnected}=1;  
317   1;
318 }
319
320
321 sub new {
322   my ($class, $params) = @_;
323   my $this = {};
324   
325   $this->{login} = delete $params->{'login'};
326   $this->{password} = delete $params->{'password'};
327
328   $this->{isSecureLogin} = delete $params->{'SecureLogin'};
329   $this->{isWebUserLogin} = delete $params->{'WebUserLogin'};
330   
331   
332   $this->{isSecureLogin} = $CGP::SECURE_LOGIN unless defined $this->{isSecureLogin};
333   $this->{isWebUserLogin} = $CGP::WEBUSER_LOGIN unless defined $this->{isWebUserLogin};
334
335
336   croak 'You must pass login parameter to CGP::CLI::new'
337     unless defined $this->{login};
338   croak 'You must pass password parameter to CGP::CLI::new'
339     unless defined $this->{password};
340
341   croak 'SecureLogin and WebUserLogin are mutually exclusive'
342     if($this->{isSecureLogin} && $this->{isWebUserLogin});
343
344   #print %$params;
345   bless $this;
346   $this->{connParams}=$params;
347   
348   if(!(defined $params->{'connectNow'}) || $params->{'connectNow'}) { 
349     unless($this->connect()) {
350       return undef;
351     }
352   }
353   $this;
354 }
355
356 sub DESTROY {
357   my $this = shift;
358   $this->Logout() if($this->{isConnected});
359 }
360
361 sub getErrCode {
362   my $this = shift;
363   return $this->{errCode};
364 }
365
366 sub getErrMessage {
367   my $this = shift;
368   return $this->{errMsg};
369 }
370
371 sub getErrCommand {
372   my $this = shift;
373   return $this->{'currentCGateCommand'};
374 }
375
376 sub isSuccess {
377   my $this = shift;
378   return ($this->{errCode} == $CGP::CLI_CODE_OK || $this->{errCode} == $CGP::CLI_CODE_OK_INLINE);
379 }
380
381 sub setDebug {
382   my ($this, $debugFlag) = @_;
383   $this->{'debug'} = $debugFlag;    
384 }
385
386 sub setStringsTranslateMode {
387   my ($this, $onFlag) = @_;
388   $this->{'translateStrings'} = $onFlag;    
389 }
390
391 sub Logout {
392   my $this = shift;
393   $this->send('QUIT');
394   $this->_parseResponse();
395   $this->{isConnected}=0;
396 }
397
398 sub NewPassword {
399   my ($this, $newPassword) = @_;
400   croak 'usage CGP::CLI->NewPassword($newPassword)'
401     unless defined $newPassword;
402   $this->send('NEWPASS '.$newPassword);
403   $this->_parseResponse();
404 }
405
406 sub SendCommand {
407   my ($this, $command) = @_;
408   croak 'usage CGP::CLI->SendCommand($commandString)'
409     unless defined $command;
410   $this->send($command);
411   $this->_parseResponse();
412 }    
413
414 sub GetResponseData {
415   my ($this) = @_;
416   $this->parseWords($this->getWords);
417 }    
418
419
420 ####################################################################
421 #    Account commands
422
423 sub ListDomainObjects {
424   my ($this, $domainName,$limit,$filter,$what,$cookie) = @_;
425   croak 'usage CGP::CLI->ListDomainObjects($domainName,$limit[,$filter][,$what][,$cookie])'
426       unless defined $domainName && defined $limit;
427   my $line = "ListDomainObjects $domainName";
428   $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
429   $line .= " $limit";
430   $line .= " $what" if $what;
431   $line .= " COOKIE ".$this->printWords($cookie) if defined $cookie;
432   $this->send($line);
433   return undef unless $this->_parseResponse();
434   $this->parseWords($this->getWords);
435 }    
436
437
438 sub ListAccounts {
439   my ($this, $domainName) = @_;
440   my $line = 'ListAccounts';
441   $line .= ' '.$domainName if $domainName;
442   $this->send($line);
443   return undef unless $this->_parseResponse();
444   $this->parseWords($this->getWords);
445 }    
446
447 sub ListDomainTelnums {
448   my ($this, $domainName,$limit,$filter) = @_;
449   croak 'usage CGP::CLI->ListDomainTelnums($domainName,$limit[,$filter])'
450       unless defined $domainName && defined $limit;
451   my $line = "ListDomainTelnums $domainName";
452   $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
453   $line .= " $limit";
454   $this->send($line);
455   return undef unless $this->_parseResponse();
456   $this->parseWords($this->getWords);
457 }    
458
459
460
461 sub CreateAccount {
462   my ($this) = shift;;
463   my %params = (@_);
464
465   croak 'usage CGP::CLI->CreateAccount(accountName => \'newAccountName\',
466                             accountType => \'accountType\',
467                             externalFlag => \'externalFlag\',
468                             settings     => $settings)'
469       unless exists $params{accountName};
470   my $line = 'CreateAccount '.$params{accountName};
471   $line .= ' ' . $params{accountType} if exists $params{accountType};
472   $line .= ' ' . 'external' if exists $params{externalFlag};
473   $line .= ' ' . $this->printWords($params{settings}) if exists $params{settings};
474
475   $this->send($line);
476   $this->_parseResponse();
477 }
478
479 sub RenameAccount {
480   my ($this, $oldAccountName, $newAccountName) = @_;
481   croak 'usage CGP::CLI->RenameAccount($oldAccountName, $newAccountName)'
482       unless defined $oldAccountName && defined $newAccountName;
483   $this->send('RenameAccount '.$oldAccountName.' into '.$newAccountName);
484   $this->_parseResponse();
485 }
486
487 sub DeleteAccount {
488   my ($this, $accountName) = @_;
489   croak 'usage CGP::CLI->DeleteAccount($accountName)'
490     unless defined $accountName;
491   $this->send('DeleteAccount '.$accountName);
492   $this->_parseResponse();
493 }
494 sub SetAccountType {
495   my ($this, $accountName,$type) = @_;
496   croak 'usage CGP::CLI->SetAccountType($accountName,$type)'
497     unless (defined $accountName && defined $type);
498   $this->send('SetAccountType '.$accountName.' '.$type);
499   $this->_parseResponse();
500 }
501
502 sub GetAccountSettings {
503   my ($this, $accountName) = @_;
504   croak 'usage CGP::CLI->GetAccountSettings($accountName)'
505     unless defined $accountName;
506   $this->send('GetAccountSettings '.$accountName);
507   return undef unless $this->_parseResponse();
508   $this->parseWords($this->getWords);
509 }
510
511 sub GetAccount {
512   GetAccountSettings(@_);
513 }
514
515 sub GetAccountEffectiveSettings {
516   my ($this, $accountName) = @_;
517   croak 'usage CGP::CLI->GetAccountEffectiveSettings($accountName)'
518     unless defined $accountName;
519   $this->send('GetAccountEffectiveSettings '.$accountName);
520   return undef unless $this->_parseResponse();
521   $this->parseWords($this->getWords);
522 }
523
524 sub UpdateAccountSettings {
525   my ($this, $accountName, $params) = @_;
526   croak 'usage CGP::CLI->UpdateAccountSettings($accountName, \%settings)'
527     unless defined $accountName;
528   $this->send('UpdateAccountSettings '.$accountName.' '.$this->printWords($params));
529   $this->_parseResponse();
530 }
531
532 sub UpdateAccount {
533   UpdateAccountSettings(@_);
534 }
535
536 sub SetAccountSettings {
537   my ($this, $accountName, $params) = @_;
538   croak 'usage CGP::CLI->SetAccountSettings($accountName, \%settings)'
539     unless defined $accountName;
540   $this->send('SetAccountSettings '.$accountName.' '.$this->printWords($params));
541   $this->_parseResponse();
542 }
543
544 sub SetAccount {
545   SetAccountSettings(@_);
546 }
547
548 sub SetAccountPassword {
549   my ($this, $accountName, $newPass) = @_;
550   croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword)'
551     unless defined $accountName && defined $newPass;
552   $this->send('SetAccountPassword '.$accountName.' TO '.$this->printWords($newPass));
553   $this->_parseResponse();
554 }
555
556 sub VerifyAccountPassword {
557   my ($this, $accountName, $pass) = @_;
558   croak 'usage CGP::CLI->VerifyAccountPassword($accountName, $password)'
559     unless defined $accountName && defined $pass;
560   $this->send('VerifyAccountPassword '.$accountName.' PASSWORD '.$this->printWords($pass));
561   $this->_parseResponse();
562 }
563
564
565 sub GetAccountAliases {
566   my ($this, $accountName) = @_;
567   croak 'usage CGP::CLI->GetAccountAliases($accountName)'
568     unless defined $accountName;
569   $this->send('GetAccountAliases '.$accountName);
570   return undef unless $this->_parseResponse();
571   $this->parseWords($this->getWords);
572 }
573
574 sub SetAccountAliases {
575   my ($this, $accountName, $aliases) = @_;
576   croak 'usage CGP::CLI->SetAccountAliases($accountName, \@aliases)'
577     unless defined $accountName && defined $aliases;
578   $this->send('SetAccountAliases '.$accountName.' '.$this->printWords($aliases));
579   $this->_parseResponse();
580 }
581
582 sub GetAccountTelnums {
583   my ($this, $accountName) = @_;
584   croak 'usage CGP::CLI->GetAccountTelnums($accountName)'
585     unless defined $accountName;
586   $this->send('GetAccountTelnums '.$accountName);
587   return undef unless $this->_parseResponse();
588   $this->parseWords($this->getWords);
589 }
590
591 sub SetAccountTelnums {
592   my ($this, $accountName, $aliases) = @_;
593   croak 'usage CGP::CLI->SetAccountTelnums($accountName, \@telnums)'
594     unless defined $accountName && defined $aliases;
595   $this->send('SetAccountTelnums '.$accountName.' '.$this->printWords($aliases));
596   $this->_parseResponse();
597 }
598
599
600 sub GetAccountRules {
601   my ($this, $accountName) = @_;
602   croak 'usage CGP::CLI->GetAccountRules($accountName)'
603     unless defined $accountName;
604   $this->send('GetAccountRules '.$accountName);
605   return undef unless $this->_parseResponse();
606   $this->parseWords($this->getWords);
607 }
608
609 sub SetAccountRules {
610   my ($this, $accountName, $rules) = @_;
611   croak 'usage CGP::CLI->SetAccountRules($accountName, \@rules)'
612     unless defined $accountName && defined $rules;
613   $this->send('SetAccountRules '.$accountName.' '.$this->printWords($rules));
614   $this->_parseResponse();
615 }
616
617 sub GetAccountMailRules {
618   my ($this, $accountName) = @_;
619   croak 'usage CGP::CLI->GetAccountMailRules($accountName)'
620     unless defined $accountName;
621   $this->send('GetAccountMailRules '.$accountName);
622   return undef unless $this->_parseResponse();
623   $this->parseWords($this->getWords);
624 }
625
626 sub SetAccountMailRules {
627   my ($this, $accountName, $rules) = @_;
628   croak 'usage CGP::CLI->SetAccountMailRules($accountName, \@rules)'
629     unless defined $accountName && defined $rules;
630   $this->send('SetAccountMailRules '.$accountName.' '.$this->printWords($rules));
631   $this->_parseResponse();
632 }
633 sub UpdateAccountMailRule {
634   my ($this, $accountName, $rule) = @_;
635   croak 'usage CGP::CLI->UpdateAccountMailRule($accountName, \@rule)'
636     unless defined $accountName && defined $rule;
637   $this->send('UpdateAccountMailRule '.$accountName.' '.$this->printWords($rule));
638   $this->_parseResponse();
639 }
640
641 sub GetAccountSignalRules {
642   my ($this, $accountName) = @_;
643   croak 'usage CGP::CLI->GetAccountSignalRules($accountName)'
644     unless defined $accountName;
645   $this->send('GetAccountSignalRules '.$accountName);
646   return undef unless $this->_parseResponse();
647   $this->parseWords($this->getWords);
648 }
649
650 sub SetAccountSignalRules {
651   my ($this, $accountName, $rules) = @_;
652   croak 'usage CGP::CLI->SetAccountSignalRules($accountName, \@rules)'
653     unless defined $accountName && defined $rules;
654   $this->send('SetAccountSignalRules '.$accountName.' '.$this->printWords($rules));
655   $this->_parseResponse();
656 }
657 sub UpdateAccountSignalRule {
658   my ($this, $accountName, $rule) = @_;
659   croak 'usage CGP::CLI->UpdateAccountSignalRule($accountName, \@rule)'
660     unless defined $accountName && defined $rule;
661   $this->send('UpdateAccountSignalRule '.$accountName.' '.$this->printWords($rule));
662   $this->_parseResponse();
663 }
664
665 sub GetAccountRPOP {
666   my ($this, $accountName) = @_;
667   croak 'usage CGP::CLI->GetAccountRPOP($accountName)'
668       unless defined $accountName;
669   $this->send('GetAccountRPOP '.$accountName);
670   return undef unless $this->_parseResponse();
671   $this->parseWords($this->getWords);
672 }
673
674 sub SetAccountRPOP {
675   my ($this, $accountName, $newRecords) = @_;
676   croak 'usage CGP::CLI->SetAccountAliases($accountName, \@newRecords)'
677     unless defined $accountName && defined $newRecords;
678   $this->send('SetAccountRPOP '.$accountName.' '.$this->printWords($newRecords));
679   $this->_parseResponse();
680 }
681
682 sub GetAccountRights {
683   my ($this, $account) = @_;
684   croak 'usage CGP::CLI->GetAccountRights($account)'
685     unless defined $account;
686   $this->send('GetAccountRights '.$account);
687   return undef unless $this->_parseResponse();
688   $this->parseWords($this->getWords);
689 }
690
691 sub SetAccountRights {
692   my ($this, $account, $list) = @_;
693   croak 'usage CGP::CLI->SetAccountRigthts($acount, \@list)'
694     unless defined $account && defined $list;
695   my $line = 'SetAccountRights '.$account.' '.$this->printWords($list);
696
697   $this->send($line);
698   $this->_parseResponse();
699 }
700
701 sub GetAccountInfo {
702   my ($this, $account, $key) = @_;
703   croak 'usage CGP::CLI->GetAccountInfo($account,$key)'
704     unless defined $account && defined $key;       
705   $this->send('GetAccountInfo '.$account.' Key '.$this->printWords($key));
706   return undef unless $this->_parseResponse();
707   $this->parseWords($this->getWords);      
708 }
709
710 sub GetWebUser {
711   my ($this, $account) = @_;
712   croak 'usage CGP::CLI->GetWebUser($account)'
713     unless defined $account;
714   $this->send('GetWebUser '.$account);
715   return undef unless $this->_parseResponse();
716   $this->parseWords($this->getWords);
717 }
718
719
720 sub GetAccountPrefs {
721   my ($this, $account) = @_;
722   croak 'usage CGP::CLI->GetAccountPrefs($account)'
723     unless defined $account;
724   $this->send('GetAccountPrefs '.$account);
725   return undef unless $this->_parseResponse();
726   $this->parseWords($this->getWords);
727 }
728
729 sub SetWebUser {
730   my ($this, $account, $settings) = @_;
731   croak 'usage CGP::CLI->SetWebUser($acount, \%settings)'
732     unless defined $account && defined $settings;
733   my $line = 'SetWebUser '.$account.' '.$this->printWords($settings);
734
735   $this->send($line);
736   $this->_parseResponse();
737 }
738
739 sub SetAccountPrefs {
740   my ($this, $account, $settings) = @_;
741   croak 'usage CGP::CLI->SetAccountPrefs($acount, \%settings)'
742     unless defined $account && defined $settings;
743   my $line = 'SetAccountPrefs '.$account.' '.$this->printWords($settings);
744
745   $this->send($line);
746   $this->_parseResponse();
747 }
748 sub UpdateAccountPrefs {
749   my ($this, $account, $settings) = @_;
750   croak 'usage CGP::CLI->UpdateAccountPrefs($acount, \%settings)'
751     unless defined $account && defined $settings;
752   my $line = 'UpdateAccountPrefs '.$account.' '.$this->printWords($settings);
753
754   $this->send($line);
755   $this->_parseResponse();
756 }
757
758
759 sub GetEffectiveWebUser {
760   my ($this, $account) = @_;
761   croak 'usage CGP::CLI->GetEffectiveWebUser($account)'
762     unless defined $account;
763   $this->send('GetEffectiveWebUser '.$account);
764   return undef unless $this->_parseResponse();
765   $this->parseWords($this->getWords);
766 }
767
768 sub GetEffectiveAccountPrefs {
769   my ($this, $account) = @_;
770   croak 'usage CGP::CLI->GetEffectiveAccountPrefs($account)'
771     unless defined $account;
772   $this->send('GetEffectiveAccountPrefs '.$account);
773   return undef unless $this->_parseResponse();
774   $this->parseWords($this->getWords);
775 }
776
777
778 sub KillAccountSessions {
779   my ($this, $account) = @_;
780   croak 'usage CGP::CLI->KillAccountSessions($account)'
781     unless defined $account;
782   $this->send('KillAccountSessions '.$account);
783   $this->_parseResponse();
784 }
785
786 sub GetAccountACL {
787   my ($this, $account,$authAccountName) = @_;
788   croak 'usage CGP::CLI->GetAccountACL($accountName [,authAccountName])'
789     unless defined $account;
790     
791   my $line = 'GetAccountACL '.$account;
792   $line .= ' AUTH '.$authAccountName if($authAccountName);
793   $this->send($line);
794   return undef unless $this->_parseResponse();
795   $this->parseWords($this->getWords);
796 }
797
798 sub SetAccountACL {
799   my ($this, $account, $newACL,$authAccountName) = @_;
800   croak 'usage CGP::CLI->SetAccountACL($acountACL, \%newACL [,$authAccountName])'
801     unless defined $account && defined $newACL;
802   my $line = 'SetAccountACL '.$account;
803   $line .= ' AUTH '.$authAccountName if($authAccountName);  
804   $line.=' '.$this->printWords($newACL);
805   $this->send($line);
806   $this->_parseResponse();
807 }
808
809 sub GetAccountACLRights {
810   my ($this, $account,$authAccountName) = @_;
811   croak 'usage CGP::CLI->GetAccountACLRights($accountName ,authAccountName)'
812     unless (defined $account && defined $authAccountName);
813     
814   my $line = 'GetAccountACLRights '.$account.' AUTH '.$authAccountName ;
815   $this->send($line);
816   return undef unless $this->_parseResponse();
817   $this->parseWords($this->getWords);
818 }
819
820 #################################################################
821 #  Group managent commands
822
823 sub ListGroups {
824   my ($this, $domainName) = @_;
825   my $line = 'ListGroups';
826   $line .= ' '.$domainName if $domainName;
827   $this->send($line);
828   return undef unless $this->_parseResponse();
829   $this->parseWords($this->getWords);
830 }    
831
832 sub CreateGroup {
833   my ($this, $groupName, $params) = @_;
834   croak 'usage CGP::CLI->CreateGroup($groupName[, \%params])'
835     unless defined $groupName;
836   my $line = 'CreateGroup '.$groupName;
837   $line .= ' '.$this->printWords($params) if $params;
838   $this->send($line);
839   $this->_parseResponse(); 
840 }
841
842 sub RenameGroup {
843   my ($this, $oldGroupName, $newGroupName) = @_;
844   croak 'usage CGP::CLI->RenameGroup($oldGroupName, $newGroupName)'
845     unless defined $oldGroupName && defined $newGroupName;
846   $this->send('RenameGroup '.$oldGroupName.' into '.$newGroupName);
847   $this->_parseResponse();    
848 }
849
850 sub DeleteGroup {
851   my ($this, $groupName) = @_;
852   croak 'usage CGP::CLI->DeleteGroup($groupName)'
853     unless defined $groupName;
854   $this->send('DeleteGroup '.$groupName);
855   $this->_parseResponse();    
856 }
857
858 sub GetGroup {
859   my ($this, $groupName) = @_;
860   croak 'usage CGP::CLI->GetGroup($groupName)'
861     unless defined $groupName;
862   $this->send('GetGroup '.$groupName);
863   return undef unless $this->_parseResponse();
864   $this->parseWords($this->getWords);      
865 }
866
867 sub SetGroup {
868   my ($this, $groupName, $params) = @_;
869   croak 'usage CGP::CLI->SetGroup($groupName, \%settings)'
870     unless defined $groupName && defined $params;
871   $this->send('SetGroup '.$groupName.' '.$this->printWords($params));
872   $this->_parseResponse();
873 }
874
875
876 #################################################################
877 #  Forwarder managent commands
878
879 sub ListForwarders {
880   my ($this, $domainName) = @_;
881   my $line = 'ListForwarders';
882   $line .= ' ' .$domainName if $domainName;
883   $this->send($line);
884   return undef unless $this->_parseResponse();
885   $this->parseWords($this->getWords);
886 }    
887
888 sub CreateForwarder {
889   my ($this, $forwarderName, $address) = @_;
890   croak 'usage CGP::CLI->CreateForwarder($forwarderName, $address)'
891     unless defined $forwarderName && defined $address;
892   $this->send('CreateForwarder '.$forwarderName.' TO '.$this->printWords($address));
893   $this->_parseResponse(); 
894 }
895 sub RenameForwarder {
896   my ($this, $forwarderName, $newName) = @_;
897   croak 'usage CGP::CLI->RenameForwarder($forwarderName, $newName)'
898     unless defined $forwarderName && defined $newName;
899   $this->send('RenameForwarder '.$forwarderName.' into '.$newName);
900   $this->_parseResponse(); 
901 }
902
903 sub DeleteForwarder {
904   my ($this, $forwarderName) = @_;
905   croak 'usage CGP::CLI->DeleteForwarder($forwarderName)'
906     unless defined $forwarderName;
907   $this->send('DeleteForwarder '.$forwarderName);
908   $this->_parseResponse();    
909 }
910
911 sub GetForwarder {
912   my ($this, $forwarderName) = @_;
913   croak 'usage CGP::CLI->GetForwarder($forwarderName)'
914     unless defined $forwarderName;
915   $this->send('GetForwarder '.$forwarderName);
916   return undef unless $this->_parseResponse();
917   $this->parseWords($this->getWords);      
918 }
919 sub FindForwarders {
920   my ($this, $domain,$forwarderAddress) = @_;
921   croak 'usage CGP::CLI->FindForwarders($domainName,$forwarderAddress)'
922     unless (defined $domain && defined $forwarderAddress);
923   $this->send('FindForwarders '.$domain.' TO '.$this->printWords($forwarderAddress));
924   return undef unless $this->_parseResponse();
925   $this->parseWords($this->getWords);      
926 }
927
928 #################################################################
929 #  Domain managent commands
930
931 sub ListDomains {
932   my $this = shift;
933   $this->send('ListDomains');
934   return undef unless $this->_parseResponse();
935   $this->parseWords($this->getWords);
936 }
937
938 sub MainDomainName {
939   my $this = shift;
940   $this->send('MainDomainName');
941   return undef unless $this->_parseResponse();
942   $this->parseWords($this->getWords);
943 }
944
945 sub GetDomainSettings {
946   my ($this, $domainName) = @_;
947
948   my $line = 'GetDomainSettings';
949   $line .= ' '.$domainName if($domainName);
950
951   $this->send($line);
952   return undef unless $this->_parseResponse();
953   $this->parseWords($this->getWords);
954 }
955
956 sub GetDomain {
957   GetDomainSettings(@_);
958 }
959
960 sub GetDomainEffectiveSettings {
961   my ($this, $domainName) = @_;
962   my $line = 'GetDomainEffectiveSettings';
963   $line .= ' '.$domainName if($domainName);
964   $this->send($line);
965   return undef unless $this->_parseResponse();
966   $this->parseWords($this->getWords);
967 }
968
969 sub UpdateDomainSettings {
970   my ($this) = shift;
971   my %params = (@_);
972
973   croak 'usage CGP::CLI->UpdateDomainSettings(domain => \'domainName\',settings => {settings})'
974     unless exists $params{settings};
975
976   my $line = 'UpdateDomainSettings';
977   $line .= ' '.$params{domain} if exists $params{domain};
978   $this->send($line.' '.$this->printWords($params{settings}));
979   $this->_parseResponse();
980 }
981
982 sub UpdateDomain {
983   UpdateDomainSettings(@_);
984 }
985
986 sub SetDomainSettings {
987   my ($this) = shift;
988   my %params = (@_);
989
990   croak 'usage CGP::CLI->SetDomainSettings(domain => \'domainName\',settings => {settings})'
991     unless exists $params{settings};
992
993   my $line = 'SetDomainSettings';
994   $line .= ' '.$params{domain} if exists $params{domain};
995   $this->send($line.' '.$this->printWords($params{settings}));
996   $this->_parseResponse();
997 }
998
999 sub SetDomain {
1000   SetDomainSettings(@_);
1001 }
1002
1003
1004 sub CreateDomain {
1005   my ($this, $domainName, $params) = @_;
1006   croak 'usage CGP::CLI->CreateDomain($domainName[, \%params])'
1007     unless defined $domainName;
1008   my $line = 'CreateDomain '.$domainName;
1009   $line .= ' '.$this->printWords($params) if $params;
1010   $this->send($line);
1011   $this->_parseResponse();
1012 }
1013
1014 sub RenameDomain {
1015   my ($this, $oldDomainName, $newDomainName) = @_;
1016   croak 'usage CGP::CLI->RenameDomain($oldDomainName, $newDomainName)'
1017     unless defined $oldDomainName && defined $newDomainName;
1018   $this->send('RenameDomain '.$oldDomainName.' into '.$newDomainName );
1019   $this->_parseResponse();
1020 }
1021
1022 sub DeleteDomain {
1023   my ($this, $domainName, $force) = @_;
1024   croak 'usage CGP::CLI->DeleteDomain($domainName[, $force])'
1025     unless defined $domainName;
1026   my $line = 'DeleteDomain '.$domainName;
1027   $line .= ' force' if $force;
1028   $this->send($line);
1029   $this->_parseResponse();
1030 }
1031
1032 sub SuspendDomain {
1033   my ($this, $domainName) = @_;
1034   croak 'usage CGP::CLI->SuspendDomain($domainName)'
1035     unless defined $domainName;
1036   $this->send('SuspendDomain '.$domainName);
1037   $this->_parseResponse();
1038 }
1039 sub ResumeDomain {
1040   my ($this, $domainName) = @_;
1041   croak 'usage CGP::CLI->ResumeDomain($domainName)'
1042     unless defined $domainName;
1043   $this->send('ResumeDomain '.$domainName);
1044   $this->_parseResponse();
1045 }
1046
1047 sub CreateSharedDomain {
1048   my ($this, $domainName, $params) = @_;
1049   croak 'usage CGP::CLI->CreateSharedDomain($domainName[, \%params])'
1050     unless defined $domainName;
1051   my $line = 'CreateSharedDomain '.$domainName;
1052   $line .= ' '.$this->printWords($params) if $params;
1053   $this->send($line);
1054   $this->_parseResponse();
1055 }
1056
1057 sub CreateDirectoryDomain {
1058   my ($this, $domainName, $params) = @_;
1059   croak 'usage CGP::CLI->CreateDirectoryDomain($domainName[, \%params])'
1060     unless defined $domainName;
1061   my $line = 'CreateDirectoryDomain '.$domainName;
1062   $line .= ' '.$this->printWords($params) if $params;
1063   $this->send($line);
1064   $this->_parseResponse();
1065 }
1066
1067 sub ReloadDirectoryDomains {
1068   my ($this) = @_;
1069   $this->send('ReloadDirectoryDomains');
1070   $this->_parseResponse();
1071 }
1072
1073 sub GetDomainRules {
1074   my ($this, $domainName) = @_;
1075   croak 'usage CGP::CLI->GetDomainRules($domainName)'
1076     unless defined $domainName;
1077   $this->send('GetDomainRules '.$domainName);
1078   return undef unless $this->_parseResponse();
1079   $this->parseWords($this->getWords);
1080 }
1081
1082 sub SetDomainRules {
1083   my ($this, $domainName, $rules) = @_;
1084   croak 'usage CGP::CLI->SetDomainRules($domainName, \@rules)'
1085     unless defined $domainName && defined $rules;
1086   $this->send('SetDomainRules '.$domainName.' '.$this->printWords($rules));
1087   $this->_parseResponse();
1088 }
1089
1090 sub GetDomainMailRules {
1091   my ($this, $domainName) = @_;
1092   croak 'usage CGP::CLI->GetDomainMailRules($domainName)'
1093     unless defined $domainName;
1094   $this->send('GetDomainMailRules '.$domainName);
1095   return undef unless $this->_parseResponse();
1096   $this->parseWords($this->getWords);
1097 }
1098
1099 sub SetDomainMailRules {
1100   my ($this, $domainName, $rules) = @_;
1101   croak 'usage CGP::CLI->SetDomainMailRules($domainName, \@rules)'
1102     unless defined $domainName && defined $rules;
1103   $this->send('SetDomainMailRules '.$domainName.' '.$this->printWords($rules));
1104   $this->_parseResponse();
1105 }
1106
1107 #sub UpdateDomainMailRule {
1108 #  my ($this, $domainName, $rule) = @_;
1109 #  croak 'usage CGP::CLI->UpdateDomainMailRules($domainName, \@rule)'
1110 #    unless defined $domainName && defined $rule;
1111 #  $this->send('UpdateDomainMailRule '.$domainName.' '.$this->printWords($rule));
1112 #  $this->_parseResponse();
1113 #}
1114 sub GetDomainSignalRules {
1115   my ($this, $domainName) = @_;
1116   croak 'usage CGP::CLI->GetDomainSignalRules($domainName)'
1117     unless defined $domainName;
1118   $this->send('GetDomainSignalRules '.$domainName);
1119   return undef unless $this->_parseResponse();
1120   $this->parseWords($this->getWords);
1121 }
1122
1123 sub SetDomainSignalRules {
1124   my ($this, $domainName, $rules) = @_;
1125   croak 'usage CGP::CLI->SetDomainSignalRules($domainName, \@rules)'
1126     unless defined $domainName && defined $rules;
1127   $this->send('SetDomainSignalRules '.$domainName.' '.$this->printWords($rules));
1128   $this->_parseResponse();
1129 }
1130
1131 #sub UpdateDomainSignalRule {
1132 #  my ($this, $domainName, $rule) = @_;
1133 #  croak 'usage CGP::CLI->UpdateDomainSignalRules($domainName, \@rule)'
1134 #    unless defined $domainName && defined $rule;
1135 #  $this->send('UpdateDomainSignalRule '.$domainName.' '.$this->printWords($rule));
1136 #  $this->_parseResponse();
1137 #}
1138
1139
1140 sub GetDomainAliases {
1141   my ($this, $domain) = @_;
1142
1143   my $line = 'GetDomainAliases';
1144   $line .= ' '.$domain if $domain;
1145   $this->send($line);
1146   return undef unless $this->_parseResponse();
1147   $this->parseWords($this->getWords);
1148 }
1149
1150
1151 sub SetDomainAliases {
1152   my ($this, $domain, $aliases) = @_;
1153   croak 'usage CGP::CLI->SetDomainAliases($domainName, \@aliases)'
1154     unless defined $domain && defined $aliases;
1155   $this->send('SetDomainAliases '.$domain.' '.$this->printWords($aliases));
1156   $this->_parseResponse();
1157 }
1158
1159 sub ListAdminDomains {
1160   my ($this, $domain) = @_;
1161   my $line = 'ListAdminDomains';
1162   $line .= ' '.$domain if $domain;
1163   $this->send($line);
1164   return undef unless $this->_parseResponse();
1165   $this->parseWords($this->getWords);
1166 }
1167
1168 sub InsertDirectoryRecords {
1169   my ($this, $domain) = @_;
1170   my $line = 'InsertDirectoryRecords';
1171   $line .= ' '.$domain if $domain;
1172   $this->send($line);
1173   $this->_parseResponse();
1174 }
1175 sub DeleteDirectoryRecords {
1176   my ($this, $domain) = @_;
1177   my $line = 'DeleteDirectoryRecords';
1178   $line .= ' '.$domain if $domain;
1179   $this->send($line);
1180   $this->_parseResponse();
1181 }
1182
1183 sub GetServerTrustedCerts {
1184   my $this = shift;
1185   $this->send('GetServerTrustedCerts');
1186   return undef unless $this->_parseResponse();
1187   $this->parseWords($this->getWords);
1188 }
1189
1190 sub SetServerTrustedCerts {
1191   my ( $this, $certs ) = @_;
1192   croak 'usage CGP::CLI->SetServerTrustedCerts(\@certs)'
1193     unless defined $certs;
1194   $this->send('SetServerTrustedCerts '.$this->printWords($certs));
1195   $this->_parseResponse(); 
1196 }
1197
1198 sub GetClusterTrustedCerts {
1199   my $this = shift;
1200   $this->send('GetClusterTrustedCerts');
1201   return undef unless $this->_parseResponse();
1202   $this->parseWords($this->getWords);
1203 }
1204
1205 sub SetClusterTrustedCerts {
1206   my ( $this, $certs ) = @_;
1207   croak 'usage CGP::CLI->SetClusterTrustedCerts(\@certs)'
1208     unless defined $certs;
1209   $this->send('SetClusterTrustedCerts '.$this->printWords($certs));
1210   $this->_parseResponse(); 
1211 }
1212
1213
1214 sub GetDirectoryIntegration {
1215   my $this = shift;
1216   $this->send('GetDirectoryIntegration');
1217   return undef unless $this->_parseResponse();
1218   $this->parseWords($this->getWords);
1219 }
1220
1221 sub SetDirectoryIntegration {
1222   my ( $this, $dict ) = @_;
1223   croak 'usage CGP::CLI->SetDirectoryIntegration(\%settings)'
1224     unless defined $dict;
1225
1226   $this->send('SetDirectoryIntegration '.$this->printWords($dict));
1227   $this->_parseResponse();
1228 }
1229
1230 sub GetClusterDirectoryIntegration {
1231   my $this = shift;
1232   $this->send('GetClusterDirectoryIntegration');
1233   return undef unless $this->_parseResponse();
1234   $this->parseWords($this->getWords);
1235 }
1236
1237 sub SetClusterDirectoryIntegration {
1238   my ( $this, $dict ) = @_;
1239   croak 'usage CGP::CLI->SetClusterDirectoryIntegration(\%settings)'
1240     unless defined $dict;
1241
1242   $this->send('SetClusterDirectoryIntegration '.$this->printWords($dict));
1243   $this->_parseResponse(); 
1244 }
1245
1246
1247 sub GetDomainDefaults {
1248   my $this = shift;
1249   $this->send('GetDomainDefaults');
1250   return undef unless $this->_parseResponse();
1251   $this->parseWords($this->getWords);
1252 }
1253
1254 sub UpdateDomainDefaults {
1255   my ( $this, $dict ) = @_;
1256   croak 'usage CGP::CLI->UpdateDomainDefaults(\%settings)'
1257     unless defined $dict;
1258
1259   $this->send('UpdateDomainDefaults '.$this->printWords($dict));
1260   $this->_parseResponse(); 
1261 }
1262
1263 sub SetDomainDefaults {
1264   my ( $this, $dict ) = @_;
1265   croak 'usage CGP::CLI->SetDomainDefaults(\%settings)'
1266     unless defined $dict;
1267   $this->send('SetDomainDefaults '.$this->printWords($dict));
1268   $this->_parseResponse();
1269 }
1270
1271 sub GetClusterDomainDefaults {
1272   my $this = shift;
1273   $this->send('GetClusterDomainDefaults');
1274   return undef unless $this->_parseResponse();
1275   $this->parseWords($this->getWords);
1276 }
1277
1278 sub UpdateClusterDomainDefaults {
1279   my ( $this, $dict ) = @_;
1280   $this->send('UpdateClusterDomainDefaults '.$this->printWords($dict));
1281   $this->_parseResponse();
1282 }
1283
1284 sub SetClusterDomainDefaults {
1285   my ( $this, $dict ) = @_;
1286   $this->send('SetClusterDomainDefaults '.$this->printWords($dict));
1287   $this->_parseResponse();
1288 }
1289
1290
1291 sub GetAllAccountsDefaults {
1292   my $this = shift;
1293   $this->send('GetAllAccountsDefaults');
1294   return undef unless $this->_parseResponse();
1295   $this->parseWords($this->getWords);
1296 }
1297
1298 sub UpdateAllAccountsDefaults {
1299   my ( $this, $dict ) = @_;
1300   $this->send('UpdateAllAccountsDefaults '.$this->printWords($dict));
1301   $this->_parseResponse();
1302 }
1303
1304 sub SetAllAccountsDefaults {
1305   my ( $this, $dict ) = @_;
1306   $this->send('SetAllAccountsDefaults '.$this->printWords($dict));
1307   $this->_parseResponse();
1308 }
1309
1310 sub GetServerAccountDefaults {
1311   my $this = shift;
1312   $this->send('GetServerAccountDefaults');
1313   return undef unless $this->_parseResponse();
1314   $this->parseWords($this->getWords);
1315 }
1316
1317 sub UpdateServerAccountDefaults {
1318   my ( $this, $dict ) = @_;
1319   $this->send('UpdateServerAccountDefaults '.$this->printWords($dict));
1320   $this->_parseResponse();
1321 }
1322
1323 sub SetServerAccountDefaults {
1324   my ( $this, $dict ) = @_;
1325   $this->send('SetServerAccountDefaults '.$this->printWords($dict));
1326   $this->_parseResponse();
1327 }
1328
1329 sub GetClusterAccountDefaults {
1330   my $this = shift;
1331   $this->send('GetClusterAccountDefaults');
1332   return undef unless $this->_parseResponse();
1333   $this->parseWords($this->getWords);
1334 }
1335
1336 sub UpdateClusterAccountDefaults {
1337   my ( $this, $dict ) = @_;
1338   $this->send('UpdateClusterAccountDefaults '.$this->printWords($dict));
1339   $this->_parseResponse();
1340 }
1341
1342 sub SetClusterAccountDefaults {
1343   my ( $this, $dict ) = @_;
1344   $this->send('SetClusterAccountDefaults '.$this->printWords($dict));
1345   $this->_parseResponse();
1346 }
1347
1348 sub GetServerWebUserDefaults {
1349   my $this = shift;
1350   $this->send('GetServerWebUserDefaults');
1351   return undef unless $this->_parseResponse();
1352   $this->parseWords($this->getWords);
1353 }
1354 sub GetServerAccountPrefs {
1355   my $this = shift;
1356   $this->send('GetServerAccountPrefs');
1357   return undef unless $this->_parseResponse();
1358   $this->parseWords($this->getWords);
1359 }
1360
1361 sub SetServerWebUserDefaults {
1362   my ( $this, $dict ) = @_;
1363   $this->send('SetServerWebUserDefaults '.$this->printWords($dict));
1364   $this->_parseResponse();
1365 }
1366 sub SetServerAccountPrefs {
1367   my ( $this, $dict ) = @_;
1368   $this->send('SetServerAccountPrefs '.$this->printWords($dict));
1369   $this->_parseResponse();
1370 }
1371
1372 sub GetClusterWebUserDefaults {
1373   my $this = shift;
1374   $this->send('GetClusterWebUserDefaults');
1375   return undef unless $this->_parseResponse();
1376   $this->parseWords($this->getWords);
1377 }
1378 sub GetClusterAccountPrefs {
1379   my $this = shift;
1380   $this->send('GetClusterAccountPrefs');
1381   return undef unless $this->_parseResponse();
1382   $this->parseWords($this->getWords);
1383 }
1384 sub SetClusterWebUserDefaults {
1385   my ( $this, $dict ) = @_;
1386   $this->send('SetClusterWebUserDefaults '.$this->printWords($dict));
1387   $this->_parseResponse();
1388 }
1389 sub SetClusterAccountPrefs {
1390   my ( $this, $dict ) = @_;
1391   $this->send('SetClusterAccountPrefs '.$this->printWords($dict));
1392   $this->_parseResponse();
1393 }
1394
1395 sub GetDomainLocation {
1396   my ( $this, $account ) = @_;
1397   $this->send('GetDomainLocation '.$account);
1398   return undef unless $this->_parseResponse();
1399   $this->parseWords($this->getWords);
1400 }
1401
1402 sub GetAccountLocation {
1403   my ( $this, $account ) = @_;
1404   $this->send('GetAccountLocation '.$account);
1405   return undef unless $this->_parseResponse();
1406   $this->parseWords($this->getWords);
1407 }
1408
1409 sub ListServerTelnums {
1410   my ($this, $limit,$filter) = @_;
1411   croak 'usage CGP::CLI->ListServerTelnums($limit[,$filter])'
1412       unless defined $limit;
1413   my $line = "ListServerTelnums";
1414   $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
1415   $line .= " $limit";
1416   $this->send($line);
1417   return undef unless $this->_parseResponse();
1418   $this->parseWords($this->getWords);
1419 }
1420  
1421 sub ListClusterTelnums {
1422   my ($this, $limit,$filter) = @_;
1423   croak 'usage CGP::CLI->ListClusterTelnums($limit[,$filter])'
1424       unless defined $limit;
1425   my $line = "ListClusterTelnums";
1426   $line .= ' FILTER '.$this->printWords($filter) if defined $filter;
1427   $line .= " $limit";
1428   $this->send($line);
1429   return undef unless $this->_parseResponse();
1430   $this->parseWords($this->getWords);
1431 }
1432
1433
1434 sub GetAccountDefaults {
1435   my ($this, $domain) = @_;
1436
1437   my $line = 'GetAccountDefaults';
1438   $line .= ' '.$domain if($domain);
1439   $this->send($line);
1440   return undef unless $this->_parseResponse();
1441   $this->parseWords($this->getWords);
1442 }
1443
1444 sub UpdateAccountDefaults {
1445   my ($this) = shift;
1446   my %params = (@_);
1447
1448   croak 'usage CGP::CLI->UpdateAccountDefaults(domain => \'domainName\',settings => {settings})'
1449     unless exists $params{settings};
1450
1451   my $line = 'UpdateAccountDefaults';
1452   $line .= ' '.$params{domain} if exists $params{domain};
1453
1454   $this->send($line . ' ' . $this->printWords($params{settings}));
1455   $this->_parseResponse();
1456 }
1457
1458 sub SetAccountDefaults {
1459   my ($this) = shift;
1460   my %params = (@_);
1461
1462   croak 'usage CGP::CLI->SetAccountDefaults(domain => \'domainName\',settings => {settings})'
1463     unless exists $params{settings};
1464
1465   my $line = 'SetAccountDefaults';
1466   $line .= ' '.$params{domain} if exists $params{domain};
1467
1468   $this->send($line . ' ' . $this->printWords($params{settings}));
1469   $this->_parseResponse();
1470 }
1471
1472 sub GetWebUserDefaults {
1473   my ($this, $domain) = @_;
1474
1475   my $line = 'GetWebUserDefaults';
1476   $line .= ' '.$domain if($domain);
1477         
1478   $this->send($line);
1479   return undef unless $this->_parseResponse();
1480   $this->parseWords($this->getWords);
1481 }
1482
1483 sub GetAccountDefaultPrefs {
1484   my ($this, $domain) = @_;
1485
1486   my $line = 'GetAccountDefaultPrefs';
1487   $line .= ' '.$domain if($domain);
1488         
1489   $this->send($line);
1490   return undef unless $this->_parseResponse();
1491   $this->parseWords($this->getWords);
1492 }
1493
1494 sub SetWebUserDefaults {
1495   my ($this) = shift;;
1496   my %params = (@_);
1497   croak 'usage CGP::CLI->SetWebUserDefaults(domain => \'domainName\',settings => {settings})'
1498     unless exists $params{settings};
1499
1500   my $line = 'SetWebUserDefaults';
1501   $line .= ' ' .$params{domain} if exists $params{domain};
1502
1503   $this->send($line . ' ' . $this->printWords($params{settings}));
1504   $this->_parseResponse();
1505 }
1506 sub SetAccountDefaultPrefs {
1507   my ($this) = shift;;
1508   my %params = (@_);
1509   croak 'usage CGP::CLI->SetAccountDefaultPrefs(domain => \'domainName\',settings => {settings})'
1510     unless exists $params{settings};
1511
1512   my $line = 'SetAccountDefaultPrefs';
1513   $line .= ' ' .$params{domain} if exists $params{domain};
1514
1515   $this->send($line . ' ' . $this->printWords($params{settings}));
1516   $this->_parseResponse();
1517 }
1518
1519 sub UpdateWebUserDefaults {
1520   my ($this) = shift;;
1521   my %params = (@_);
1522   croak 'usage CGP::CLI->UpdateWebUserDefaults(domain => \'domainName\',settings => {settings})'
1523     unless exists $params{settings};
1524
1525   my $line = 'UpdateWebUserDefaults';
1526   $line .= ' ' .$params{domain} if exists $params{domain};
1527
1528   $this->send($line . ' ' . $this->printWords($params{settings}));
1529   $this->_parseResponse();
1530 }
1531 sub UpdateAccountDefaultPrefs {
1532   my ($this) = shift;;
1533   my %params = (@_);
1534   croak 'usage CGP::CLI->UpdateAccountDefaultPrefs(domain => \'domainName\',settings => {settings})'
1535     unless exists $params{settings};
1536
1537   my $line = 'UpdateAccountDefaultPrefs';
1538   $line .= ' ' .$params{domain} if exists $params{domain};
1539
1540   $this->send($line . ' ' . $this->printWords($params{settings}));
1541   $this->_parseResponse();
1542 }
1543
1544 sub GetAccountTemplate {
1545   my ($this, $domain) = @_;
1546
1547   my $line = 'GetAccountTemplate';
1548   $line .= ' '.$domain if($domain);
1549
1550   $this->send($line);
1551   return undef unless $this->_parseResponse();
1552   $this->parseWords($this->getWords);
1553 }
1554
1555 sub UpdateAccountTemplate {
1556   my ($this) = shift;;
1557   my %params = (@_);
1558
1559   croak 'usage CGP::CLI->UpdateAccountTemplate(domain => \'domainName\',settings => {settings})'
1560     unless exists $params{settings};
1561
1562   my $line = 'UpdateAccountTemplate';
1563   $line .= ' '.$params{domain} if exists $params{domain};
1564
1565   $this->send($line.' '.$this->printWords($params{settings}));
1566   $this->_parseResponse();
1567 }
1568
1569 sub SetAccountTemplate {
1570   my ($this) = shift;;
1571   my %params = (@_);
1572
1573   croak 'usage CGP::CLI->SetAccountTemplate(domain => \'domainName\',settings => {settings})'
1574     unless exists $params{settings};
1575
1576   my $line = 'SetAccountTemplate';
1577   $line .= ' '.$params{domain} if exists $params{domain};
1578
1579   $this->send($line.' '.$this->printWords($params{settings}));
1580   $this->_parseResponse();
1581 }
1582
1583 #################################################################
1584 #  Mailbox managent commands
1585
1586 sub ListMailboxes {
1587   my ($this) = shift;;
1588   my %params = (@_);
1589
1590   croak 'usage CGP::CLI->ListMailboxes(accountName => \'account\',filter => \'*\',authAccountName => \'extAccount\')'
1591       unless exists $params{accountName};
1592
1593   my $line = 'ListMailboxes '.$params{accountName};
1594   $line .= ' FILTER '.$this->printWords($params{filter}) if exists $params{filter};
1595   $line .= ' AUTH '.$params{authAccountName} if exists $params{authAccountName};
1596
1597   $this->send($line);
1598   return undef unless $this->_parseResponse();
1599   $this->parseWords($this->getWords);
1600 }
1601
1602 sub CreateMailbox {
1603   my ($this,$accountName,$mailboxName,$authAccountName,$class) = @_;
1604  
1605  
1606   croak 'usage CGP::CLI->CreateMailbox(accountName,mailboxName,[authAccountName],[class])'
1607       unless (defined $accountName && defined $mailboxName);
1608       
1609   my $line = 'CREATEMAILBOX '.$accountName;
1610   $line .= ' MAILBOX '.$this->printWords($mailboxName);
1611   $line .= ' AUTH '.$authAccountName if($authAccountName);
1612   $line .= ' CLASS '.$class if($class);
1613
1614   $this->send($line);
1615   $this->_parseResponse();
1616 }
1617
1618 sub RenameMailbox {   
1619   my ($this,$accountName,$oldMailboxName,$newMailboxName,$authAccountName) = @_;
1620   
1621   croak 'usage CGP::CLI->RenameMailbox(accountName,oldMailboxName,newMailboxName[,authAccountName])'
1622       unless (defined $accountName && defined $oldMailboxName && defined $newMailboxName);
1623       
1624   my $line = 'RENAMEMAILBOX '.$accountName;
1625   $line .= ' MAILBOX '.$this->printWords($oldMailboxName);
1626   $line .= ' INTO '.$this->printWords($newMailboxName);
1627   $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1628
1629   $this->send($line);
1630   $this->_parseResponse();
1631 }
1632
1633 sub RenameMailboxes {   
1634   my ($this,$accountName,$oldMailboxName,$newMailboxName,$authAccountName) = @_;
1635   
1636   croak 'usage CGP::CLI->RenameMailboxes(accountName,oldMailboxName,newMailboxName[,authAccountName])'
1637       unless (defined $accountName && defined $oldMailboxName && defined $newMailboxName);
1638       
1639   my $line = 'RENAMEMAILBOX '.$accountName;
1640   $line .= ' MAILBOXES '.$this->printWords($oldMailboxName);
1641   $line .= ' INTO '.$this->printWords($newMailboxName);
1642   $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1643
1644   $this->send($line);
1645   $this->_parseResponse();
1646 }
1647
1648 sub DeleteMailbox {
1649   my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1650   
1651   croak 'usage CGP::CLI->DeleteMailbox(accountName,mailboxName[,authAccountName])'
1652       unless (defined $accountName && defined $mailboxName);
1653       
1654   my $line = 'DELETEMAILBOX '.$accountName;
1655   $line .= ' MAILBOX '.$this->printWords($mailboxName);
1656   $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1657
1658   $this->send($line);
1659   $this->_parseResponse();
1660 }
1661
1662 sub DeleteMailboxes {
1663   my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1664   
1665   croak 'usage CGP::CLI->DeleteMailboxes(accountName,mailboxName[,authAccountName])'
1666       unless (defined $accountName && defined $mailboxName);
1667       
1668   my $line = 'DELETEMAILBOX '.$accountName;
1669   $line .= ' MAILBOXES '.$this->printWords($mailboxName);
1670   $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1671
1672   $this->send($line);
1673   $this->_parseResponse();
1674 }
1675
1676 sub GetMailboxInfo {
1677   my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1678
1679   croak 'usage CGP::CLI->GetMailboxInfo(accountName,mailboxName[,authAccountName])'
1680        unless (defined $accountName && defined $mailboxName);
1681      
1682   my $line = 'GETMAILBOXINFO '.$accountName;
1683   $line .= ' MAILBOX '.$this->printWords($mailboxName);
1684   $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1685
1686   $this->send($line);
1687   return undef unless $this->_parseResponse();
1688   $this->parseWords($this->getWords);
1689 }
1690
1691 sub GetMailboxACL {   
1692   my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1693
1694   croak 'usage CGP::CLI->GetMailboxACL(accountName,mailboxName[,authAccountName])'
1695        unless (defined $accountName && defined $mailboxName);
1696      
1697   my $line = 'GETMAILBOXACL '.$accountName;
1698   $line .= ' MAILBOX '.$this->printWords($mailboxName);
1699   $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1700
1701   $this->send($line);
1702   return undef unless $this->_parseResponse();
1703   $this->parseWords($this->getWords);
1704 }
1705
1706 sub SetMailboxACL {
1707   my ($this,$accountName,$mailboxName,$newACL,$authAccountName) = @_;
1708
1709   croak 'usage CGP::CLI->SetMailboxACL(accountName,mailboxName,\@newACL[,authAccountName])'
1710        unless (defined $accountName && defined $mailboxName && defined $newACL);
1711      
1712   my $line = 'SETMAILBOXACL '.$accountName;
1713   $line .= ' MAILBOX '.$this->printWords($mailboxName);
1714   $line .= ' AUTH '.$authAccountName if defined $authAccountName;
1715
1716   $this->send($line.' '.$this->printWords($newACL));
1717   $this->_parseResponse();
1718 }
1719
1720
1721 sub GetMailboxRights {
1722   my ($this,$accountName,$mailboxName,$authAccountName) = @_;
1723
1724   croak 'usage CGP::CLI->GetMailboxRights(accountName,mailboxName,authAccountName)'
1725        unless (defined $accountName && defined $mailboxName && defined $authAccountName);
1726      
1727   my $line = 'GETMAILBOXRIGHTS '.$accountName;
1728   $line .= ' MAILBOX '.$this->printWords($mailboxName);
1729   $line .= ' AUTH '.$authAccountName;
1730
1731   $this->send($line);
1732   return undef unless $this->_parseResponse();
1733   $this->parseWords($this->getWords);
1734 }
1735
1736 sub SetMailboxClass {
1737   my ($this,$accountName,$mailboxName,$class,$authAccountName) = @_;
1738
1739   croak 'usage CGP::CLI->SetMailboxClass(accountName,mailboxName,class [,authAccountName])'
1740        unless (defined $accountName && defined $mailboxName && defined $class);
1741      
1742   my $line = 'SetMailboxClass '.$accountName;
1743   $line .= ' MAILBOX '.$this->printWords($mailboxName);
1744   $line .= ' AUTH '.$authAccountName if(defined $authAccountName);
1745   $line .= ' CLASS '.$class;
1746
1747   $this->send($line);
1748   return undef unless $this->_parseResponse();
1749 }
1750
1751
1752 sub GetAccountSubscription {
1753   my ($this,$accountName) = @_;
1754   croak 'usage CGP::CLI->GetAccountSubscription(accountName)'
1755        unless defined $accountName;
1756      
1757   $this->send('GetAccountSubscription '.$accountName);
1758   return undef unless $this->_parseResponse();
1759   $this->parseWords($this->getWords);
1760 }
1761
1762 sub SetAccountSubscription {
1763   my ($this,$accountName,$newSubscription) = @_;
1764   croak 'usage CGP::CLI->SetAccountSubscription(accountName,\%newSubscription)'
1765        unless (defined $accountName && defined $newSubscription);
1766      
1767   $this->send('SetAccountSubscription '.$accountName.' '.$this->printWords($newSubscription));
1768   $this->_parseResponse();
1769 }
1770
1771 sub GetMailboxAliases {
1772   my ($this,$accountName) = @_;
1773   croak 'usage CGP::CLI->GetMailboxAliases(accountName)'
1774        unless defined $accountName;
1775      
1776   $this->send('GetMailboxAliases '.$accountName);
1777   return undef unless $this->_parseResponse();
1778   $this->parseWords($this->getWords);
1779 }
1780
1781 sub SetMailboxAliases {
1782   my ($this,$accountName,$newAliases) = @_;
1783   croak 'usage CGP::CLI->SetMailboxAliases(accountName,\%newAliases)'
1784        unless (defined $accountName && defined $newAliases);
1785      
1786   $this->send('SetMailboxAliases '.$accountName.' '.$this->printWords($newAliases));
1787   $this->_parseResponse();
1788 }
1789
1790
1791 #################################################################
1792 #   Alerts Administration
1793
1794 sub GetDomainAlerts {
1795   my ($this, $domain) = @_;
1796
1797   my $line = 'GetDomainAlerts';
1798   $line .= ' '.$domain if $domain;
1799   $this->send($line);
1800   return undef unless $this->_parseResponse();
1801   $this->parseWords($this->getWords);
1802 }
1803
1804 sub SetDomainAlerts {
1805   my ($this, $domain, $alerts) = @_;
1806   croak 'usage CGP::CLI->SetDomainAlerts($domainName, \@alerts)'
1807     unless defined $domain && defined $alerts;
1808   $this->send('SetDomainAlerts '.$domain.' '.$this->printWords($alerts));
1809   $this->_parseResponse();
1810 }
1811
1812 sub PostDomainAlert {
1813   my ($this, $domain, $alert) = @_;
1814   croak 'usage CGP::CLI->PostDomainAlert($domainName, $alertString)'
1815     unless defined $domain && defined $alert;
1816   $this->send('PostDomainAlert '.$domain.' ALERT '.$this->printWords($alert));
1817   $this->_parseResponse();
1818 }
1819
1820 sub RemoveDomainAlert {
1821   my ($this, $domain, $timeStamp) = @_;
1822   croak 'usage CGP::CLI->RemoveDomainAlert($domainName, $timeStamp)'
1823     unless defined $domain && defined $timeStamp;
1824   $this->send('RemoveDomainAlert '.$domain.' ALERT '.$timeStamp);
1825   $this->_parseResponse();
1826 }
1827
1828 sub GetAccountAlerts {
1829   my ($this, $account) = @_;
1830   $this->send('GetAccountAlerts '.$account);
1831   return undef unless $this->_parseResponse();
1832   $this->parseWords($this->getWords);
1833 }
1834
1835 sub SetAccountAlerts {
1836   my ($this, $account, $alerts) = @_;
1837   croak 'usage CGP::CLI->SetAccountAlerts($account, \@alerts)'
1838     unless defined $account && defined $alerts;
1839   $this->send('SetAccountAlerts '.$account.' '.$this->printWords($alerts));
1840   $this->_parseResponse();
1841 }
1842
1843 sub PostAccountAlert {
1844   my ($this, $account, $alert) = @_;
1845   croak 'usage CGP::CLI->PostAccountAlert($account, $alertString)'
1846     unless defined $account && defined $alert;
1847   $this->send('PostAccountAlert '.$account.' ALERT '.$this->printWords($alert));
1848   $this->_parseResponse();
1849 }
1850
1851 sub RemoveAccountAlert {
1852   my ($this, $account, $timeStamp) = @_;
1853   croak 'usage CGP::CLI->RemoveAccountAlert($account, $timeStamp)'
1854     unless defined $account && defined $timeStamp;
1855   $this->send('RemoveAccountAlert '.$account.' ALERT '.$timeStamp);
1856   $this->_parseResponse();
1857 }
1858
1859
1860 sub GetServerAlerts {
1861   my ($this) = @_;
1862   $this->send('GetServerAlerts');
1863   return undef unless $this->_parseResponse();
1864   $this->parseWords($this->getWords);
1865 }
1866
1867 sub SetServerAlerts {
1868   my ($this, $alerts) = @_;
1869   croak 'usage CGP::CLI->SetServerAlerts(\@alerts)'
1870     unless defined $alerts;
1871   $this->send('SetServerAlerts '.$this->printWords($alerts));
1872   $this->_parseResponse();
1873 }
1874
1875 sub PostServerAlert {
1876   my ($this,  $alert) = @_;
1877   croak 'usage CGP::CLI->PostServerAlert($alertString)'
1878     unless defined $alert;
1879   $this->send('PostServerAlert '.$this->printWords($alert));
1880   $this->_parseResponse();
1881 }
1882
1883 sub RemoveServerAlert {
1884   my ($this, $timeStamp) = @_;
1885   croak 'usage CGP::CLI->RemoveServerAlert($timeStamp)'
1886     unless defined $timeStamp;
1887   $this->send('RemoveServerAlert '.$timeStamp);
1888   $this->_parseResponse();
1889 }
1890
1891 sub GetClusterAlerts {
1892   my ($this) = @_;
1893   $this->send('GetClusterAlerts');
1894   return undef unless $this->_parseResponse();
1895   $this->parseWords($this->getWords);
1896 }
1897
1898 sub SetClusterAlerts {
1899   my ($this, $alerts) = @_;
1900   croak 'usage CGP::CLI->SetClusterAlerts(\@alerts)'
1901     unless defined $alerts;
1902   $this->send('SetClusterAlerts '.$this->printWords($alerts));
1903   $this->_parseResponse();
1904 }
1905
1906 sub PostClusterAlert {
1907   my ($this,  $alert) = @_;
1908   croak 'usage CGP::CLI->PostClusterAlert($alertString)'
1909     unless defined $alert;
1910   $this->send('PostClusterAlert '.$this->printWords($alert));
1911   $this->_parseResponse();
1912 }
1913
1914 sub RemoveClusterAlert {
1915   my ($this, $timeStamp) = @_;
1916   croak 'usage CGP::CLI->RemoveClusterAlert($timeStamp)'
1917     unless defined $timeStamp;
1918   $this->send('RemoveClusterAlert '.$timeStamp);
1919   $this->_parseResponse();
1920 }
1921
1922 #################################################################
1923 #   Personal Web Site Administration
1924
1925 sub GetWebFile {
1926   my ($this,$accountName,$fileName,$position,$sliceSize) = @_;
1927
1928   croak 'usage CGP::CLI->GetWebFile(accountName,fileName[,position,sliceSize])'
1929        unless (defined $accountName && defined $fileName);
1930   my $line='GetWebFile '.$accountName.' FILE '.$this->printWords($fileName);
1931   $line .= ' OFFSET '. $position if(defined $position && $position!=0);
1932   $line .= ' SIZE '. $sliceSize if(defined $sliceSize);
1933       
1934   $this->send($line);
1935   return undef unless $this->_parseResponse;
1936   $this->parseWords($this->getWords);
1937 }
1938
1939 sub PutWebFile {
1940   my ($this,$accountName,$fileName,$data,$position) = @_;
1941
1942   croak 'usage CGP::CLI->PutWebFile(accountName,fileName,data [,position])'
1943        unless (defined $accountName && defined $fileName && defined $data);
1944   my $line='PutWebFile '.$accountName.' FILE '.$this->printWords($fileName);
1945   $line .= ' OFFSET '. $position if(defined $position && $position!=0);
1946   
1947   $line .= ' DATA ['.$data.']';
1948        
1949   $this->send($line);
1950   $this->_parseResponse;
1951 }
1952
1953 sub RenameWebFile {
1954   my ($this,$accountName,$oldFileName,$newFileName) = @_;
1955
1956   croak 'usage CGP::CLI->RenameWebFile(accountName,oldFileName,newFileName)'
1957        unless (defined $accountName && defined $oldFileName && defined $newFileName);
1958   $this->send('RenameWebFile '.$accountName.' FILE '.$this->printWords($oldFileName).' INTO '.$this->printWords($newFileName));
1959   $this->_parseResponse;
1960 }
1961
1962 sub DeleteWebFile {
1963   my ($this,$accountName,$fileName) = @_;
1964
1965   croak 'usage CGP::CLI->DeleteWebFile(accountName,fileName)'
1966        unless (defined $accountName && defined $fileName);
1967   $this->send('DeleteWebFile '.$accountName.' FILE '.$this->printWords($fileName));
1968   $this->_parseResponse;
1969 }
1970
1971 sub ListWebFiles {
1972   my ($this,$accountName,$filePath) = @_;
1973
1974   croak 'usage CGP::CLI->ListWebFiles(accountName [,filePath])'
1975        unless defined $accountName;
1976   my $line = 'ListWebFiles '.$accountName;
1977   $line .= ' PATH '.$this->printWords($filePath) if $filePath;
1978   $this->send($line);
1979   return undef unless $this->_parseResponse;
1980   $this->parseWords($this->getWords);
1981 }
1982
1983 sub GetWebFilesInfo {
1984   my ($this,$accountName) = @_;
1985
1986   croak 'usage CGP::CLI->InfoWebFiles(accountName)'
1987        unless defined $accountName;
1988   $this->send('GetWebFilesInfo '.$accountName);
1989   return undef unless $this->_parseResponse;
1990   $this->parseWords($this->getWords);
1991 }
1992
1993 #################################################################
1994 #   List management commands
1995
1996 sub ListLists {
1997   my ( $this, $domain ) = @_;
1998   my $line = 'LISTLISTS';
1999   $line .= ' '.$domain if $domain;
2000   $this->send($line);
2001   return undef unless $this->_parseResponse;
2002   $this->parseWords($this->getWords);
2003 }
2004
2005 sub GetDomainLists {
2006   my ( $this, $domain ) = @_;
2007   my $line = 'GetDomainLists';
2008   $line .= ' '.$domain if $domain;
2009   $this->send($line);
2010   return undef unless $this->_parseResponse;
2011   $this->parseWords($this->getWords);
2012 }
2013
2014 sub GetAccountLists {
2015   my ( $this, $accountName ) = @_;
2016   croak 'usage CGP::CLI->GetAccoountLists($accountName)'
2017       unless defined $accountName;
2018
2019   $this->send('GetAccountLists '.$accountName);
2020   return undef unless $this->_parseResponse;
2021   $this->parseWords($this->getWords);
2022 }
2023
2024 sub CreateList {
2025   my ($this, $listName, $accountName) = @_;
2026   croak 'usage CGP::CLI->CreateList($listName, $accountName)'
2027       unless defined $listName && defined $accountName;
2028   $this->send('CREATELIST '.$listName.' for '.$accountName);
2029   $this->_parseResponse();
2030 }
2031
2032 sub RenameList {
2033   my ($this, $oldListName, $newListName) = @_;
2034   croak 'usage CGP::CLI->RenameList($oldListName, $newListName)'
2035       unless defined $oldListName && defined $newListName;
2036   $this->send('RENAMELIST '.$oldListName.' into '.$newListName);
2037   $this->_parseResponse();
2038 }
2039
2040 sub DeleteList {
2041   my ( $this, $listName ) = @_;
2042   croak 'usage CGP::CLI->DeleteList($listName)'
2043       unless defined $listName;
2044
2045   $this->send('DELETELIST '.$listName);
2046   $this->_parseResponse();
2047 }
2048
2049 sub GetList {
2050   my ( $this, $listName ) = @_;
2051   croak 'usage CGP::CLI->GetList($listName)'
2052       unless defined $listName;
2053       
2054   $this->send('GETLIST '.$listName);
2055   return undef unless $this->_parseResponse();
2056   $this->parseWords($this->getWords);
2057 }
2058
2059 sub UpdateList {
2060   my ( $this, $listName, $dict ) = @_;
2061   croak 'usage CGP::CLI->UpdateList($listName,\%params)'
2062       unless defined $listName && defined $dict;
2063   
2064   $this->send('UPDATELIST '.$listName.' '.$this->printWords($dict) );
2065   $this->_parseResponse();
2066 }
2067
2068 sub List {
2069   my ( $this, $listName, $command, $subscriber, @options ) = @_;
2070   croak 'usage CGP::CLI->List($listName, $command, $subscriber, @options)'
2071       unless defined $listName && defined $command && defined $subscriber;
2072
2073   $this->send('LIST '.$listName.' '.$command.' '.join(' ',@options).' '.$subscriber);
2074   $this->_parseResponse();
2075 }
2076
2077 sub ListSubscribers {
2078   my ( $this, $listName,$filter,$limit ) = @_;    
2079   croak 'usage CGP::CLI->ListSubscribers($listName [,$filter[,$limit]])'
2080       unless defined $listName;
2081
2082   my $line = 'ListSubscribers '.$listName;
2083   $line .= ' FILTER '. ($filter eq '' ? '""' : $this->printWords($filter)) if($filter || $limit);
2084   $line .= " $limit" if($limit);
2085   
2086   $this->send($line );
2087   return undef unless $this->_parseResponse();
2088   $this->parseWords($this->getWords);
2089 }
2090
2091 sub GetSubscriberInfo {
2092   my ( $this, $listName,$address ) = @_;    
2093   croak 'usage CGP::CLI->GetSubscriberInfo($listName ,$subscriberAddress)'
2094       unless defined $listName && defined $address;
2095   $this->send('GetSubscriberInfo '.$listName.' NAME '.$address);
2096   return undef unless $this->_parseResponse();
2097   $this->parseWords($this->getWords);
2098 }
2099
2100 sub SetPostingMode {
2101   my ($this, $listName, $address, $mode) = @_;
2102   croak 'usage CGP::CLI->SetPostingMode($listName,$subscriberAddress,$mode)'
2103       unless defined $listName && defined $address && defined $mode;
2104   $this->send('SetPostingMode '.$listName.' FOR '.$address.' '.$mode);
2105   $this->_parseResponse();
2106 }
2107
2108 sub ProcessBounce {
2109   my ($this, $listName, $address, $fatal) = @_;
2110   croak 'usage CGP::CLI->ProcessBounce($listName,$subscriberAddress,"fatal")'
2111       unless defined $listName && defined $address;
2112   my $line = 'ProcessBounce '.$listName;
2113   $line .= ' FATAL' if($fatal);
2114   $this->send($line. ' FOR '.$address);
2115   $this->_parseResponse();
2116 }
2117
2118 #############################################
2119 #   Web Skins Administration 
2120  
2121 sub ListDomainSkins {
2122   my ($this, $domainName) = @_;
2123   my $line = 'ListDomainSkins';
2124   $line .= ' '.$domainName if($domainName);
2125   $this->send($line);
2126   return undef unless $this->_parseResponse();
2127   $this->parseWords($this->getWords);
2128 }
2129
2130 sub CreateDomainSkin {
2131   my ( $this, $domain, $skin ) = @_;
2132   croak 'usage CGP::CLI->CreateDomainSkin($domainName,$skinName)'
2133       unless defined $domain && defined $skin;
2134
2135   $this->send('CreateDomainSkin '.$domain.' SKIN '.$this->printWords($skin));
2136   $this->_parseResponse();
2137 }
2138
2139 sub RenameDomainSkin {
2140   my ( $this, $domain, $skin, $newName ) = @_;
2141   croak 'usage CGP::CLI->RenameDomainSkin($domainName,$oldSkinName,$newSkinName)'
2142       unless defined $domain && defined $skin && defined $newName;
2143
2144   $this->send('RenameDomainSkin '.$domain.' SKIN '.$this->printWords($skin).' INTO '.$this->printWords($newName));
2145   $this->_parseResponse();
2146 }
2147
2148 sub DeleteDomainSkin {
2149   my ( $this, $domain, $skin ) = @_;
2150   croak 'usage CGP::CLI->DeleteDomainSkin($domainName,$skinName)'
2151       unless defined $domain && defined $skin;
2152
2153   $this->send('DeleteDomainSkin '.$domain.' SKIN '.$this->printWords($skin));
2154   $this->_parseResponse();
2155 }
2156
2157 sub ListDomainSkinFiles {
2158   my ( $this, $domain, $skin ) = @_;
2159   croak 'usage CGP::CLI->ListDomainSkinFiles($domainName,$skinName)'
2160       unless defined $domain && defined $skin;
2161   
2162   $this->send('ListDomainSkinFiles '.$domain.' SKIN '.$this->printWords($skin));
2163   return undef unless $this->_parseResponse();
2164   $this->parseWords($this->getWords);
2165 }
2166
2167 sub ReadDomainSkinFile {
2168   my ( $this, $domain, $skin, $fileName ) = @_;
2169   croak 'usage CGP::CLI->ReadDomainSkinFile($domainName,$skinName,$fileName)'
2170       unless defined $domain && defined $skin && defined $fileName;
2171
2172   $this->send('ReadDomainSkinFile '.$domain.' SKIN '.$this->printWords($skin).' FILE '.$this->printWords($fileName));
2173   return undef unless $this->_parseResponse();
2174   $this->parseWords($this->getWords);
2175 }
2176
2177 sub StoreDomainSkinFile {
2178   my ( $this, $domain, $skin, $fileName,$base64data ) = @_;
2179   croak 'usage CGP::CLI->StoreDomainSkinFile($domainName,$skinName,$fileName,$base64data)'
2180       unless defined $domain && defined $skin && defined $fileName && defined $base64data;
2181   $this->send('StoreDomainSkinFile '.$domain.' SKIN '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DATA ['.$base64data.']');
2182   $this->_parseResponse();
2183 }
2184
2185 sub DeleteDomainSkinFile {
2186   my ( $this, $domain, $skin, $fileName ) = @_;
2187   croak 'usage CGP::CLI->DeleteDomainSkinFile($domainName,$skinName,$fileName)'
2188       unless defined $domain && defined $skin && defined $fileName;
2189
2190   $this->send('StoreDomainSkinFile '.$domain.' SKIN '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DELETE');
2191   $this->_parseResponse();
2192 }
2193
2194 #--
2195 sub ListServerSkins {
2196   my ($this) = @_;
2197   $this->send('ListServerSkins');
2198   return undef unless $this->_parseResponse();
2199   $this->parseWords($this->getWords);
2200 }
2201
2202 sub CreateServerSkin {
2203   my ( $this, $skin ) = @_;
2204   croak 'usage CGP::CLI->CreateServerSkin($skinName)'
2205       unless defined $skin;
2206
2207   $this->send('CreateServerSkin '.$this->printWords($skin));
2208   $this->_parseResponse();
2209 }
2210
2211 sub RenameServerSkin {
2212   my ( $this, $skin, $newName ) = @_;
2213   croak 'usage CGP::CLI->RenameServerSkin($oldSkinName,$newSkinName)'
2214       unless defined $skin && defined $newName;
2215
2216   $this->send('RenameServerSkin '.$this->printWords($skin).' INTO '.$this->printWords($newName));
2217   $this->_parseResponse();
2218 }
2219
2220 sub DeleteServerSkin {
2221   my ( $this, $skin ) = @_;
2222   croak 'usage CGP::CLI->DeleteServerSkin($skinName)'
2223       unless defined $skin;
2224
2225   $this->send('DeleteServerSkin '.$this->printWords($skin));
2226   $this->_parseResponse();
2227 }
2228
2229 sub ListServerSkinFiles {
2230   my ( $this, $skin ) = @_;
2231   croak 'usage CGP::CLI->ListServerSkinFiles($skinName)'
2232       unless defined $skin;
2233
2234   $this->send('ListServerSkinFiles '.$this->printWords($skin));
2235   return undef unless $this->_parseResponse();
2236   $this->parseWords($this->getWords);
2237 }
2238
2239 sub ReadServerSkinFile {
2240   my ( $this, $skin, $fileName ) = @_;
2241   croak 'usage CGP::CLI->ReadServerSkinFile($skinName,$fileName)'
2242       unless defined $skin && defined $fileName;
2243
2244   $this->send('ReadServerSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName));
2245   return undef unless $this->_parseResponse();
2246   $this->parseWords($this->getWords);
2247 }
2248
2249 sub StoreServerSkinFile {
2250   my ( $this, $skin, $fileName,$data ) = @_;
2251   croak 'usage CGP::CLI->StoreServerSkinFile($skinName,$fileName,$base64data)'
2252       unless defined $skin && defined $fileName && defined $data;
2253
2254   $this->send('StoreServerSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DATA ['.$data.']');
2255   $this->_parseResponse();
2256 }
2257
2258 sub DeleteServerSkinFile {
2259   my ( $this, $skin, $fileName ) = @_;
2260   croak 'usage CGP::CLI->DeleteServerSkinFile($skinName,$fileName)'
2261       unless defined $skin && defined $fileName;
2262
2263   $this->send('StoreServerSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DELETE');
2264   $this->_parseResponse();
2265 }
2266
2267 #--
2268 sub ListClusterSkins {
2269   my ($this) = @_;
2270   $this->send('ListClusterSkins');
2271   return undef unless $this->_parseResponse();
2272   $this->parseWords($this->getWords);
2273 }
2274
2275 sub CreateClusterSkin {
2276   my ( $this, $skin ) = @_;
2277   croak 'usage CGP::CLI->CreateClusterSkin($skinName)'
2278       unless defined $skin;
2279
2280   $this->send('CreateClusterSkin '.$this->printWords($skin));
2281   $this->_parseResponse();
2282 }
2283
2284 sub RenameClusterSkin {
2285   my ( $this, $skin, $newName ) = @_;
2286   croak 'usage CGP::CLI->RenameClusterSkin($oldSkinName,$newSkinName)'
2287       unless defined $skin && defined $newName;
2288
2289   $this->send('RenameClusterSkin '.$this->printWords($skin).' INTO '.$this->printWords($newName));
2290   $this->_parseResponse();
2291 }
2292
2293 sub DeleteClusterSkin {
2294   my ( $this, $skin ) = @_;
2295   croak 'usage CGP::CLI->DeleteClusterSkin($skinName)'
2296       unless defined $skin;
2297
2298   $this->send('DeleteClusterSkin '.$this->printWords($skin));
2299   $this->_parseResponse();
2300 }
2301
2302 sub ListClusterSkinFiles {
2303   my ( $this, $skin ) = @_;
2304   croak 'usage CGP::CLI->ListClusterSkinFiles($skinName)'
2305       unless defined $skin;
2306
2307   $this->send('ListClusterSkinFiles '.$this->printWords($skin));
2308   return undef unless $this->_parseResponse();
2309   $this->parseWords($this->getWords);
2310 }
2311
2312 sub ReadClusterSkinFile {
2313   my ( $this, $skin, $fileName ) = @_;
2314   croak 'usage CGP::CLI->ReadClusterSkinFile($skinName,$fileName)'
2315       unless defined $skin && defined $fileName;
2316
2317   $this->send('ReadClusterSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName));
2318   return undef unless $this->_parseResponse();
2319   $this->parseWords($this->getWords);
2320 }
2321
2322 sub StoreClusterSkinFile {
2323   my ( $this, $skin, $fileName,$data ) = @_;
2324   croak 'usage CGP::CLI->StoreClusterSkinFile($skinName,$fileName,$base64data)'
2325       unless defined $skin && defined $fileName && defined $data;
2326
2327   $this->send('StoreClusterSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DATA ['.$data.']');
2328   $this->_parseResponse();
2329 }
2330
2331 sub DeleteClusterSkinFile {
2332   my ( $this, $skin, $fileName ) = @_;
2333   croak 'usage CGP::CLI->DeleteClusterSkinFile($skinName,$fileName)'
2334       unless defined $skin && defined $fileName;
2335
2336   $this->send('StoreClusterSkinFile '.$this->printWords($skin).' FILE '.$this->printWords($fileName).' DELETE');
2337   $this->_parseResponse();
2338 }
2339
2340 #############################################
2341 #   Web Interface Tuning
2342
2343 sub ListWebUserInterface {
2344   my ($this, $domainName, $path) = @_;
2345
2346   my $line = 'ListWebUserInterface';
2347   $line .= ' '.$domainName if($domainName);
2348   $line .= ' PATH '.$this->printWords($path) if($path);
2349
2350   $this->send($line);
2351   return undef unless $this->_parseResponse();
2352   $this->parseWords($this->getWords);
2353 }
2354
2355 sub GetWebUserInterface {
2356   my ($this, $domainName, $path) = @_;
2357   croak 'usage CGP::CLI->GetWebUserInterface($domainName, $fileName)'
2358     unless defined $domainName && defined $path;
2359
2360   my $line = 'GetWebUserInterface '.$domainName.' FILE '.$this->printWords($path);
2361   $this->send($line);
2362   return undef unless $this->_parseResponse();
2363   $this->parseWords($this->getWords);
2364 }
2365
2366 sub PutWebUserInterface {
2367   my ($this, $domainName, $path, $data) = @_;
2368   croak 'usage CGP::CLI->PutWebUserInterface($domainName, $fileName, $base64data)'
2369     unless defined $domainName && defined $path && defined $data;
2370
2371   my $line = 'PutWebUserInterface '.$domainName;
2372   $line .= ' FILE '.$this->printWords($path).' DATA ['.$data.']';
2373   $this->send($line);
2374   $this->_parseResponse();
2375 }
2376
2377 sub DeleteWebUserInterface {
2378   my ($this, $domainName, $path) = @_;
2379   croak 'usage CGP::CLI->DeleteWebUserInterface($domainName, $fileName)'
2380     unless defined $domainName && defined $path;
2381
2382   my $line = 'DeleteWebUserInterface ';
2383   $line .= ' '.$domainName if($domainName);
2384   $line .= ' FILE '.$this->printWords($path) if($path);
2385
2386   $this->send($line);
2387   $this->_parseResponse();
2388 }
2389
2390 sub ClearWebUserCache {
2391   my ($this, $domainName) = @_;
2392
2393   my $line = 'ClearWebUserCache';
2394   $line .= ' '.$domainName if($domainName);
2395
2396   $this->send($line);
2397   $this->_parseResponse();
2398 }
2399
2400 #############################################
2401 #   Web Interface Integration
2402
2403 sub CreateWebUserSession {
2404   my ($this, $accountName, $ipAddress, $wml,$skin,$origAddress) = @_;
2405   croak 'usage CGP::CLI->CreateWebUserSession($accountName, $IP_Address[, "WML"[,"mySkin"]][,$origAddress )'
2406     unless defined $accountName && defined $ipAddress;
2407   my $line='CreateWebUserSession '.$accountName.' ADDRESS '.$ipAddress;
2408   $line .= " FOR $origAddress" if($origAddress);
2409   $line .= " $wml" if($wml);
2410   $line .= " SKIN $skin" if($skin);
2411   
2412   $this->send($line);
2413   return undef unless $this->_parseResponse();
2414   $this->parseWords($this->getWords);
2415 }
2416
2417 sub CreateXIMSSSession {
2418   my ($this, $accountName, $ipAddress,$origAddress) = @_;
2419   croak 'usage CGP::CLI->CreateXIMSSSession($accountName, $IP_Address,[$origAddress] )'
2420     unless defined $accountName && defined $ipAddress;
2421   my $line='CreateXIMSSSession '.$accountName.' ADDRESS '.$ipAddress;
2422   $line .= " FOR $origAddress" if($origAddress);
2423   $this->send($line);
2424   return undef unless $this->_parseResponse();
2425   $this->parseWords($this->getWords);
2426 }
2427
2428 sub FindWebUserSession {
2429   my ($this, $accountName,$address) = @_;
2430   croak 'usage CGP::CLI->FindWebUserSession($accountName [,$address])' unless defined $accountName;
2431
2432   my $line='FindWebUserSession '.$accountName;
2433   $line .= ' ADDRESS '.$address if($address);
2434
2435   $this->send($line);
2436   return undef unless $this->_parseResponse();
2437   $this->parseWords($this->getWords);
2438 }
2439
2440 sub GetWebUserSession {
2441   my ($this, $sessionID,$domain) = @_;
2442   croak 'usage CGP::CLI->GetWebUserSession($sessionID [,$domain])' unless defined $sessionID;
2443
2444   my $line='GetWebUserSession '.$sessionID;
2445   $line .= ' DOMAIN '.$domain if($domain);
2446
2447   $this->send($line);
2448   return undef unless $this->_parseResponse();
2449   $this->parseWords($this->getWords);
2450 }
2451 sub GetSession {
2452   my ($this, $sessionID,$domain) = @_;
2453   croak 'usage CGP::CLI->GetSession($sessionID [,$domain])' unless defined $sessionID;
2454
2455   my $line='GetSession '.$sessionID;
2456   $line .= ' DOMAIN '.$domain if($domain);
2457
2458   $this->send($line);
2459   return undef unless $this->_parseResponse();
2460   $this->parseWords($this->getWords);
2461 }
2462
2463
2464
2465 sub KillWebUserSession {
2466   my ($this, $sessionID,$domain) = @_;
2467   croak 'usage CGP::CLI->KillWebUserSession($sessionID [,$domain])' unless defined $sessionID;
2468   my $line='KillWebUserSession '.$sessionID;
2469   $line .= ' DOMAIN '.$domain if($domain);
2470
2471   $this->send($line);
2472   $this->_parseResponse();
2473 }
2474 sub KillSession {
2475   my ($this, $sessionID,$domain) = @_;
2476   croak 'usage CGP::CLI->KillSession($sessionID [,$domain])' unless defined $sessionID;
2477   my $line='KillSession '.$sessionID;
2478   $line .= ' DOMAIN '.$domain if($domain);
2479
2480   $this->send($line);
2481   $this->_parseResponse();
2482 }
2483
2484 #############################################
2485 #   Real-Time Application Administration 
2486  
2487 sub CreateDomainPBX {
2488   my ( $this, $domain, $language ) = @_;
2489   croak 'usage CGP::CLI->CreateDomainPBX($domainName,$language)'
2490       unless defined $domain;
2491   my $line = 'CreateDomainPBX '.$domain;
2492   $line .= ' FILE '.$this->printWords($language) if($language);
2493       
2494   $this->send($line);
2495   $this->_parseResponse();
2496 }
2497
2498 sub ListDomainPBXFiles {
2499   my ($this, $domain,$language) = @_;
2500   croak 'usage CGP::CLI->ListDomainPBXFiles($domainName,$language)'
2501       unless defined $domain;
2502   my $line = 'ListDomainPBXFiles '.$domain;
2503   $line .= ' FILE '.$this->printWords($language) if($language);
2504   $this->send($line);
2505   return undef unless $this->_parseResponse();
2506   $this->parseWords($this->getWords);
2507 }
2508
2509 sub ReadDomainPBXFile {
2510   my ( $this, $domain, $fileName ) = @_;
2511   croak 'usage CGP::CLI->ReadDomainPBXFile($domainName,$fileName)'
2512       unless defined $domain && defined $fileName;
2513
2514   $this->send('ReadDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName));
2515   return undef unless $this->_parseResponse();
2516   $this->parseWords($this->getWords);
2517 }
2518
2519 sub StoreDomainPBXFile {
2520   my ( $this, $domain, $fileName,$base64data ) = @_;
2521   croak 'usage CGP::CLI->StoreDomainPBXFile($domainName,$fileName,$base64data)'
2522       unless defined $domain && defined $fileName && defined $base64data;
2523   $this->send('StoreDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName).' DATA ['.$base64data.']');
2524   $this->_parseResponse();
2525 }
2526
2527 sub DeleteDomainPBXFile {
2528   my ( $this, $domain, $fileName ) = @_;
2529   croak 'usage CGP::CLI->DeleteDomainPBXFile($domainName,$fileName)'
2530       unless defined $domain && defined $fileName;
2531
2532   $this->send('StoreDomainPBXFile '.$domain.' FILE '.$this->printWords($fileName).' DELETE');
2533   $this->_parseResponse();
2534 }
2535
2536 #--
2537
2538 sub CreateServerPBX {
2539   my ( $this, $language ) = @_;
2540   my $line = 'CreateServerPBX';
2541   $line .= $this->printWords($language) if($language);      
2542   $this->send($line);
2543   $this->_parseResponse();
2544 }
2545
2546 sub ListServerPBXFiles {
2547   my ($this,$language) = @_;
2548
2549   my $line = 'ListServerPBXFiles ';
2550   $line .= $this->printWords($language) if($language);
2551   $this->send($line);
2552   return undef unless $this->_parseResponse();
2553   $this->parseWords($this->getWords);
2554 }
2555
2556 sub ReadServerPBXFile {
2557   my ( $this, $fileName ) = @_;
2558   croak 'usage CGP::CLI->ReadServerPBXFile($fileName)'
2559       unless defined $fileName;
2560
2561   $this->send('ReadServerPBXFile '.$this->printWords($fileName));
2562   return undef unless $this->_parseResponse();
2563   $this->parseWords($this->getWords);
2564 }
2565
2566 sub StoreServerPBXFile {
2567   my ( $this, $fileName,$base64data ) = @_;
2568   croak 'usage CGP::CLI->StoreServerPBXFile($fileName,$base64data)'
2569       unless  defined $fileName && defined $base64data;
2570   $this->send('StoreServerPBXFile ' .$this->printWords($fileName).' DATA ['.$base64data.']');
2571   $this->_parseResponse();
2572 }
2573
2574 sub DeleteServerPBXFile {
2575   my ( $this, $fileName ) = @_;
2576   croak 'usage CGP::CLI->DeleteServerPBXFile($fileName)'
2577       unless defined $fileName;
2578
2579   $this->send('StoreServerPBXFile '.$this->printWords($fileName).' DELETE');
2580   $this->_parseResponse();
2581 }
2582
2583 #--
2584
2585 sub CreateClusterPBX {
2586   my ( $this, $language ) = @_;
2587   my $line = 'CreateClusterPBX';
2588   $line .= $this->printWords($language) if($language);      
2589   $this->send($line);
2590   $this->_parseResponse();
2591 }
2592
2593 sub ListClusterPBXFiles {
2594   my ($this,$language) = @_;
2595
2596   my $line = 'ListClusterPBXFiles ';
2597   $line .= $this->printWords($language) if($language);
2598   $this->send($line);
2599   return undef unless $this->_parseResponse();
2600   $this->parseWords($this->getWords);
2601 }
2602
2603 sub ReadClusterPBXFile {
2604   my ( $this, $fileName ) = @_;
2605   croak 'usage CGP::CLI->ReadClusterPBXFile($fileName)'
2606       unless defined $fileName;
2607
2608   $this->send('ReadClusterPBXFile '.$this->printWords($fileName));
2609   return undef unless $this->_parseResponse();
2610   $this->parseWords($this->getWords);
2611 }
2612
2613 sub StoreClusterPBXFile {
2614   my ( $this, $fileName,$base64data ) = @_;
2615   croak 'usage CGP::CLI->StoreClusterPBXFile($fileName,$base64data)'
2616       unless  defined $fileName && defined $base64data;
2617   $this->send('StoreClusterPBXFile ' .$this->printWords($fileName).' DATA ['.$base64data.']');
2618   $this->_parseResponse();
2619 }
2620
2621 sub DeleteClusterPBXFile {
2622   my ( $this, $fileName ) = @_;
2623   croak 'usage CGP::CLI->DeleteClusterPBXFile($fileName)'
2624       unless defined $fileName;
2625
2626   $this->send('StoreClusterPBXFile '.$this->printWords($fileName).' DELETE');
2627   $this->_parseResponse();
2628 }
2629
2630 #############################################
2631 #  Server Settings
2632
2633 sub GetModule {
2634   my ( $this, $moduleName ) = @_;
2635   $this->send('GetModule '.$moduleName);
2636   return undef unless $this->_parseResponse();
2637   $this->parseWords($this->getWords);
2638 }
2639
2640 sub UpdateModule {
2641   my ( $this, $moduleName, $newSettings ) = @_;
2642   croak 'usage CGP::CLI->UpdateModule($moduleName, \%newSettings)'
2643     unless defined $moduleName && defined $newSettings;
2644   $this->send ('UpdateModule '.$moduleName.' '.$this->printWords($newSettings) );
2645   $this->_parseResponse();
2646 }
2647
2648 sub SetModule {
2649   my ( $this, $moduleName, $newSettings ) = @_;
2650   croak 'usage CGP::CLI->SetModule($moduleName, \%newSettings)'
2651     unless defined $moduleName && defined $newSettings;
2652   $this->send ('SetModule '.$moduleName.' '.$this->printWords($newSettings) );
2653   $this->_parseResponse();
2654 }
2655
2656 sub GetQueueSettings {
2657   my ( $this ) = @_;
2658   $this->send('GetQueueSettings');
2659   return undef unless $this->_parseResponse();
2660   $this->parseWords($this->getWords);
2661 }
2662 sub SetQueueSettings {
2663   my ( $this,  $newSettings ) = @_;
2664   croak 'usage CGP::CLI->SetQueueSettings(\%newSettings)'
2665     unless defined $newSettings;
2666   $this->send ('SetQueueSettings '.$this->printWords($newSettings) );
2667   $this->_parseResponse();
2668 }
2669
2670 sub GetSignalSettings {
2671   my ( $this ) = @_;
2672   $this->send('GetSignalSettings');
2673   return undef unless $this->_parseResponse();
2674   $this->parseWords($this->getWords);
2675 }
2676 sub SetSignalSettings {
2677   my ( $this,  $newSettings ) = @_;
2678   croak 'usage CGP::CLI->SetSignalSettings(\%newSettings)'
2679     unless defined $newSettings;
2680   $this->send ('SetSignalSettings '.$this->printWords($newSettings) );
2681   $this->_parseResponse();
2682 }
2683 sub GetClusterSettings {
2684   my ( $this ) = @_;
2685   $this->send('GetClusterSettings');
2686   return undef unless $this->_parseResponse();
2687   $this->parseWords($this->getWords);
2688 }
2689 sub SetClusterSettings {
2690   my ( $this,  $newSettings ) = @_;
2691   croak 'usage CGP::CLI->SetClusterSettings(\%newSettings)'
2692     unless defined $newSettings;
2693   $this->send ('SetClusterSettings '.$this->printWords($newSettings) );
2694   $this->_parseResponse();
2695 }
2696
2697
2698 sub GetLANIPs {
2699   my ( $this ) = @_;
2700   $this->send('GetLANIPs');
2701   return undef unless $this->_parseResponse();
2702   $this->parseWords($this->getWords);
2703 }
2704
2705 sub GetBlacklistedIPs {
2706   my ( $this ) = @_;
2707   $this->send('GetBlacklistedIPs');
2708   return undef unless $this->_parseResponse();
2709   $this->parseWords($this->getWords);
2710 }
2711
2712 sub GetClientIPs {
2713   my ( $this ) = @_;
2714   $this->send('GetClientIPs');
2715   return undef unless $this->_parseResponse();
2716   $this->parseWords($this->getWords);
2717 }
2718
2719 sub GetWhiteHoleIPs {
2720   my ( $this ) = @_;
2721   $this->send('GetWhiteHoleIPs');
2722   return undef unless $this->_parseResponse();
2723   $this->parseWords($this->getWords);
2724 }
2725 sub GetNATedIPs {
2726   my ( $this ) = @_;
2727   $this->send('GetNATedIPs');
2728   return undef unless $this->_parseResponse();
2729   $this->parseWords($this->getWords);
2730 }
2731 sub GetDebugIPs {
2732   my ( $this ) = @_;
2733   $this->send('GetDebugIPs');
2734   return undef unless $this->_parseResponse();
2735   $this->parseWords($this->getWords);
2736 }
2737 sub GetDeniedIPs {
2738   my ( $this ) = @_;
2739   $this->send('GetDeniedIPs');
2740   return undef unless $this->_parseResponse();
2741   $this->parseWords($this->getWords);
2742 }
2743
2744 sub GetProtection {
2745   my ( $this ) = @_;
2746   $this->send('GetProtection');
2747   return undef unless $this->_parseResponse();
2748   $this->parseWords($this->getWords);
2749 }
2750
2751 sub GetBanned {
2752   my ( $this ) = @_;
2753   $this->send('GetBanned');
2754   return undef unless $this->_parseResponse();
2755   $this->parseWords($this->getWords);
2756 }
2757
2758 sub SetLANIPs {
2759   my ( $this, $addresses ) = @_;
2760   croak 'usage CGP::CLI->SetLANIPs("10.0.0.1\e192.168.0.1")'
2761     unless defined $addresses;
2762   $this->send ('SetLANIPs '.$this->printWords($addresses));
2763   $this->_parseResponse();
2764 }
2765
2766
2767 sub SetBlacklistedIPs {
2768   my ( $this, $addresses ) = @_;
2769   croak 'usage CGP::CLI->SetBlacklistedIPs("11.22.33.44\e55.66.77.88")'
2770     unless defined $addresses;
2771   $this->send ('SetBlacklistedIPs '.$this->printWords($addresses));
2772   $this->_parseResponse();
2773 }
2774
2775 sub SetClientIPs {
2776   my ( $this, $addresses ) = @_;
2777   croak 'usage CGP::CLI->SetClientIPs("11.22.33.44\e55.66.77.88")'
2778     unless defined $addresses;
2779   $this->send ('SetClientIPs '.$this->printWords($addresses));
2780   $this->_parseResponse();
2781 }
2782
2783 sub SetWhiteHoleIPs {
2784   my ( $this, $addresses ) = @_;
2785   croak 'usage CGP::CLI->SetWhiteHoleIPs("11.22.33.44\e55.66.77.88")'
2786     unless defined $addresses;
2787   $this->send ('SetWhiteHoleIPs '.$this->printWords($addresses));
2788   $this->_parseResponse();
2789 }
2790 sub SetNATedIPs {
2791   my ( $this, $addresses ) = @_;
2792   croak 'usage CGP::CLI->SetNATedIPs("192.168.0.1\e10.0.0.1")'
2793     unless defined $addresses;
2794   $this->send ('SetNATedIPs '.$this->printWords($addresses));
2795   $this->_parseResponse();
2796 }
2797 sub SetDebugIPs {
2798   my ( $this, $addresses ) = @_;
2799   croak 'usage CGP::CLI->SetDebugIPs("11.22.33.44\e55.66.77.88")'
2800     unless defined $addresses;
2801   $this->send ('SetDebugIPs '.$this->printWords($addresses));
2802   $this->_parseResponse();
2803 }
2804 sub SetDeniedIPs {
2805   my ( $this, $addresses ) = @_;
2806   croak 'usage CGP::CLI->SetDeniedIPs("11.22.33.44\e55.66.77.88")'
2807     unless defined $addresses;
2808   $this->send ('SetDeniedIPs '.$this->printWords($addresses));
2809   $this->_parseResponse();
2810 }
2811
2812 sub SetProtection {
2813   my ( $this, $settings ) = @_;
2814   croak 'usage CGP::CLI->SetProtection(\%settings)'
2815     unless defined $settings;
2816   $this->send ('SetProtection '.$this->printWords($settings));
2817   $this->_parseResponse();
2818 }
2819
2820 sub SetBanned {
2821   my ( $this, $settings ) = @_;
2822   croak 'usage CGP::CLI->SetBanned(\%settings)'
2823     unless defined $settings;
2824   $this->send ('SetBanned '.$this->printWords($settings));
2825   $this->_parseResponse();
2826 }
2827
2828 sub GetClusterLANIPs {
2829   my ( $this ) = @_;
2830   $this->send('GetClusterLANIPs');
2831   return undef unless $this->_parseResponse();
2832   $this->parseWords($this->getWords);
2833 }
2834
2835 sub GetClusterBlacklistedIPs {
2836   my ( $this ) = @_;
2837   $this->send('GetClusterBlacklistedIPs');
2838   return undef unless $this->_parseResponse();
2839   $this->parseWords($this->getWords);
2840 }
2841
2842 sub GetClusterClientIPs {
2843   my ( $this ) = @_;
2844   $this->send('GetClusterClientIPs');
2845   return undef unless $this->_parseResponse();
2846   $this->parseWords($this->getWords);
2847 }
2848
2849 sub GetClusterWhiteHoleIPs {
2850   my ( $this ) = @_;
2851   $this->send('GetClusterWhiteHoleIPs');
2852   return undef unless $this->_parseResponse();
2853   $this->parseWords($this->getWords);
2854 }
2855 sub GetClusterNATedIPs {
2856   my ( $this ) = @_;
2857   $this->send('GetClusterNATedIPs');
2858   return undef unless $this->_parseResponse();
2859   $this->parseWords($this->getWords);
2860 }
2861 sub GetClusterDebugIPs {
2862   my ( $this ) = @_;
2863   $this->send('GetClusterDebugIPs');
2864   return undef unless $this->_parseResponse();
2865   $this->parseWords($this->getWords);
2866 }
2867 sub GetClusterDeniedIPs {
2868   my ( $this ) = @_;
2869   $this->send('GetClusterDeniedIPs');
2870   return undef unless $this->_parseResponse();
2871   $this->parseWords($this->getWords);
2872 }
2873
2874 sub GetClusterProtection {
2875   my ( $this ) = @_;
2876   $this->send('GetClusterProtection');
2877   return undef unless $this->_parseResponse();
2878   $this->parseWords($this->getWords);
2879 }
2880 sub GetClusterBanned {
2881   my ( $this ) = @_;
2882   $this->send('GetClusterBanned');
2883   return undef unless $this->_parseResponse();
2884   $this->parseWords($this->getWords);
2885 }
2886
2887 sub SetClusterLANIPs {
2888   my ( $this, $addresses ) = @_;
2889   croak 'usage CGP::CLI->SetClusterLANIPs("10.0.0.1\e192.168.0.1")'
2890     unless defined $addresses;
2891   $this->send ('SetClusterLANIPs '.$this->printWords($addresses));
2892   $this->_parseResponse();
2893 }
2894
2895 sub SetClusterBlacklistedIPs {
2896   my ( $this, $addresses ) = @_;
2897   croak 'usage CGP::CLI->SetClusterBlacklistedIPs("11.22.33.44\e55.66.77.88")'
2898     unless defined $addresses;
2899   $this->send ('SetClusterBlacklistedIPs '.$this->printWords($addresses));
2900   $this->_parseResponse();
2901 }
2902
2903 sub SetClusterClientIPs {
2904   my ( $this, $addresses ) = @_;
2905   croak 'usage CGP::CLI->SetClusterClientIPs("11.22.33.44\e55.66.77.88")'
2906     unless defined $addresses;
2907   $this->send ('SetClusterClientIPs '.$this->printWords($addresses));
2908   $this->_parseResponse();
2909 }
2910
2911 sub SetClusterWhiteHoleIPs {
2912   my ( $this, $addresses ) = @_;
2913   croak 'usage CGP::CLI->SetClusterWhiteHoleIPs("11.22.33.44\e55.66.77.88")'
2914     unless defined $addresses;
2915   $this->send ('SetClusterWhiteHoleIPs '.$this->printWords($addresses));
2916   $this->_parseResponse();
2917 }
2918 sub SetClusterNATedIPs {
2919   my ( $this, $addresses ) = @_;
2920   croak 'usage CGP::CLI->SetClusterNATedIPs("192.168.0.1\e10.0.0.1")'
2921     unless defined $addresses;
2922   $this->send ('SetClusterNATedIPs '.$this->printWords($addresses));
2923   $this->_parseResponse();
2924 }
2925 sub SetClusterDebugIPs {
2926   my ( $this, $addresses ) = @_;
2927   croak 'usage CGP::CLI->SetClusterDebugIPs("11.22.33.44\e55.66.77.88")'
2928     unless defined $addresses;
2929   $this->send ('SetClusterDebugIPs '.$this->printWords($addresses));
2930   $this->_parseResponse();
2931 }
2932 sub SetClusterDeniedIPs {
2933   my ( $this, $addresses ) = @_;
2934   croak 'usage CGP::CLI->SetClusterDeniedIPs("11.22.33.44\e55.66.77.88")'
2935     unless defined $addresses;
2936   $this->send ('SetClusterDeniedIPs '.$this->printWords($addresses));
2937   $this->_parseResponse();
2938 }
2939
2940 sub SetClusterProtection {
2941   my ( $this, $settings ) = @_;
2942   croak 'usage CGP::CLI->SetClusterProtection(\%settings)'
2943     unless defined $settings;
2944   $this->send ('SetClusterProtection '.$this->printWords($settings));
2945   $this->_parseResponse();
2946 }
2947
2948 sub GetServerRules {
2949   my $this = shift;
2950   $this->send('GetServerRules');
2951   return undef unless $this->_parseResponse();
2952   $this->parseWords($this->getWords);
2953 }
2954
2955 sub SetServerRules {
2956   my ($this, $rules) = @_;
2957   croak 'usage CGP::CLI->SetServerRules(\@rules)'
2958     unless defined $rules;
2959   $this->send('SetServerRules '.$this->printWords($rules));
2960   $this->_parseResponse();
2961 }
2962
2963
2964 sub GetClusterRules {
2965   my $this = shift;
2966   $this->send('GetClusterRules');
2967   return undef unless $this->_parseResponse();
2968   $this->parseWords($this->getWords);
2969 }
2970
2971 sub SetClusterRules {
2972   my ($this, $rules) = @_;
2973   croak 'usage CGP::CLI->SetClusterRules(\@rules)'
2974     unless defined $rules;
2975   $this->send('SetClusterRules '.$this->printWords($rules));
2976   $this->_parseResponse();
2977 }
2978
2979 sub GetServerMailRules {
2980   my $this = shift;
2981   $this->send('GetServerMailRules');
2982   return undef unless $this->_parseResponse();
2983   $this->parseWords($this->getWords);
2984 }
2985
2986 sub SetServerMailRules {
2987   my ($this, $rules) = @_;
2988   croak 'usage CGP::CLI->SetServerMailRules(\@rules)'
2989     unless defined $rules;
2990   $this->send('SetServerMailRules '.$this->printWords($rules));
2991   $this->_parseResponse();
2992 }
2993
2994 #sub UpdateServerMailRule {
2995 #  my ($this, $rule) = @_;
2996 #  croak 'usage CGP::CLI->UpdateServerMailRules(\@rule)'
2997 #    unless defined $rule;
2998 #  $this->send('UpdateServerMailRule '.$this->printWords($rule));
2999 #  $this->_parseResponse();
3000 #}
3001
3002 sub GetServerSignalRules {
3003   my $this = shift;
3004   $this->send('GetServerSignalRules');
3005   return undef unless $this->_parseResponse();
3006   $this->parseWords($this->getWords);
3007 }
3008
3009 sub SetServerSignalRules {
3010   my ($this, $rules) = @_;
3011   croak 'usage CGP::CLI->SetServerSignalRules(\@rules)'
3012     unless defined $rules;
3013   $this->send('SetServerSignalRules '.$this->printWords($rules));
3014   $this->_parseResponse();
3015 }
3016
3017 #sub UpdateServerSignalRule {
3018 #  my ($this, $rule) = @_;
3019 #  croak 'usage CGP::CLI->UpdateServerSignalRule(\@rule)'
3020 #    unless defined $rule;
3021 #  $this->send('UpdateServerSignalRule '.$this->printWords($rule));
3022 #  $this->_parseResponse();
3023 #}
3024
3025 sub GetClusterMailRules {
3026   my $this = shift;
3027   $this->send('GetClusterMailRules');
3028   return undef unless $this->_parseResponse();
3029   $this->parseWords($this->getWords);
3030 }
3031
3032 sub SetClusterMailRules {
3033   my ($this, $rules) = @_;
3034   croak 'usage CGP::CLI->SetClusterMailRules(\@rules)'
3035     unless defined $rules;
3036   $this->send('SetClusterMailRules '.$this->printWords($rules));
3037   $this->_parseResponse();
3038 }
3039
3040 #sub UpdateClusterMailRule {
3041 #  my ($this, $rule) = @_;
3042 #  croak 'usage CGP::CLI->UpdateClusterMailRule(\@rule)'
3043 #    unless defined $rule;
3044 #  $this->send('UpdateClusterMailRule '.$this->printWords($rule));
3045 #  $this->_parseResponse();
3046 #}
3047
3048 sub GetClusterSignalRules {
3049   my $this = shift;
3050   $this->send('GetClusterSignalRules');
3051   return undef unless $this->_parseResponse();
3052   $this->parseWords($this->getWords);
3053 }
3054
3055 sub SetClusterSignalRules {
3056   my ($this, $rules) = @_;
3057   croak 'usage CGP::CLI->SetClusterSignalRules(\@rules)'
3058     unless defined $rules;
3059   $this->send('SetClusterSignalRules '.$this->printWords($rules));
3060   $this->_parseResponse();
3061 }
3062
3063 #sub UpdateClusterSignalRule {
3064 #  my ($this, $rule) = @_;
3065 #  croak 'usage CGP::CLI->UpdateClusterSignalRule(\@rule)'
3066 #    unless defined $rule;
3067 #  $this->send('UpdateClusterSignalRule '.$this->printWords($rule));
3068 #  $this->_parseResponse();
3069 #}
3070
3071
3072
3073 sub RefreshOSData {
3074   my ($this) = @_;
3075   $this->send('RefreshOSData');
3076   $this->_parseResponse();
3077 }
3078
3079 sub GetRouterTable {
3080   my $this = shift;
3081   $this->send('GetRouterTable');
3082   return undef unless $this->_parseResponse();
3083   $this->parseWords($this->getWords);
3084 }
3085
3086 sub SetRouterTable {
3087   my ($this, $table) = @_;
3088   croak 'usage CGP::CLI->GetRouterTable("<addr1>=addr1\@domain.com\\e<addr2>=addr2\@domain.com\\e")'
3089     unless defined $table;
3090   $this->send('SetRouterTable '.$this->printWords($table));
3091   $this->_parseResponse();
3092 }
3093
3094 sub GetRouterSettings {
3095   my $this = shift;
3096   $this->send('GetRouterSettings');
3097   return undef unless $this->_parseResponse();
3098   $this->parseWords($this->getWords);
3099 }
3100
3101 sub SetRouterSettings {
3102   my ($this, $settings) = @_;
3103   croak 'usage CGP::CLI->SetRouterSettings(\@settings)'
3104     unless defined $settings;
3105   $this->send('SetRouterSettings '.$this->printWords($settings));
3106   $this->_parseResponse();
3107 }
3108
3109
3110 sub GetClusterRouterTable {
3111   my $this = shift;
3112   $this->send('GetClusterRouterTable');
3113   return undef unless $this->_parseResponse();
3114   $this->parseWords($this->getWords);
3115 }
3116
3117 sub SetClusterRouterTable {
3118   my ($this, $table) = @_;
3119   croak 'usage CGP::CLI->SetClusterRouterTable("<addr1>=addr1\@domain.com\\e<addr2>=addr2\@domain.com\\e")'
3120     unless defined $table;
3121   $this->send('SetClusterRouterTable '.$this->printWords($table));
3122   $this->_parseResponse();
3123 }
3124
3125
3126 sub GetServerIntercept {
3127   my ( $this ) = @_;
3128   $this->send('GetServerIntercept');
3129   return undef unless $this->_parseResponse();
3130   $this->parseWords($this->getWords);
3131 }
3132 sub SetServerIntercept {
3133   my ( $this, $settings ) = @_;
3134   croak 'usage CGP::CLI->SetServerIntercept(\%settings)'
3135     unless defined $settings;
3136   $this->send ('SetServerIntercept '.$this->printWords($settings));
3137   $this->_parseResponse();
3138 }
3139
3140 sub GetClusterIntercept {
3141   my ( $this ) = @_;
3142   $this->send('GetClusterIntercept');
3143   return undef unless $this->_parseResponse();
3144   $this->parseWords($this->getWords);
3145 }
3146 sub SetClusterIntercept {
3147   my ( $this, $settings ) = @_;
3148   croak 'usage CGP::CLI->SetClusterIntercept(\%settings)'
3149     unless defined $settings;
3150   $this->send ('SetClusterIntercept '.$this->printWords($settings));
3151   $this->_parseResponse();
3152 }
3153
3154
3155 sub Route {
3156   my ($this, $address, $mail) = @_;
3157   croak 'usage CGP::CLI->Route(address[,"mail"])'
3158     unless defined $address;
3159   my $line='Route '.$address;
3160   $line .= ' mail' if($mail);
3161   $this->send($line);
3162   return undef unless $this->_parseResponse();
3163   $this->parseWords($this->getWords);
3164 }
3165
3166 #############################################
3167 #  Monitoring commands
3168
3169 sub GetSNMPElement {
3170   my ($this, $element) = @_;
3171   $this->send('GetSNMPElement '.$element);
3172   return undef unless $this->_parseResponse();
3173   $this->parseWords($this->getWords);
3174 }
3175 sub GetDialogInfo {
3176   my ($this, $dialogID) = @_;
3177   $this->send('GetDialogInfo '.$dialogID);
3178   return undef unless $this->_parseResponse();
3179   $this->parseWords($this->getWords);
3180 }
3181
3182 sub Shutdown {
3183   my $this = shift;
3184   $this->send('SHUTDOWN');
3185   $this->_parseResponse();
3186 }
3187
3188 #############################################
3189 #  Statistics commands
3190
3191 sub GetAccountStat {
3192   my ($this, $account, $key) = @_;
3193   croak 'usage CGP::CLI->GetAccountStat($account[,$key])'
3194     unless defined $account;
3195   my $line = 'GetAccountStat '.$account;
3196   $line .= ' Key '.$key if $key;
3197   $this->send($line);
3198   return undef unless $this->_parseResponse();
3199   $this->parseWords($this->getWords);
3200 }
3201
3202 sub ResetAccountStat {
3203   my ($this, $account, $key) = @_;
3204   croak 'usage CGP::CLI->ResetAccountStat($account[,$key])'
3205     unless defined $account;
3206   my $line = 'ResetAccountStat '.$account;
3207   $line .= ' Key '.$key if $key;
3208   $this->send($line);
3209   $this->_parseResponse();
3210 }
3211
3212 sub GetDomainStat {
3213   my ($this, $domain, $key) = @_;
3214   croak 'usage CGP::CLI->GetDomainStat($domain[,$key])'
3215     unless defined $domain;
3216   my $line = 'GetDomainStat '.$domain;
3217   $line .= ' Key '.$key if $key;
3218   $this->send($line);
3219   return undef unless $this->_parseResponse();
3220   $this->parseWords($this->getWords);
3221 }
3222
3223 sub ResetDomainStat {
3224   my ($this, $domain, $key) = @_;
3225   croak 'usage CGP::CLI->ResetDomainStat($domain[,$key])'
3226     unless defined $domain;
3227   my $line = 'ResetDomainStat '.$domain;
3228   $line .= ' Key '.$key if $key;
3229   $this->send($line);
3230   $this->_parseResponse();
3231 }
3232
3233 #############################################
3234 #  Miscellaneous commands
3235
3236 sub WriteLog {
3237   my ($this, $level, $msg) = @_;
3238   croak 'usage CGP::CLI->WriteLog($level,$message)'
3239     unless defined $level && defined $msg;
3240   $this->send('WriteLog '.$level.' '.$this->printWords($msg));
3241   $this->_parseResponse();
3242 }
3243 sub ReleaseSMTPQueue {
3244   my ($this, $queue) = @_;
3245   croak 'usage CGP::CLI->ReleaseSMTPQueue($queueName)'
3246     unless defined $queue;
3247   $this->send('ReleaseSMTPQueue '.$this->printWords($queue));
3248   $this->_parseResponse();
3249 }
3250 sub RejectQueueMessage {
3251   my ($this, $msg, $text) = @_;
3252   croak 'usage CGP::CLI->RejectQueueMessage($msgID [,$errorText])'
3253     unless defined $msg;
3254   my $line = 'RejectQueueMessage '.$msg;
3255   $line .= $this->printWords($text) if $text;
3256   $this->send($line);
3257   $this->_parseResponse();
3258 }
3259 sub GetMessageQueueInfo {
3260   my ($this, $moduleName, $queueName) = @_;
3261   croak 'usage CGP::CLI->GetMessageQueueInfo($moduleName,$queueName)'
3262     unless (defined $moduleName && defined $queueName);
3263   my $line = 'GetMessageQueueInfo '.$moduleName.' QUEUE '.$this->printWords($queueName);
3264   $this->send($line);
3265   return undef unless $this->_parseResponse();
3266   $this->parseWords($this->getWords);
3267 }
3268
3269 sub GetCurrentController {
3270   my ($this) = @_;
3271   $this->send('GetCurrentController');
3272   return undef unless $this->_parseResponse();
3273   $this->parseWords($this->getWords);
3274 }
3275 sub GetTempClientIPs  {
3276   my ($this) = @_;
3277   $this->send('GetTempClientIPs');
3278   return undef unless $this->_parseResponse();
3279   $this->parseWords($this->getWords);
3280 }
3281 sub GetTempBlacklistedIPs  {
3282   my ($this) = @_;
3283   $this->send('GetTempBlacklistedIPs');
3284   return undef unless $this->_parseResponse();
3285   $this->parseWords($this->getWords);
3286 }
3287 sub SetTempBlacklistedIPs  {
3288   my ( $this, $addresses ) = @_;
3289   croak 'usage CGP::CLI->SetTempBlacklistedIPs("111.11.1.1\e222.2.2.2")'
3290     unless defined $addresses;
3291   $this->send ('SetTempBlacklistedIPs '.$this->printWords($addresses));
3292   $this->_parseResponse();
3293 }
3294
3295 sub RemoveAccountSubset  {
3296   my ($this, $account, $subset) = @_;
3297   croak 'usage CGP::CLI->RemoveAccountSubset($account,$subset)'
3298     unless defined $account && defined $subset;       
3299   $this->send('RemoveAccountSubset '.$account.' SUBSET '.$this->printWords($subset));
3300   return undef unless $this->_parseResponse();
3301 }
3302
3303
3304 #########################################################################
3305 #########################################################################
3306 ##  Internal routines
3307
3308 sub _setStrangeError
3309 {
3310     my ($this, $line, $code) = @_;
3311     if ($code)
3312     {
3313         $this->{errCode} = $code;
3314     }
3315     else
3316     {
3317         $this->{errCode} = $CGP::CLI_CODE_STRANGE;
3318     }
3319     $this->{errMsg} = $line;
3320     return 0;
3321 }
3322
3323 sub _parseResponse
3324 {
3325   my $this = shift;
3326
3327   my $responseLine = $this->{theSocket}->getline();
3328
3329
3330   print STDERR "CGP::CLI->_parseResponse::responseLine = $responseLine\n\n"
3331       if $this->{'debug'};
3332
3333   $responseLine =~ /^(\d+)\s(.*)$/;
3334   return $this->_setStrangeError($responseLine) unless ($1);
3335   $this->{errCode} = $1;
3336   if($1 == $CGP::CLI_CODE_OK_INLINE) {
3337     $this->{'inlineResponse'} = $2;     
3338     $this->{errMsg} = 'OK';
3339   } else {
3340     $this->{errMsg} = $2;
3341     chomp($this->{errMsg});
3342     $this->{errMsg} =~ s/\r$//;
3343   }
3344   $this->{'lastAccess'}=time();
3345   $this->isSuccess;
3346 }
3347
3348 sub convertOutput {
3349   my $data = $_[0];
3350   my $translate = $_[1];
3351   if(!defined($data)) {
3352     return '#NULL#';
3353   } elsif(ref($data) eq 'HASH') {
3354     my $outp='{';
3355     #$outp.="\n";
3356     foreach (sort keys %$data) {
3357       my $value=@$data{$_};
3358       $outp .= convertOutput($_,$translate).'='.convertOutput($value,$translate).';';
3359       #$outp.="\n";
3360     }
3361     $outp.= '}';
3362     #$outp.="\n";
3363     return $outp;
3364   } elsif(ref($data) eq 'ARRAY') {
3365     my $outp='(';
3366     my $first=1;
3367     foreach (@$data) {
3368       if(!$first) { $outp.=','; } else { $first=0; }
3369       $outp.=convertOutput($_,$translate);
3370     }
3371     $outp.= ')';
3372     return $outp;
3373   } else {
3374     if($data =~ /[\W_]/ || $data eq '') {
3375       if($translate) {
3376         $data =~ s/\\((?![enr\d]))/\\\\$1/g;
3377         $data =~ s/\"/\\\"/g;
3378       }
3379       $data =~ s/([\x00-\x1F\x7F])/'\\'.('0'x(3-length(ord($1)))).ord($1)/ge;
3380
3381       return '"' . $data . '"';
3382     } else {
3383       return $data;
3384     }
3385   }
3386 }
3387
3388 sub printWords {
3389   my ($this,$data)= @_;
3390   return convertOutput($data,$this->{'translateStrings'});
3391 }
3392
3393 sub strip
3394 {
3395     my $line = shift;
3396     $line =~ s/^\s+//;
3397     $line =~ s/\s+$//;
3398     return $line;
3399 }
3400
3401 sub getWords {
3402   my $this = shift;
3403   if($this->{errCode} == $CGP::CLI_CODE_OK_INLINE) {
3404         return $this->{'inlineResponse'};
3405   }
3406   my ($bag, $line) = ('', '');
3407   my $firstLine = 1;
3408   my $lastLine = '';
3409   while (1) {
3410     $line = $this->{theSocket}->getline();
3411     chomp $line;
3412     $line = strip($line);
3413     if($firstLine) {
3414       $line =~ /^(.)/;
3415       if ($1) {
3416         $lastLine = '\)' if $1 eq '(';
3417         $lastLine = '\}' if $1 eq '{';
3418         $lastLine = $lastLine . '$';
3419         $firstLine = 0;
3420       }
3421     }
3422     $bag .= $line;
3423     last if $line =~ /$lastLine/;
3424   }
3425   return $bag;
3426 }
3427
3428
3429 sub send {
3430   my ($this, $command) = @_;
3431
3432   if(time()-$this->{'lastAccess'} > $CGP::TIMEOUT ||
3433      !($this->{theSocket}) ||
3434      $this->{theSocket}->error()) {
3435     $this->{theSocket}->shutdown(SHUT_RDWR) if($this->{theSocket});
3436     unless($this->connect()) {
3437       die "Failure: Can't reopen CLI connection";
3438     }
3439   }
3440
3441   $this->{currentCGateCommand} = $command;
3442   print STDERR ref($this) . "->send($command)\n\n"
3443     if $this->{'debug'};
3444   $this->{'lastAccess'}=time();
3445   print {$this->{theSocket}} $command."\012";
3446 }
3447
3448
3449 ###########################
3450
3451 sub skipSpaces {
3452   my $this = shift;
3453   while($this->{'span'} < $this->{'len'} && substr($this->{'data'},$this->{'span'},1) =~ /\s/) { ++$this->{'span'}; }
3454 }
3455
3456 sub readWord {
3457   my $this = shift;
3458   my $isQuoted=0;
3459   my $isBlock=0;
3460   my $result="";
3461
3462   $this->skipSpaces();
3463   if(substr($this->{'data'},$this->{'span'},1) eq '"') {
3464     $isQuoted=1; ++$this->{'span'};
3465   } elsif(substr($this->{'data'},$this->{'span'},1) eq '[') {
3466     $isBlock=1;
3467   }
3468   while($this->{'span'} < $this->{'len'}) {
3469     my $ch=substr($this->{'data'},$this->{'span'},1);
3470
3471     if($isQuoted) {
3472       if($ch eq '\\') {
3473         if(substr($this->{'data'},$this->{'span'}+1,3) =~ /^(?:\"|\\|\d\d\d)/) { 
3474           $ch=substr($this->{'data'},++$this->{'span'},3);
3475           if($ch =~ /\d\d\d/) {
3476             $this->{'span'}+=2;
3477             $ch=chr($ch);
3478           } else {
3479             $ch=substr($ch,0,1);
3480             $ch='\\'.$ch unless($this->{'translateStrings'}); 
3481           }
3482         }
3483       } elsif($ch eq '"') {
3484         ++$this->{'span'};
3485         $this->skipSpaces();
3486         if(substr($this->{'data'},$this->{'span'},1) eq '"') {
3487           ++$this->{'span'};
3488         } else {
3489           last;
3490         }  
3491       }
3492     } elsif($isBlock) {
3493       if($ch eq ']') {
3494         ++$this->{'span'};
3495         $this->skipSpaces();
3496         if(substr($this->{'data'},$this->{'span'},1) eq '[') {
3497           ++$this->{'span'};
3498         } else {
3499           $result .= ']';
3500           last;
3501         }  
3502
3503       }
3504     } elsif($ch =~ /[-a-zA-Z0-9\x80-\xff_\.\@\!\#\%\:]/) {    
3505     } else {
3506       last;
3507     }
3508     $result .= $ch;
3509     ++$this->{'span'};
3510   }
3511   return $result;
3512 }
3513
3514
3515 sub readKey() {
3516   my $this = shift;
3517   return $this->readWord();
3518 }
3519
3520
3521 sub readValue() {
3522   my $this = shift;
3523   $this->skipSpaces();
3524   my $ch=substr($this->{'data'},$this->{'span'},1);
3525   if($ch eq '{') {
3526     ++$this->{'span'};
3527     return $this->readDictionary();
3528   } elsif($ch eq '(') {
3529     ++$this->{'span'};
3530     return $this->readArray();
3531   } else {
3532     return $this->readWord();
3533   }
3534 }
3535
3536 sub readArray() {
3537   my $this = shift;
3538   my $result=[];
3539   while($this->{'span'}<$this->{'len'}) {
3540     $this->skipSpaces();
3541     if(substr($this->{'data'},$this->{'span'},1) eq ')') {
3542       ++$this->{'span'};
3543       last;
3544     } else {
3545       my $theValue=$this->readValue();
3546       $this->skipSpaces();
3547       push(@$result,$theValue);
3548       if(substr($this->{'data'},$this->{'span'},1) eq ',') {
3549         ++$this->{'span'};
3550       } elsif(substr($this->{'data'},$this->{'span'},1) eq ')') {
3551       } else { 
3552         croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10);
3553       }     
3554     }
3555   }
3556   return $result;
3557 }
3558
3559 sub readDictionary {
3560   my $this = shift;
3561   my $result={};
3562   while($this->{'span'} < $this->{'len'}) {
3563     $this->skipSpaces();
3564     if(substr($this->{'data'},$this->{'span'},1) eq '}') {
3565       ++$this->{'span'};
3566       last;
3567     } else {
3568       my $theKey=$this->readKey();
3569       $this->skipSpaces();
3570       if(substr($this->{'data'},$this->{'span'},1) ne '=') { croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10); }
3571       ++$this->{'span'};
3572       @$result{$theKey}=$this->readValue();
3573       $this->skipSpaces();
3574       if(substr($this->{'data'},$this->{'span'},1) ne ';') { croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10); }
3575       ++$this->{'span'};
3576     }
3577   }
3578   return $result;
3579 }
3580
3581 sub parseWords {
3582   my $this = shift;
3583
3584   $this->{'data'}=shift;
3585   $this->{'span'}=0;
3586   $this->{'len'}=length($this->{'data'});
3587   return $this->readValue();
3588 }
3589
3590 1;
3591  
3592 =pod
3593
3594 =head1 NAME
3595
3596 CGP::CLI
3597
3598 =head1 SYNOPSIS
3599
3600 See http://www.stalker.com/CGPerl/
3601
3602 =head1 DESCRIPTION
3603
3604 CommunigatePro Command Line Interface perl module.
3605
3606 This is Stalker's CLI.pm packaged for CPAN.
3607 The original CLI.pm file is available from Stalker's website at:
3608
3609 http://www.stalker.com/CGPerl/CLI.pm
3610
3611 The only changes are the addition of the VERSION variable for MakeMaker
3612 and this short POD at the end.
3613
3614 =head1 AUTHOR
3615
3616 Stalker, Inc. <support@stalker.com>
3617
3618 =cut