| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Slides::Client::Base; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
|
|
4
|
10
|
|
|
10
|
|
30692
|
use version; our $VERSION = qv('0.0.5'); |
|
|
10
|
|
|
|
|
6558
|
|
|
|
10
|
|
|
|
|
72
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
10
|
|
|
10
|
|
867
|
use warnings; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
263
|
|
|
7
|
10
|
|
|
10
|
|
48
|
use strict; |
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
281
|
|
|
8
|
10
|
|
|
10
|
|
56
|
use Carp; |
|
|
10
|
|
|
|
|
16
|
|
|
|
10
|
|
|
|
|
725
|
|
|
9
|
10
|
|
|
10
|
|
3826
|
use English qw( -no_match_vars ); |
|
|
10
|
|
|
|
|
8829
|
|
|
|
10
|
|
|
|
|
87
|
|
|
10
|
10
|
|
|
10
|
|
12118
|
use IO::Select; |
|
|
10
|
|
|
|
|
14549
|
|
|
|
10
|
|
|
|
|
419
|
|
|
11
|
10
|
|
|
10
|
|
6039
|
use IO::Handle; |
|
|
10
|
|
|
|
|
47201
|
|
|
|
10
|
|
|
|
|
394
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
4896
|
use Object::InsideOut; |
|
|
10
|
|
|
|
|
240669
|
|
|
|
10
|
|
|
|
|
101
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Module implementation here |
|
16
|
|
|
|
|
|
|
my @in_handle : Field # controller handle, answers |
|
17
|
|
|
|
|
|
|
: Std(Name => 'in_handle', Private => 1) |
|
18
|
|
|
|
|
|
|
: Arg(Name => 'in_handle', Mandatory => 1); |
|
19
|
|
|
|
|
|
|
my @out_handle : Field # controller handle, commands |
|
20
|
|
|
|
|
|
|
: Std(Name => 'out_handle', Private => 1) |
|
21
|
|
|
|
|
|
|
: Arg(Name => 'out_handle', Mandatory => 1); |
|
22
|
|
|
|
|
|
|
my @timeout : Field # Timeout for receiving data |
|
23
|
|
|
|
|
|
|
: Std(Name => 'timeout') : Get(Name => 'timeout') |
|
24
|
|
|
|
|
|
|
: Arg(Name => 'timeout', Default => 10); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub raw_send { |
|
27
|
32
|
|
|
32
|
0
|
9325
|
my $self = shift; |
|
28
|
32
|
|
|
|
|
2103
|
$self->get_out_handle()->print(@_); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
sub receive { |
|
31
|
32
|
|
|
32
|
0
|
1088
|
my $self = shift; |
|
32
|
|
|
|
|
|
|
|
|
33
|
32
|
|
|
|
|
1054
|
my $timeout = $self->timeout(); |
|
34
|
32
|
|
|
|
|
288
|
my $response = ''; |
|
35
|
32
|
|
|
|
|
1106
|
my $in = $self->get_in_handle(); |
|
36
|
32
|
|
|
|
|
2352
|
my $sel = IO::Select->new($in); |
|
37
|
32
|
|
|
|
|
2151
|
while ($sel->can_read($timeout)) { |
|
38
|
32
|
|
|
|
|
2136
|
$in->sysread(my $data, 1024); |
|
39
|
32
|
50
|
|
|
|
629
|
if (!length $data) { |
|
40
|
0
|
|
|
|
|
0
|
$self->shut_down(); |
|
41
|
0
|
|
|
|
|
0
|
last; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
32
|
|
|
|
|
93
|
$response .= $data; |
|
44
|
32
|
|
|
|
|
243
|
$timeout = 0.1; # lower timeout for following data |
|
45
|
|
|
|
|
|
|
} ## end while ($sel->can_read($timeout... |
|
46
|
|
|
|
|
|
|
|
|
47
|
32
|
|
|
|
|
3214802
|
return $response; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub send_command { |
|
51
|
30
|
|
|
30
|
0
|
170
|
my $self = shift; |
|
52
|
30
|
|
|
|
|
71
|
my ($command) = @_; |
|
53
|
30
|
50
|
|
|
|
196
|
$command .= "\n" unless substr($command, -1) eq "\n"; |
|
54
|
30
|
|
|
|
|
758
|
$self->raw_send($command); |
|
55
|
30
|
|
|
|
|
2832
|
return $self->receive(); |
|
56
|
|
|
|
|
|
|
} ## end sub send_command |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#-------------- COMMAND EXECUTION FRAMEWORK ------------------------- |
|
59
|
|
|
|
|
|
|
sub _targetted : Private { |
|
60
|
21
|
|
|
0
|
|
1004
|
my $self = shift; |
|
61
|
21
|
|
|
|
|
51
|
my $base_command = shift; |
|
62
|
21
|
|
|
|
|
138
|
my $target = ' target=' . join ',', @_; |
|
63
|
21
|
|
|
|
|
134
|
return $self->send_command($base_command . $target); |
|
64
|
10
|
|
|
10
|
|
4973
|
} ## end sub _targetted : |
|
|
10
|
|
|
|
|
78
|
|
|
|
10
|
|
|
|
|
57
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub next { |
|
67
|
3
|
|
|
3
|
1
|
2910
|
my $self = shift; |
|
68
|
3
|
|
|
|
|
27
|
return $self->_targetted('command=next ', @_); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub previous { |
|
72
|
3
|
|
|
3
|
0
|
912
|
my $self = shift; |
|
73
|
3
|
|
|
|
|
25
|
return $self->_targetted('command=previous ', @_); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub first { |
|
77
|
3
|
|
|
3
|
0
|
32
|
my $self = shift; |
|
78
|
3
|
|
|
|
|
24
|
return $self->_targetted('command=first ', @_); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub last { |
|
82
|
3
|
|
|
3
|
0
|
1066
|
my $self = shift; |
|
83
|
3
|
|
|
|
|
23
|
return $self->_targetted('command=last ', @_); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub show { |
|
87
|
3
|
|
|
3
|
0
|
1536
|
my $self = shift; |
|
88
|
3
|
|
|
|
|
9
|
my $slide_no = shift; |
|
89
|
3
|
|
|
|
|
35
|
return $self->_targetted("command=show slide=$slide_no ", @_); |
|
90
|
|
|
|
|
|
|
} ## end sub show |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub attach { |
|
93
|
3
|
|
|
3
|
0
|
855
|
my $self = shift; |
|
94
|
3
|
|
|
|
|
25
|
return $self->_targetted('command=attach ', @_); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub detach { |
|
98
|
3
|
|
|
3
|
0
|
1532
|
my $self = shift; |
|
99
|
3
|
|
|
|
|
42
|
return $self->_targetted('command=detach ', @_); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub book { |
|
103
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
|
104
|
1
|
|
|
|
|
4
|
my $code = shift; |
|
105
|
1
|
|
|
|
|
17
|
return $self->send_command("command=book code=$code"); |
|
106
|
|
|
|
|
|
|
} ## end sub book |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub clamp { |
|
109
|
1
|
|
|
1
|
0
|
9
|
return shift->send_command('command=clamp'); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub loose { |
|
113
|
1
|
|
|
1
|
0
|
9
|
return shift->send_command('command=loose'); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub get_current { |
|
117
|
1
|
|
|
1
|
0
|
8424
|
my $self = shift; |
|
118
|
1
|
|
|
|
|
6
|
my $res = $self->send_command('command=get_current'); |
|
119
|
1
|
50
|
|
|
|
14
|
return unless defined $res; |
|
120
|
1
|
|
|
|
|
32
|
my ($slide_no, $total) = |
|
121
|
|
|
|
|
|
|
$res =~ m{200 \s+ OK \s+ current=(\d+) ; total=(\d+) \s* \z}mxs; |
|
122
|
1
|
50
|
|
|
|
8
|
return $slide_no unless wantarray; |
|
123
|
1
|
|
|
|
|
10
|
return ($slide_no, $total); |
|
124
|
|
|
|
|
|
|
} ## end sub get_current |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub get_attendees { |
|
127
|
2
|
|
|
2
|
0
|
5943
|
my $self = shift; |
|
128
|
2
|
|
|
|
|
44
|
my $res = $self->send_command('command=get_attendees'); |
|
129
|
2
|
50
|
|
|
|
27
|
return unless defined $res; |
|
130
|
2
|
|
|
|
|
31
|
my @attendees = split /\n/, $res; |
|
131
|
2
|
|
|
|
|
10
|
shift @attendees; # status line |
|
132
|
|
|
|
|
|
|
|
|
133
|
2
|
|
|
|
|
22
|
for my $attendee (@attendees) { |
|
134
|
4
|
|
|
|
|
26
|
my %data = map { split /=/ } split /;/, $attendee; |
|
|
8
|
|
|
|
|
90
|
|
|
135
|
4
|
|
|
|
|
27
|
$attendee = \%data; |
|
136
|
|
|
|
|
|
|
} ## end for my $attendee (@att) |
|
137
|
|
|
|
|
|
|
|
|
138
|
2
|
100
|
|
|
|
23
|
return @attendees if wantarray; |
|
139
|
1
|
|
|
|
|
10
|
return \@attendees; |
|
140
|
|
|
|
|
|
|
} ## end sub get_attendees |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub quit { |
|
143
|
1
|
|
|
1
|
0
|
8
|
return shift->send_command('command=quit'); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub shut_down { |
|
147
|
1
|
|
|
1
|
0
|
398
|
my $self = shift; |
|
148
|
1
|
50
|
|
|
|
24
|
$self->get_in_handle()->close() if $self->get_in_handle(); |
|
149
|
1
|
|
|
|
|
199
|
$self->set_in_handle(undef); |
|
150
|
1
|
50
|
|
|
|
55
|
$self->get_out_handle()->close() if $self->get_out_handle(); |
|
151
|
1
|
|
|
|
|
124
|
$self->set_out_handle(undef); |
|
152
|
1
|
|
|
|
|
44
|
return; |
|
153
|
|
|
|
|
|
|
} ## end sub shut_down |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub is_alive { |
|
156
|
2
|
|
|
2
|
0
|
7
|
my $self = shift; |
|
157
|
2
|
|
|
|
|
66
|
return defined($self->get_in_handle()); |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
162
|
|
|
|
|
|
|
__END__ |