1 package FS::part_export::communigate_pro;
7 @ISA = qw(FS::part_export);
12 my( $self, $svc_acct ) = (shift, shift);
13 $self->communigate_pro_queue( $svc_acct->svcnum, 'CreateAccount',
14 'accountName' => $svc_acct->email,
15 'accountType' => $self->option('accountType'),
16 'externalFlag' => $self->option('externalFlag'),
17 'AccessModes' => $self->option('AccessModes'),
18 'RealName' => $svc_acct->finger,
19 'MaxAccountSize' => $svc_acct->quota,
20 'Password' => $svc_acct->_password,
25 my( $self, $new, $old ) = (shift, shift, shift);
26 return "can't (yet) change domain with CommuniGate Pro"
27 if $old->domain ne $new->domain;
28 return "can't (yet) change username with CommuniGate Pro"
29 if $old->username ne $new->username;
30 return "can't (yet) change GECOS with CommuniGate Pro"
31 if $old->finger ne $new->finger;
32 return "can't (yet) change quota with CommuniGate Pro"
33 if $old->quota ne $new->quota;
34 return '' unless $old->username ne $new->username
35 || $old->_password ne $new->_password
36 || $old->finger ne $new->finger
37 || $old->quota ne $new->quota;
39 #my $err_or_queue = $self->communigate_pro_queue( $new->svcnum,'RenameAccount',
40 # $old->email, $new->email );
41 #return $err_or_queue unless ref($err_or_queue);
42 #my $jobnum = $err_or_queue->jobnum;
44 $self->communigate_pro_queue( $new->svcnum, 'SetAccountPassword',
45 $new->email, $new->_password )
46 if $new->_password ne $old->_password;
51 my( $self, $svc_acct ) = (shift, shift);
52 $self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
57 #sub _export_suspend {
60 #sub _export_unsuspend {
63 sub communigate_pro_queue {
64 my( $self, $svcnum, $method ) = (shift, shift, shift);
65 my $sub = $method eq 'CreateAccount'
67 : 'communigate_pro_command';
68 my $queue = new FS::queue {
70 'job' => "FS::part_export::communigate_pro::$sub",
74 $self->option('port'),
75 $self->option('login'),
76 $self->option('password'),
84 my( $machine, $port, $login, $password, $method, @args ) = @_;
87 my $accountName = delete $args{'accountName'};
88 my $accountType = delete $args{'accountType'};
89 my $externalFlag = delete $args{'externalFlag'};
90 $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
91 @args = ( accountName => $accountName, [ settings => \%args ],
92 accountType => $accountType, externalFlag => $externalFlag, );
94 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
98 sub communigate_pro_command { #subroutine, not method
99 my( $machine, $port, $login, $password, $method, @args ) = @_;
103 my $cli = new CGP::CLI( {
104 'PeerAddr' => $machine,
107 'password' => $password,
108 } ) or die "Can't login to CGPro: $CGP::ERR_STRING\n";
110 $cli->$method(@args) or die "CGPro error: ". $cli->getErrMessage;
112 $cli->Logout or die "Can't logout of CGPro: $CGP::ERR_STRING\n";