line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Asterisk::QCall; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.004; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
371
|
use Fcntl ':flock'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
103
|
|
6
|
1
|
|
|
1
|
|
199
|
use Asterisk; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
284
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
0
|
sub version { $VERSION; } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
0
|
588
|
my ($class, %args) = @_; |
14
|
1
|
|
|
|
|
1
|
my $self = {}; |
15
|
1
|
|
|
|
|
1
|
$self->{QUEUEDIR} = '/var/spool/asterisk/qcall'; |
16
|
1
|
|
|
|
|
2
|
$self->{QUEUETIME} = undef; |
17
|
1
|
|
33
|
|
|
5
|
bless $self, ref $class || $class; |
18
|
1
|
|
|
|
|
2
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
0
|
|
|
sub DESTROY { } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub queuedir { |
24
|
2
|
|
|
2
|
0
|
677
|
my ($self, $dir) = @_; |
25
|
|
|
|
|
|
|
|
26
|
2
|
100
|
|
|
|
6
|
if (defined($dir)) { |
27
|
1
|
|
|
|
|
1
|
$self->{QUEUEDIR} = $dir; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
8
|
return $self->{QUEUEDIR}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub queuetime { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $time) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if (defined($time)) { |
|
|
0
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub create_qcall { |
46
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
open(QFILE, ">$filename") || return 0; |
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; |