use XMLDispatcher for Domains and SoundFiles

agranig/1_0_subfix
Gerhard Jungwirth 12 years ago
parent 36d3317da8
commit 01cea1a76d

@ -40,6 +40,7 @@ sub create :Chained('dom_list') :PathPart('create') :Args(0) {
},
1
);
$self->_sip_domain_reload;
$c->flash(messages => [{type => 'success', text => 'Domain successfully created!'}]);
$c->response->redirect($c->uri_for());
return;
@ -84,6 +85,7 @@ sub edit :Chained('base') :PathPart('edit') :Args(0) {
$c->stash->{'domain_result'}->update({
domain => $form->field('domain')->value,
});
$self->_sip_domain_reload;
$c->flash(messages => [{type => 'success', text => 'Domain successfully changed!'}]);
$c->response->redirect($c->uri_for());
@ -103,6 +105,7 @@ sub delete :Chained('base') :PathPart('delete') :Args(0) {
}
$c->stash->{'domain_result'}->delete;
$self->_sip_domain_reload;
# my $schema = $c->model('billing')->schema;
# $schema->provisioning($c->model('provisioning')->schema->connect);
@ -223,6 +226,20 @@ sub load_preference_list :Private {
);
}
sub _sip_domain_reload {
my ($self) = @_;
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$dispatcher->dispatch("proxy-ng", 1, 1, <<EOF );
<?xml version="1.0" ?>
<methodCall>
<methodName>domain.reload</methodName>
<params/>
</methodCall>
EOF
return 1;
}
__PACKAGE__->meta->make_immutable;
1;
@ -295,6 +312,12 @@ Retrieves and processes a datastructure containing preference groups, preference
Data that is put on stash: pref_groups
=head2 _sip_domain_reload
Ported from ossbss
reloads domain cache of sip proxies
=head1 AUTHOR
Andreas Granig,,,

@ -8,6 +8,7 @@ use NGCP::Panel::Form::SoundSet;
use NGCP::Panel::Form::SoundFile;
use File::Type;
use IPC::System::Simple qw/capturex/;
use NGCP::Panel::Utils::XMLDispatcher;
sub auto :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) {
my ($self, $c) = @_;
@ -215,7 +216,13 @@ sub handles_edit :Chained('handles_base') :PathPart('edit') {
my $target_codec = 'WAV';
if($file_result->handle->group->name eq 'calling_card') {
#$self->_clear_audio_cache($data->{set_id}, $handle->{name});
try {
$self->_clear_audio_cache($file_result->set_id, $file_result->handle->name);
} catch ($e) {
$c->flash(messages => [{type => 'error', text => 'Failed to clear audio cache!'}]);
$c->response->redirect($c->stash->{handles_base_uri});
return;
}
}
if ($file_result->handle->name eq 'music_on_hold') {
@ -304,6 +311,46 @@ sub _transcode_sound_file {
return $out;
}
sub _clear_audio_cache {
my ($self, $sound_set_id, $handle_name) = @_;
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
my @ret = $dispatcher->dispatch("appserver", 1, 1, <<EOF );
<?xml version="1.0"?>
<methodCall>
<methodName>postDSMEvent</methodName>
<params>
<param>
<value><string>sw_audio</string></value>
</param>
<param>
<value><array><data>
<value><array><data>
<value><string>cmd</string></value>
<value><string>clearFile</string></value>
</data></array></value>
<value><array><data>
<value><string>audio_id</string></value>
<value><string>$handle_name</string></value>
</data></array></value>
<value><array><data>
<value><string>sound_set_id</string></value>
<value><string>$sound_set_id</string></value>
</data></array></value>
</data></array></value>
</param>
</params>
</methodCall>
EOF
if(grep { $$_[1] != 1 or $$_[2] !~ m#<value>OK</value># } @ret) { # error
die "failed to clear SEMS audio cache";
}
return 1;
}
__PACKAGE__->meta->make_immutable;
1;
@ -398,6 +445,12 @@ For $target_codec 'WAV' returns is WAV 16bit, 8kHz.
Will die if transcoding doesn't work.
=head2 _clear_audio_cache
Ported from ossbss.
tells our application server to clear a specific audio file
=head1 AUTHOR
Gerhard Jungwirth C<< <gjungwirth@sipwise.com> >>

Loading…
Cancel
Save