/usr/share/perl5/Asterisk/Outgoing.pm is in libasterisk-agi-perl 1.01-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | package Asterisk::Outgoing;
=head1 NAME
Asterisk::Outgoing - Create outgoing call queue file
=head1 SYNOPSIS
use Asterisk::Outgoing;
my $out = new Asterisk::Outgoing;
$out->setvariable('Channel', 'Zap/1/');
$out->setvariable('MaxRetries', 0);
$out->setvariable('RetryTime', 60);
$out->setvariable('WaitTime', 60);
$out->setvariable('Application', 'Playback');
$out->setvariable('Data', 'beep');
$out->create_outgoing;
=cut
require 5.004;
use strict;
use warnings;
use Fcntl ':flock';
use Asterisk;
use vars qw(@ISA);
@ISA = ('Asterisk');
my $VERSION = '0.02';
sub new {
my ($class, %args) = @_;
my $self = {};
$self->{OUTDIR} = '/var/spool/asterisk/outgoing';
$self->{OUTTIME} = undef;
$self->{OUTVARS} = {};
$self->{CUSTOM_VARS} = ();
$self->{ALLOWEDVARS} = [ 'channel', 'maxretries', 'retrytime', 'waittime', 'context', 'extension', 'priority', 'application', 'data', 'callerid', 'setvar'];
bless $self, ref $class || $class;
return $self;
}
sub outdir {
my ($self, $dir) = @_;
if (defined($dir)) {
$self->{OUTDIR} = $dir;
}
return $self->{OUTDIR};
}
sub outtime {
my ($self, $time) = @_;
if (defined($time)) {
$self->{OUTTIME} = $time;
} elsif (!defined($self->{OUTTIME})) {
$self->{OUTTIME} = time();
}
return $self->{OUTTIME};
}
sub checkvariable {
my ($self, $var) = @_;
my $ret = 0;
foreach my $allowed (@{$self->{ALLOWEDVARS}}) {
if ($allowed =~ /$var/i) {
$ret = 1;
}
}
return $ret;
}
sub setvariable {
my ($self, $var, $value) = @_;
if ($self->checkvariable($var)) {
if ($var =~ /setvar/i) {
push @{$self->{CUSTOM_VARS}},$value;
} else {
$self->{OUTVARS}{$var} = $value;
}
}
}
sub create_outgoing {
my ($self) = @_;
my $time = $self->outtime();
my $outdir = $self->outdir();
my $filename = $outdir . '/' . $time . '.outgoing';
open(OUTFILE, ">$filename") || return 0;
flock(OUTFILE, LOCK_EX);
utime($time, $time, $filename);
foreach my $var (keys %{$self->{OUTVARS}}) {
print OUTFILE "$var: " . $self->{OUTVARS}{$var} . "\n";
}
foreach my $var (@{$self->{CUSTOM_VARS}}) {
print OUTFILE 'SetVar: ' . $var . "\n";
}
flock(OUTFILE, LOCK_UN);
close(OUTFILE);
utime($time, $time, $filename);
return 1;
}
1;
|