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