| 1 | package Asterisk::QCall; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | require 5.004; | |||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use Fcntl ':flock'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Asterisk; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | $VERSION = '0.01'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 0 | ▶ | sub version { $VERSION; } | ||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 13 | 1 | my ($class, %args) = @_; | |||||||||||||||||||
| 14 | 1 | my $self = {}; | |||||||||||||||||||
| 15 | 1 | $self->{QUEUEDIR} = '/var/spool/asterisk/qcall'; | |||||||||||||||||||
| 16 | 1 | $self->{QUEUETIME} = undef; | |||||||||||||||||||
| 17 | 1 | ▶ | bless $self, ref $class || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 18 | 1 | return $self; | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub DESTROY { } | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 2 | ▶ | sub queuedir { | ||||||||||||||||||
|
Subroutine
queuedir: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 24 | 2 | my ($self, $dir) = @_; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 2 | ▶ | if (defined($dir)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 1 | $self->{QUEUEDIR} = $dir; | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 2 | return $self->{QUEUEDIR}; | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | ▶ | sub queuetime { | ||||||||||||||||||
|
Subroutine
queuetime: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 34 | 0 | my ($self, $time) = @_; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | if (defined($time)) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 37 | 0 | $self->{QUEUETIME} = $time; | |||||||||||||||||||
| 38 | } elsif (!defined($self->{QUEUETIME})) { | ||||||||||||||||||||
| 39 | 0 | $self->{QUEUETIME} = time(); | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | return $self->{QUEUETIME}; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | ▶ | sub create_qcall { | ||||||||||||||||||
|
Subroutine
create_qcall: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 46 | 0 | my ($self, $dialstring, $callerid, $extension, $maxsecs, $identifier, $response) = @_; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | my $time = $self->queuetime(); | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | my $queuedir = $self->queuedir(); | |||||||||||||||||||
| 51 | 0 | my $filename = $queuedir . '/' . $time . '.queue'; | |||||||||||||||||||
| 52 | 0 | ▶ | open(QFILE, ">$filename") || return 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 0 | flock(QFILE, LOCK_EX); | |||||||||||||||||||
| 54 | 0 | print QFILE "$dialstring $callerid $extension $maxsecs $identifier $response"; | |||||||||||||||||||
| 55 | 0 | flock(QFILE, LOCK_UN); | |||||||||||||||||||
| 56 | 0 | close(QFILE); | |||||||||||||||||||
| 57 | 0 | my $ret = utime($time, $time, $filename); | |||||||||||||||||||
| 58 | 0 | return 1; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 1 | 1; | |||||||||||||||||||