1 package FS::part_export::communigate_pro;
4 use vars qw(@ISA %info %options %quotas $DEBUG);
10 @ISA = qw(FS::part_export);
14 tie %options, 'Tie::IxHash',
15 'port' => { label =>'Port number', default=>'106', },
16 'login' => { label =>'The administrator account name. The name can contain a domain part.', },
17 'password' => { label =>'The administrator account password.', },
18 'accountType' => { label => 'Type for newly-created accounts (default when not specified in service)',
20 options => [qw(MultiMailbox TextMailbox MailDirMailbox AGrade BGrade CGrade)],
21 default => 'MultiMailbox',
23 'externalFlag' => { label => 'Create accounts with an external (visible for legacy mailers) INBOX.',
26 'AccessModes' => { label => 'Access modes (default when not specified in service)',
27 default => 'Mail POP IMAP PWD WebMail WebSite',
29 'create_domain' => { label => 'Domain creation API call',
31 options => [qw( CreateDomain CreateSharedDomain )],
36 'svc' => [qw( svc_acct svc_domain svc_forward svc_mailinglist )],
37 'desc' => 'Real-time export of accounts, domains, mail forwards and mailing lists to a CommuniGate Pro mail server',
38 'options' => \%options,
40 Real time export of accounts, domains, mail forwards and mailing lists to a
41 <a href="http://www.stalker.com/CommuniGatePro/">CommuniGate Pro</a>
43 <a href="http://www.stalker.com/CGPerl/">CommuniGate Pro Perl Interface</a>
44 must be installed as CGP::CLI.
49 'quota' => 'MaxAccountSize',
50 'file_quota' => 'MaxWebSize',
51 'file_maxnum' => 'MaxWebFiles',
52 'file_maxsize' => 'MaxFileSize',
55 sub rebless { shift; }
58 my($self, $svc_acct) = (shift, shift);
63 my( $self, $svc_x ) = (shift, shift);
65 my $table = $svc_x->table;
66 my $method = "_export_insert_$table";
67 $self->$method($svc_x, @_);
70 sub _export_insert_svc_acct {
71 my( $self, $svc_acct ) = (shift, shift);
74 'AccessModes' => [ split(' ', ( $svc_acct->cgp_accessmodes
75 || $self->option('AccessModes') )
78 'RealName' => $svc_acct->finger,
79 'Password' => $svc_acct->_password,
80 map { $quotas{$_} => $svc_acct->$_() }
81 grep $svc_acct->$_(), keys %quotas
83 #phase 2: pwdallowed, passwordrecovery, allowed mail rules,
84 # RPOP modifications, accepts mail to all, add trailer to sent mail
85 #phase 3: archive messages, mailing lists
87 my @options = ( 'CreateAccount',
88 'accountName' => $self->export_username($svc_acct),
89 'accountType' => ( $svc_acct->cgp_type
90 || $self->option('accountType') ),
91 'settings' => \%settings
94 push @options, 'externalFlag' => $self->option('externalFlag')
95 if $self->option('externalFlag');
97 #let's do the create realtime too, for much the same reasons, and to avoid
98 #pain of trying to queue w/dep the prefs & aliases
99 eval { $self->communigate_pro_runcommand( @options ) };
104 $prefs{'DeleteMode'} = $svc_acct->cgp_deletemode if $svc_acct->cgp_deletemode;
105 $prefs{'EmptyTrash'} = $svc_acct->cgp_emptytrash if $svc_acct->cgp_emptytrash;
106 #phase 2: language, time zone, layout, pronto style, send read receipts
108 my $pref_err = $self->communigate_pro_queue( $svc_acct->svcnum,
109 'UpdateAccountPrefs',
110 $self->export_username($svc_acct),
113 warn "WARNING: error queueing UpdateAccountPrefs job: $pref_err"
118 if ( $svc_acct->cgp_aliases ) {
119 my $alias_err = $self->communigate_pro_queue( $svc_acct->svcnum,
121 $self->export_username($svc_acct),
122 [ split(/\s*[,\s]\s*/, $svc_acct->cgp_aliases) ],
124 warn "WARNING: error queueing SetAccountAliases job: $alias_err"
132 sub _export_insert_svc_domain {
133 my( $self, $svc_domain ) = (shift, shift);
135 my $create = $self->option('create_domain') || 'CreateDomain';
138 'DomainAccessModes' => [ split(' ', $svc_domain->cgp_accessmodes ) ],
140 $settings{'AccountsLimit'} = $svc_domain->max_accounts
141 if $svc_domain->max_accounts;
142 $settings{'AdminDomainName'} = $svc_domain->parent_svc_x->domain
143 if $svc_domain->parent_svcnum;
144 $settings{'TrailerText'} = $svc_domain->trailer
145 if $svc_domain->trailer;
147 my @options = ( $create, $svc_domain->domain, \%settings );
149 eval { $self->communigate_pro_runcommand( @options ) };
153 if ( $svc_domain->cgp_aliases ) {
154 my $alias_err = $self->communigate_pro_queue( $svc_domain->svcnum,
157 split(/\s*[,\s]\s*/, $svc_domain->cgp_aliases),
159 warn "WARNING: error queueing SetDomainAliases job: $alias_err"
164 my $def_err = $self->communigate_pro_queue( $svc_domain->svcnum,
165 'SetAccountDefaults',
167 'PWDAllowed' =>($svc_domain->acct_def_password_selfchange ? 'YES':'NO'),
168 'PasswordRecovery' => ($svc_domain->acct_def_password_recover ? 'YES':'NO'),
169 'AccessModes' => $svc_domain->acct_def_cgp_accessmodes,
170 'MaxAccountSize' => $svc_domain->acct_def_quota,
171 'MaxWebSize' => $svc_domain->acct_def_file_quota,
172 'MaxWebFile' => $svc_domain->acct_def_file_maxnum,
173 'MaxFileSize' => $svc_domain->acct_def_file_maxsize,
174 'RulesAllowed' => $svc_domain->acct_def_cgp_rulesallowed,
175 'RPOPAllowed' =>($svc_domain->acct_def_cgp_rpopallowed ?'YES':'NO'),
176 'MailToAll' =>($svc_domain->acct_def_cgp_mailtoall ?'YES':'NO'),
177 'AddMailTrailer' =>($svc_domain->acct_def_cgp_addmailtrailer ?'YES':'NO'),
179 warn "WARNING: error queueing SetAccountDefaults job: $def_err"
182 #account defaults prefs
183 my $pref_err = $self->communigate_pro_queue( $svc_domain->svcnum,
184 'SetAccountDefaultPrefs',
186 'DeleteMode' => $svc_domain->acct_def_cgp_deletemode,
187 'EmptyTrash' => $svc_domain->acct_def_cgp_emptytrash,
189 warn "WARNING: error queueing SetAccountDefaultPrefs job: $pref_err"
196 sub _export_insert_svc_forward {
197 my( $self, $svc_forward ) = (shift, shift);
199 my $src = $svc_forward->src || $svc_forward->srcsvc_acct->email;
200 my $dst = $svc_forward->dst || $svc_forward->dstsvc_acct->email;
202 #real-time here, presuming CGP does some dup detection?
203 eval { $self->communigate_pro_runcommand( 'CreateForwarder', $src, $dst); };
209 sub _export_insert_svc_mailinglist {
210 my( $self, $svc_mlist ) = (shift, shift);
212 my @members = map $_->email_address,
213 $svc_mlist->mailinglist->mailinglistmember;
215 #real-time here, presuming CGP does some dup detection
216 eval { $self->communigate_pro_runcommand(
218 $svc_mlist->username.'@'.$svc_mlist->domain,
219 { 'RealName' => $svc_mlist->listname,
220 'SetReplyTo' => ( $svc_mlist->reply_to ? 'YES' : 'NO' ),
221 'RemoveAuthor' => ( $svc_mlist->remove_from ? 'YES' : 'NO' ),
222 'RejectAuto' => ( $svc_mlist->reject_auto ? 'YES' : 'NO' ),
223 'RemoveToAndCc' => ( $svc_mlist->remove_to_and_cc ? 'YES' : 'NO' ),
224 'Members' => \@members,
234 sub _export_replace {
235 my( $self, $new, $old ) = (shift, shift, shift);
237 my $table = $new->table;
238 my $method = "_export_replace_$table";
239 $self->$method($new, $old, @_);
242 sub _export_replace_svc_acct {
243 my( $self, $new, $old ) = (shift, shift, shift);
245 #let's just do the rename part realtime rather than trying to queue
246 #w/dependencies. we don't want FS winding up out-of-sync with the wrong
247 #username and a queued job anyway. right??
248 if ( $self->export_username($old) ne $self->export_username($new) ) {
249 eval { $self->communigate_pro_runcommand(
251 $self->export_username($old),
252 $self->export_username($new),
257 if ( $new->_password ne $old->_password
258 && '*SUSPENDED* '.$old->_password ne $new->_password
260 $self->communigate_pro_queue( $new->svcnum, 'SetAccountPassword',
261 $self->export_username($new), $new->_password
267 $settings{'RealName'} = $new->finger
268 if $old->finger ne $new->finger;
269 $settings{$quotas{$_}} = $new->$_()
270 foreach grep $old->$_() ne $new->$_(), keys %quotas;
271 $settings{'accountType'} = $new->cgp_type
272 if $old->cgp_type ne $new->cgp_type;
273 $settings{'AccessModes'} = $new->cgp_accessmodes
274 if $old->cgp_accessmodes ne $new->cgp_accessmodes
275 || $old->cgp_type ne $new->cgp_type;
277 #phase 2: pwdallowed, passwordrecovery, allowed mail rules,
278 # RPOP modifications, accepts mail to all, add trailer to sent mail
279 #phase 3: archive messages, mailing lists
281 if ( keys %settings ) {
282 my $error = $self->communigate_pro_queue(
284 'UpdateAccountSettings',
285 $self->export_username($new),
288 return $error if $error;
293 $prefs{'DeleteMode'} = $new->cgp_deletemode
294 if $old->cgp_deletemode ne $new->cgp_deletemode;
295 $prefs{'EmptyTrash'} = $new->cgp_emptytrash
296 if $old->cgp_emptytrash ne $new->cgp_emptytrash;
297 #phase 2: language, time zone, layout, pronto style, send read receipts
299 my $pref_err = $self->communigate_pro_queue( $new->svcnum,
300 'UpdateAccountPrefs',
301 $self->export_username($new),
304 warn "WARNING: error queueing UpdateAccountPrefs job: $pref_err"
308 if ( $old->cgp_aliases ne $new->cgp_aliases ) {
309 my $error = $self->communigate_pro_queue(
312 $self->export_username($new),
313 [ split(/\s*[,\s]\s*/, $new->cgp_aliases) ],
315 return $error if $error;
322 sub _export_replace_svc_domain {
323 my( $self, $new, $old ) = (shift, shift, shift);
325 if ( $old->domain ne $new->domain ) {
326 my $error = $self->communigate_pro_queue( $new->svcnum, 'RenameDomain',
327 $old->domain, $new->domain,
329 return $error if $error;
332 $settings{'AccountsLimit'} = $new->max_accounts
333 if $old->max_accounts ne $new->max_accounts;
334 $settings{'TrailerText'} = $new->trailer
335 if $old->trailer ne $new->trailer;
336 $settings{'DomainAccessModes'} = $new->cgp_accessmodes
337 if $old->cgp_accessmodes ne $new->cgp_accessmodes;
338 $settings{'AdminDomainName'} =
339 $new->parent_svcnum ? $new->parent_svc_x->domain : ''
340 if $old->parent_svcnum != $new->parent_svcnum;
342 if ( keys %settings ) {
343 my $error = $self->communigate_pro_queue( $new->svcnum,
344 'UpdateDomainSettings',
348 return $error if $error;
351 if ( $old->cgp_aliases ne $new->cgp_aliases ) {
352 my $error = $self->communigate_pro_queue( $new->svcnum,
355 split(/\s*[,\s]\s*/, $new->cgp_aliases),
357 return $error if $error;
360 #below this identical to insert... any value to doing an Update here?
361 #not seeing any big one... i guess it would be nice to avoid the update
362 #when things haven't changed
365 my $def_err = $self->communigate_pro_queue( $new->svcnum,
366 'SetAccountDefaults',
368 'PWDAllowed' => ( $new->acct_def_password_selfchange ? 'YES' : 'NO' ),
369 'PasswordRecovery' => ( $new->acct_def_password_recover ? 'YES' : 'NO' ),
370 'AccessModes' => $new->acct_def_cgp_accessmodes,
371 'MaxAccountSize' => $new->acct_def_quota,
372 'MaxWebSize' => $new->acct_def_file_quota,
373 'MaxWebFile' => $new->acct_def_file_maxnum,
374 'MaxFileSize' => $new->acct_def_file_maxsize,
375 'RulesAllowed' => $new->acct_def_cgp_rulesallowed,
376 'RPOPAllowed' => ( $new->acct_def_cgp_rpopallowed ? 'YES' : 'NO' ),
377 'MailToAll' => ( $new->acct_def_cgp_mailtoall ? 'YES' : 'NO' ),
378 'AddMailTrailer' => ( $new->acct_def_cgp_addmailtrailer ? 'YES' : 'NO' ),
380 warn "WARNING: error queueing SetAccountDefaults job: $def_err"
383 #account defaults prefs
384 my $pref_err = $self->communigate_pro_queue( $new->svcnum,
385 'SetAccountDefaultPrefs',
387 'DeleteMode' => $new->acct_def_cgp_deletemode,
388 'EmptyTrash' => $new->acct_def_cgp_emptytrash,
390 warn "WARNING: error queueing SetAccountDefaultPrefs job: $pref_err"
396 sub _export_replace_svc_forward {
397 my( $self, $new, $old ) = (shift, shift, shift);
399 my $osrc = $old->src || $old->srcsvc_acct->email;
400 my $nsrc = $new->src || $new->srcsvc_acct->email;
401 my $odst = $old->dst || $old->dstsvc_acct->email;
402 my $ndst = $new->dst || $new->dstsvc_acct->email;
404 if ( $odst ne $ndst ) {
406 #no change command, so delete and create (real-time)
407 eval { $self->communigate_pro_runcommand('DeleteForwarder', $osrc) };
409 eval { $self->communigate_pro_runcommand('CreateForwarder', $nsrc, $ndst)};
412 } elsif ( $osrc ne $nsrc ) {
414 #real-time here, presuming CGP does some dup detection?
415 eval { $self->communigate_pro_runcommand( 'RenameForwarder', $osrc, $nsrc)};
419 warn "communigate replace called for svc_forward with no changes\n";#confess
425 sub _export_replace_svc_mailinglist {
426 my( $self, $new, $old ) = (shift, shift, shift);
428 my $oldGroupName = $old->username.'@'.$old->domain;
429 my $newGroupName = $new->username.'@'.$new->domain;
431 if ( $oldGroupName ne $newGroupName ) {
432 eval { $self->communigate_pro_runcommand(
433 'RenameGroup', $oldGroupName, $newGroupName ); };
437 my @members = map $_->email_address,
438 $new->mailinglist->mailinglistmember;
440 #real-time here, presuming CGP does some dup detection
441 eval { $self->communigate_pro_runcommand(
442 'SetGroup', $newGroupName,
443 { 'RealName' => $new->listname,
444 'SetReplyTo' => ( $new->reply_to ? 'YES' : 'NO' ),
445 'RemoveAuthor' => ( $new->remove_from ? 'YES' : 'NO' ),
446 'RejectAuto' => ( $new->reject_auto ? 'YES' : 'NO' ),
447 'RemoveToAndCc' => ( $new->remove_to_and_cc ? 'YES' : 'NO' ),
448 'Members' => \@members,
459 my( $self, $svc_x ) = (shift, shift);
461 my $table = $svc_x->table;
462 my $method = "_export_delete_$table";
463 $self->$method($svc_x, @_);
466 sub _export_delete_svc_acct {
467 my( $self, $svc_acct ) = (shift, shift);
469 $self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
470 $self->export_username($svc_acct),
474 sub _export_delete_svc_domain {
475 my( $self, $svc_domain ) = (shift, shift);
477 $self->communigate_pro_queue( $svc_domain->svcnum, 'DeleteDomain',
479 #XXX turn on force option for domain deletion?
483 sub _export_delete_svc_forward {
484 my( $self, $svc_forward ) = (shift, shift);
486 $self->communigate_pro_queue( $svc_forward->svcnum, 'DeleteForwarder',
487 ($svc_forward->src || $svc_forward->srcsvc_acct->email),
491 sub _export_delete_svc_mailinglist {
492 my( $self, $svc_mailinglist ) = (shift, shift);
494 #real-time here, presuming CGP does some dup detection
495 eval { $self->communigate_pro_runcommand(
497 $svc_mailinglist->username.'@'.$svc_mailinglist->domain,
506 sub _export_suspend {
507 my( $self, $svc_x ) = (shift, shift);
509 my $table = $svc_x->table;
510 my $method = "_export_suspend_$table";
511 $self->$method($svc_x, @_);
515 sub _export_suspend_svc_acct {
516 my( $self, $svc_acct ) = (shift, shift);
518 #XXX is this the desired suspnsion action?
520 $self->communigate_pro_queue(
522 'UpdateAccountSettings',
523 $self->export_username($svc_acct),
524 'AccessModes' => 'Mail',
529 sub _export_suspend_svc_domain {
530 my( $self, $svc_domain) = (shift, shift);
532 #XXX domain operations
537 sub _export_unsuspend {
538 my( $self, $svc_x ) = (shift, shift);
540 my $table = $svc_x->table;
541 my $method = "_export_unsuspend_$table";
542 $self->$method($svc_x, @_);
546 sub _export_unsuspend_svc_acct {
547 my( $self, $svc_acct ) = (shift, shift);
549 $self->communigate_pro_queue(
551 'UpdateAccountSettings',
552 $self->export_username($svc_acct),
553 'AccessModes' => ( $svc_acct->cgp_accessmodes
554 || $self->option('AccessModes') ),
559 sub _export_unsuspend_svc_domain {
560 my( $self, $svc_domain) = (shift, shift);
562 #XXX domain operations
567 sub export_mailinglistmember_insert {
568 my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
569 $svc_mailinglist->replace();
572 sub export_mailinglistmember_replace {
573 my( $self, $svc_mailinglist, $new, $old ) = (shift, shift, shift, shift);
574 die "no way to do this from the UI right now";
577 sub export_mailinglistmember_delete {
578 my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
579 $svc_mailinglist->replace();
582 sub export_getsettings {
583 my($self, $svc_x) = (shift, shift);
585 my $table = $svc_x->table;
586 my $method = "export_getsettings_$table";
588 $self->can($method) ? $self->$method($svc_x, @_) : '';
592 sub export_getsettings_svc_domain {
593 my($self, $svc_domain, $settingsref, $defaultref ) = @_;
595 my $settings = eval { $self->communigate_pro_runcommand(
601 my $effective_settings = eval { $self->communigate_pro_runcommand(
602 'GetDomainEffectiveSettings',
607 my $acct_defaults = eval { $self->communigate_pro_runcommand(
608 'GetAccountDefaults',
613 my $acct_defaultprefs = eval { $self->communigate_pro_runcommand(
614 'GetAccountDefaultPrefs',
619 %$effective_settings = (
620 %$effective_settings,
621 ( map { ("Acct. Default $_" => $acct_defaults->{$_}); }
622 keys(%$acct_defaults)
624 ( map { ("Acct. Default $_" => $acct_defaultprefs->{$_}); } #diff label??
625 keys(%$acct_defaultprefs)
630 ( map { ("Acct. Default $_" => $acct_defaults->{$_}); }
631 keys(%$acct_defaults)
633 ( map { ("Acct. Default $_" => $acct_defaultprefs->{$_}); } #diff label??
634 keys(%$acct_defaultprefs)
639 my $aliases = eval { $self->communigate_pro_runcommand(
645 $effective_settings->{'Aliases'} = join(', ', @$aliases);
646 $settings->{'Aliases'} = join(', ', @$aliases);
649 #false laziness w/below
651 my %defaults = map { $_ => 1 }
652 grep !exists(${$settings}{$_}), keys %$effective_settings;
654 foreach my $key ( grep ref($effective_settings->{$_}),
655 keys %$effective_settings )
657 my $value = $effective_settings->{$key};
658 if ( ref($value) eq 'ARRAY' ) {
659 $effective_settings->{$key} = join(' ', @$value);
662 warn "serializing ". ref($value). " for table display not yet handled";
666 %{$settingsref} = %$effective_settings;
667 %{$defaultref} = %defaults;
672 sub export_getsettings_svc_acct {
673 my($self, $svc_acct, $settingsref, $defaultref ) = @_;
675 my $settings = eval { $self->communigate_pro_runcommand(
676 'GetAccountSettings',
681 delete($settings->{'Password'});
683 my $effective_settings = eval { $self->communigate_pro_runcommand(
684 'GetAccountEffectiveSettings',
689 delete($effective_settings->{'Password'});
691 #prefs/effectiveprefs too
693 my $prefs = eval { $self->communigate_pro_runcommand(
699 my $effective_prefs = eval { $self->communigate_pro_runcommand(
700 'GetAccountEffectivePrefs',
705 %$effective_settings = ( %$effective_settings,
706 map { ("Pref $_" => $effective_prefs->{$_}); }
707 keys(%$effective_prefs)
709 %$settings = ( %$settings,
710 map { ("Pref $_" => $prefs->{$_}); }
716 my $aliases = eval { $self->communigate_pro_runcommand(
722 $effective_settings->{'Aliases'} = join(', ', @$aliases);
723 $settings->{'Aliases'} = join(', ', @$aliases);
725 #false laziness w/above
727 my %defaults = map { $_ => 1 }
728 grep !exists(${$settings}{$_}), keys %$effective_settings;
730 foreach my $key ( grep ref($effective_settings->{$_}),
731 keys %$effective_settings )
733 my $value = $effective_settings->{$key};
734 if ( ref($value) eq 'ARRAY' ) {
735 $effective_settings->{$key} = join(' ', @$value);
738 warn "serializing ". ref($value). " for table display not yet handled";
742 %{$settingsref} = %$effective_settings;
743 %{$defaultref} = %defaults;
749 sub export_getsettings_svc_mailinglist {
750 my($self, $svc_mailinglist, $settingsref, $defaultref ) = @_;
752 my $settings = eval { $self->communigate_pro_runcommand(
754 $svc_mailinglist->username.'@'.$svc_mailinglist->domain,
758 $settings->{'Members'} = join(', ', @{ $settings->{'Members'} } );
760 %{$settingsref} = %$settings;
765 sub communigate_pro_queue {
766 my( $self, $svcnum, $method ) = (shift, shift, shift);
767 my $jobnum = ''; #don't actually care
768 $self->communigate_pro_queue_dep( \$jobnum, $svcnum, $method, @_);
771 sub communigate_pro_queue_dep {
772 my( $self, $jobnumref, $svcnum, $method ) = splice(@_,0,4);
774 my %kludge_methods = (
775 #'CreateAccount' => 'CreateAccount',
776 'UpdateAccountSettings' => 'UpdateAccountSettings',
777 'UpdateAccountPrefs' => 'cp_Scalar_Hash',
778 #'CreateDomain' => 'cp_Scalar_Hash',
779 #'CreateSharedDomain' => 'cp_Scalar_Hash',
780 'UpdateDomainSettings' => 'cp_Scalar_settingsHash',
781 'SetDomainAliases' => 'cp_Scalar_Array',
782 'SetAccountDefaults' => 'cp_Scalar_settingsHash',
783 'UpdateAccountDefaults' => 'cp_Scalar_settingsHash',
784 'SetAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
785 'UpdateAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
787 my $sub = exists($kludge_methods{$method})
788 ? $kludge_methods{$method}
789 : 'communigate_pro_command';
791 my $queue = new FS::queue {
793 'job' => "FS::part_export::communigate_pro::$sub",
795 my $error = $queue->insert(
797 $self->option('port'),
798 $self->option('login'),
799 $self->option('password'),
803 $$jobnumref = $queue->jobnum unless $error;
808 sub communigate_pro_runcommand {
809 my( $self, $method ) = (shift, shift);
811 communigate_pro_command(
813 $self->option('port'),
814 $self->option('login'),
815 $self->option('password'),
822 #XXX one sub per arg prototype is lame. more magic? i suppose queue needs
823 # to store data strctures properly instead of just an arg list. right.
826 my( $machine, $port, $login, $password, $method, $scalar, %hash ) = @_;
827 my @args = ( $scalar, \%hash );
828 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
831 sub cp_Scalar_Array {
832 my( $machine, $port, $login, $password, $method, $scalar, @array ) = @_;
833 my @args = ( $scalar, \@array );
834 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
838 # my( $machine, $port, $login, $password, $method, %hash ) = @_;
839 # my @args = ( \%hash );
840 # communigate_pro_command( $machine, $port, $login, $password, $method, @args );
843 sub cp_Scalar_settingsHash {
844 my( $machine, $port, $login, $password, $method, $domain, %settings ) = @_;
845 for (qw( AccessModes DomainAccessModes )) {
846 $settings{$_} = [split(' ',$settings{$_})] if $settings{$_};
848 my @args = ( 'domain' => $domain, 'settings' => \%settings );
849 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
853 # my( $machine, $port, $login, $password, $method, %args ) = @_;
854 # my $accountName = delete $args{'accountName'};
855 # my $accountType = delete $args{'accountType'};
856 # my $externalFlag = delete $args{'externalFlag'};
857 # $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
858 # my @args = ( accountName => $accountName,
859 # accountType => $accountType,
860 # settings => \%args,
862 # #externalFlag => $externalFlag,
863 # push @args, externalFlag => $externalFlag if $externalFlag;
865 # communigate_pro_command( $machine, $port, $login, $password, $method, @args );
869 sub UpdateAccountSettings {
870 my( $machine, $port, $login, $password, $method, $accountName, %args ) = @_;
871 $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
872 my @args = ( $accountName, \%args );
873 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
876 sub communigate_pro_command { #subroutine, not method
877 my( $machine, $port, $login, $password, $method, @args ) = @_;
882 my $cli = new CGP::CLI( {
883 'PeerAddr' => $machine,
886 'password' => $password,
887 } ) or die "Can't login to CGPro: $CGP::ERR_STRING\n";
889 #warn "$method ". Dumper(@args) if $DEBUG;
891 my $return = $cli->$method(@args)
892 or die "Communigate Pro error: ". $cli->getErrMessage. "\n";
894 $cli->Logout; # or die "Can't logout of CGPro: $CGP::ERR_STRING\n";