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