'domsvc', 'int', 'NULL', '', '', '',
'locationnum', 'int', 'NULL', '', '', '',
'route', 'varchar', 'NULL', $char_d, '', '',
+ 'gwlist', 'varchar', 'NULL', $char_d, '', '',
'forwarddst', 'varchar', 'NULL', 15, '', '',
'email', 'varchar', 'NULL', 255, '', '',
'lnp_status', 'varchar', 'NULL', $char_d, '', '',
use FS::part_export;
use FS::svc_phone;
use FS::export_svc;
+use LWP::UserAgent;
@ISA = qw(FS::part_export);
'datasrc' => { label=>'DBI data source ' },
'username' => { label=>'Database username' },
'password' => { label=>'Database password' },
+ 'xmlrpc_url' => { label=>'XMLRPC URL' },
;
%info = (
my $sth = $dbh->prepare("insert into dr_rules ".
"( groupid, prefix, timerec, routeid, gwlist, description ) ".
" values ( ?, ?, ?, ?, ?, ? )") or die $dbh->errstr;
- $sth->execute('0',$svc_x->phonenum,'',$svc_x->route,'',
+ $sth->execute('0',$svc_x->phonenum,'',$svc_x->route,$svc_x->gwlist,
$svc_x->phone_name) or die $sth->errstr;
$dbh->disconnect;
- '';
+ $self->dr_reload;
}
sub opensips_connect {
push @paramvalues, $new->phone_name;
}
+ if($old->gwlist ne $new->gwlist) {
+ push @update, 'gwlist = ?';
+ push @paramvalues, $new->gwlist;
+ }
+
if(scalar(@update)) {
my $update_str = join(' and ',@update);
my $dbh = $self->opensips_connect;
push @paramvalues, $old->phonenum;
$sth->execute(@paramvalues) or die $sth->errstr;
$dbh->disconnect;
+ return $self->dr_reload;
}
'';
}
or die $dbh->errstr;
$sth->execute($svc_x->phonenum) or die $sth->errstr;
$dbh->disconnect;
- '';
+ $self->dr_reload;
+}
+
+sub dr_reload {
+ my $self = shift;
+ my $reqxml = "<?xml version=\"1.0\"?>
+<methodCall>
+ <methodName>dr_reload</methodName>
+</methodCall>";
+ my $ua = LWP::UserAgent->new;
+ my $resp = $ua->post( $self->option('xmlrpc_url'),
+ Content_Type => 'text/xml',
+ Content => $reqxml );
+ return "invalid HTTP response from OpenSIPS: " . $resp->status_line
+ unless $resp->is_success;
+ '';
}
Route id/number
+=item gwlist
+
+OpenSIPS dr_rules gwlist - OpenSIPS dynamic routing
+
=item forwarddst
Forwarding destination
'route' => { label => 'Route',
%dis2,
},
+ 'gwlist' => { label => 'OpenSIPS gwlist', %dis2 },
'forwarddst' => { label => 'Forward Destination',
%dis2,
},
|| $self->ut_foreign_keyn('domsvc', 'svc_domain', 'svcnum' )
|| $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum')
|| $self->ut_textn('route')
+ || $self->ut_textn('gwlist')
|| $self->ut_numbern('forwarddst')
|| $self->ut_textn('email')
|| $self->ut_numbern('lrn')
maxlength => $conf->config('svc_phone-phone_name-max_length'),
},
'route',
+ 'gwlist',
'forwarddst',
'email',
my @fields = qw( countrycode phonenum );
push @fields, 'domain' if $conf->exists('svc_phone-domain');
-push @fields, qw( pbx_title sip_password pin phone_name route forwarddst email );
+push @fields, qw( pbx_title sip_password pin phone_name route gwlist forwarddst email );
if ( $conf->exists('svc_phone-lnp') ) {
push @fields, 'lnp_status',