line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Slides::Attendee; |
2
|
|
|
|
|
|
|
{ |
3
|
7
|
|
|
7
|
|
28552
|
use version; our $VERSION = qv('0.0.4'); |
|
7
|
|
|
|
|
5932
|
|
|
7
|
|
|
|
|
50
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
668
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
209
|
|
6
|
7
|
|
|
7
|
|
32
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
204
|
|
7
|
7
|
|
|
7
|
|
39
|
use Carp; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
492
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
7505
|
use Object::InsideOut; |
|
7
|
|
|
|
|
362361
|
|
|
7
|
|
|
|
|
48
|
|
10
|
7
|
|
|
7
|
|
4664
|
use IO::Handle; |
|
7
|
|
|
|
|
29624
|
|
|
7
|
|
|
|
|
341
|
|
11
|
7
|
|
|
7
|
|
6277
|
use HTTP::Response; |
|
7
|
|
|
|
|
198151
|
|
|
7
|
|
|
|
|
293
|
|
12
|
7
|
|
|
7
|
|
4028
|
use Socket; |
|
7
|
|
|
|
|
22377
|
|
|
7
|
|
|
|
|
4861
|
|
13
|
7
|
|
|
7
|
|
54
|
use Digest::MD5 qw( md5_hex ); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
384
|
|
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
7
|
|
5349
|
use WWW::Slides::SlideTracker; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
54
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Other recommended modules (uncomment to use): |
18
|
|
|
|
|
|
|
# use IO::Prompt; |
19
|
|
|
|
|
|
|
# use Perl6::Export; |
20
|
|
|
|
|
|
|
# use Perl6::Slurp; |
21
|
|
|
|
|
|
|
# use Perl6::Say; |
22
|
|
|
|
|
|
|
# use Regexp::Autoflags; |
23
|
|
|
|
|
|
|
# use Readonly; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Module implementation here |
26
|
|
|
|
|
|
|
my @handle : Field # Handle towards browser |
27
|
|
|
|
|
|
|
: Std(Name => 'handle') # Leave public for Talk access |
28
|
|
|
|
|
|
|
: Arg(Name => 'handle', Mandatory => 1); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my @slide_show : Field # Where we're getting the slides from |
31
|
|
|
|
|
|
|
: Std(Name => 'slide_show', Private => 1) |
32
|
|
|
|
|
|
|
: Get(Name => 'slide_show', Private => 1) |
33
|
|
|
|
|
|
|
: Arg(Name => 'slide_show', Mandatory => 1); |
34
|
|
|
|
|
|
|
my @tracker : Field # Where we are |
35
|
|
|
|
|
|
|
: Std(Name => 'tracker', Private => 1) |
36
|
|
|
|
|
|
|
: Get(Name => 'tracker'); |
37
|
|
|
|
|
|
|
my @is_attached : Field # Is the user attached or on its own? |
38
|
|
|
|
|
|
|
: Std(Name => 'is_attached') : Get(Name => 'is_attached'); |
39
|
|
|
|
|
|
|
my @check_booking : Field # Check incoming parameter before allowing |
40
|
|
|
|
|
|
|
: Std(Name => 'check_booking') : Get(Name => 'must_check_booking') |
41
|
|
|
|
|
|
|
: Arg(Name => 'check_booking', Default => 0); |
42
|
|
|
|
|
|
|
my @booking_code : Field # Attendee external identifier |
43
|
|
|
|
|
|
|
: Std(Name => 'booking_code', Private => 1); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my %init_args : InitArgs = ('current_slide' => {Mandatory => 1},); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _init : Init { |
48
|
4
|
|
|
|
|
104940
|
my $self = shift; |
49
|
4
|
|
|
|
|
33
|
my ($args) = @_; |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
43
|
$self->attach(); |
52
|
4
|
|
|
|
|
158
|
$self->get_handle()->autoflush(); |
53
|
4
|
|
|
|
|
634
|
$self->set_tracker( |
54
|
|
|
|
|
|
|
WWW::Slides::SlideTracker->new( |
55
|
|
|
|
|
|
|
slide_show => $self->get_slide_show(), |
56
|
|
|
|
|
|
|
current => $args->{current_slide}, |
57
|
|
|
|
|
|
|
) |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
4
|
50
|
|
|
|
517
|
$self->send_start() unless $self->must_check_booking(); |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
31
|
return; |
63
|
7
|
|
|
7
|
|
1837
|
} ## end sub _init : |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
51
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub attach { |
66
|
4
|
|
|
4
|
0
|
21
|
my $self = shift; |
67
|
4
|
|
|
|
|
350
|
$self->set_is_attached(1); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub detach { |
71
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
72
|
0
|
|
|
|
|
0
|
$self->set_is_attached(0); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub peer_address { |
76
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
77
|
0
|
|
|
|
|
0
|
my ($port, $iaddr) = sockaddr_in($self->get_handle()->peername()); |
78
|
0
|
|
|
|
|
0
|
my $addr = inet_ntoa($iaddr); |
79
|
0
|
|
|
|
|
0
|
return $addr . ':' . $port; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub send : Private { |
83
|
29
|
|
|
|
|
4388
|
my $self = shift; |
84
|
29
|
50
|
|
|
|
714
|
return if $self->must_check_booking(); |
85
|
29
|
|
|
|
|
839
|
$self->get_handle()->print(@_); |
86
|
7
|
|
|
7
|
|
2589
|
} |
|
7
|
|
|
|
|
123
|
|
|
7
|
|
|
|
|
42
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub send_start : Private { |
89
|
4
|
|
|
|
|
196
|
my $self = shift; |
90
|
4
|
|
|
|
|
30
|
$self->send_HTTP_headers(); |
91
|
4
|
|
|
|
|
196
|
$self->send_preamble(); |
92
|
4
|
|
|
|
|
101
|
$self->show_current_slide(); |
93
|
4
|
|
|
|
|
9
|
return; |
94
|
7
|
|
|
7
|
|
1687
|
} ## end sub send_start : |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
28
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub send_stop : Private { |
97
|
0
|
|
|
|
|
0
|
my $self = shift; |
98
|
0
|
|
|
|
|
0
|
return $self->send($self->slide_show()->get_postamble()); |
99
|
7
|
|
|
7
|
|
1550
|
} |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
26
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub send_HTTP_headers : Private { # Get from slide_show? |
102
|
4
|
|
|
|
|
171
|
my $self = shift; |
103
|
|
|
|
|
|
|
|
104
|
4
|
|
|
|
|
75
|
my $res = HTTP::Response->new(); |
105
|
4
|
|
|
|
|
507
|
$res->code(200); |
106
|
4
|
|
|
|
|
42
|
$res->message('OK'); |
107
|
4
|
|
|
|
|
130
|
$res->content_type('text/html; charset=UTF-8'); |
108
|
4
|
|
|
|
|
374
|
$res->date(time()); |
109
|
4
|
|
|
|
|
24292
|
$res->server('Web::Slides/1.0'); |
110
|
4
|
|
|
|
|
415
|
$self->slide_show()->add_headers($res); |
111
|
|
|
|
|
|
|
|
112
|
4
|
|
|
|
|
749
|
return $self->send('HTTP/1.1 ', $res->as_string("\r\n")); |
113
|
7
|
|
|
7
|
|
1951
|
} ## end sub send_HTTP_headers : |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
26
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub send_preamble : Private { |
116
|
4
|
|
|
|
|
165
|
my $self = shift; |
117
|
4
|
|
|
|
|
94
|
return $self->send($self->slide_show()->get_preamble()); |
118
|
7
|
|
|
7
|
|
1540
|
} |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
34
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub show_current_slide : Private { |
121
|
9
|
|
|
|
|
270
|
my $self = shift; |
122
|
9
|
|
|
|
|
281
|
my $slide_show = $self->slide_show(); |
123
|
9
|
|
|
|
|
616
|
my $tracker = $self->tracker(); |
124
|
|
|
|
|
|
|
|
125
|
9
|
100
|
|
|
|
85
|
$self->send($slide_show->get_slide($tracker->current())) |
126
|
|
|
|
|
|
|
unless $tracker->already_served_current(); |
127
|
9
|
|
|
|
|
507
|
$self->send($slide_show->get_show_div($tracker->current())); |
128
|
|
|
|
|
|
|
|
129
|
9
|
|
|
|
|
143
|
return; |
130
|
7
|
|
|
7
|
|
1836
|
} ## end sub show_current_slide : |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
33
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub hide_current_slide : Private { |
133
|
5
|
|
|
|
|
111
|
my $self = shift; |
134
|
5
|
|
|
|
|
124
|
return $self->send( |
135
|
|
|
|
|
|
|
$self->slide_show()->get_hide_div($self->tracker()->current())); |
136
|
7
|
|
|
7
|
|
1648
|
} |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
35
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub ping { |
139
|
1
|
|
|
1
|
0
|
588
|
my $self = shift; |
140
|
1
|
|
|
|
|
24
|
return $self->send($self->slide_show()->get_ping()); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub show { |
144
|
5
|
|
|
5
|
0
|
1419
|
my $self = shift; |
145
|
5
|
|
|
|
|
8
|
my ($slide_no) = @_; |
146
|
5
|
50
|
|
|
|
144
|
return unless $self->slide_show()->validate_slide_id($slide_no); |
147
|
|
|
|
|
|
|
|
148
|
5
|
|
|
|
|
701
|
$self->tracker()->mark_current(); |
149
|
5
|
|
|
|
|
22
|
$self->hide_current_slide(); |
150
|
5
|
|
|
|
|
194
|
$self->tracker->goto($slide_no); |
151
|
5
|
|
|
|
|
19
|
$self->show_current_slide(); |
152
|
|
|
|
|
|
|
|
153
|
5
|
|
|
|
|
14
|
return; |
154
|
|
|
|
|
|
|
} ## end sub show |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub show_first { |
157
|
1
|
|
|
1
|
0
|
654
|
my $self = shift; |
158
|
1
|
|
|
|
|
29
|
return $self->show($self->tracker()->get_first()); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub show_last { |
162
|
1
|
|
|
1
|
0
|
582
|
my $self = shift; |
163
|
1
|
|
|
|
|
39
|
return $self->show($self->tracker()->get_last()); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub show_next { |
167
|
1
|
|
|
1
|
0
|
601
|
my $self = shift; |
168
|
1
|
|
|
|
|
31
|
return $self->show($self->tracker()->get_next()); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub show_previous { |
172
|
1
|
|
|
1
|
0
|
633
|
my $self = shift; |
173
|
1
|
|
|
|
|
34
|
return $self->show($self->tracker()->get_previous()); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub handle_input { |
177
|
3
|
|
|
3
|
0
|
1301
|
my $self = shift; |
178
|
3
|
|
|
|
|
12
|
my ($give_data) = @_; |
179
|
3
|
50
|
|
|
|
168
|
my $handle = $self->get_handle() or return; |
180
|
3
|
|
|
|
|
153
|
$handle->sysread(my $buffer, 1024); |
181
|
3
|
50
|
|
|
|
218
|
return $buffer if $give_data; |
182
|
3
|
|
66
|
|
|
83
|
return defined $buffer && length $buffer; |
183
|
|
|
|
|
|
|
} ## end sub handle_input |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub booking_code { |
186
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
187
|
0
|
0
|
|
|
|
|
if ($self->must_check_booking()) { |
188
|
0
|
|
|
|
|
|
$self->set_check_booking(0); # Won't check it two times... |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
my $input = $self->handle_input(1); # Get data back |
191
|
0
|
0
|
0
|
|
|
|
$self->set_booking_code($1) |
192
|
|
|
|
|
|
|
if defined $input |
193
|
|
|
|
|
|
|
&& $input =~ m{\A GET \s+ /?(\S+) \s+ HTTP/(?:\S+) \r\n}mxs; |
194
|
|
|
|
|
|
|
} ## end if ($self->check_booking... |
195
|
0
|
|
|
|
|
|
return $self->get_booking_code(); |
196
|
|
|
|
|
|
|
} ## end sub booking_code |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub book_ok { |
199
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
200
|
0
|
|
|
|
|
|
$self->set_check_booking(0); |
201
|
0
|
|
|
|
|
|
$self->send_start(); |
202
|
0
|
|
|
|
|
|
return; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub shut_down { |
206
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
207
|
0
|
|
|
|
|
|
$self->send_stop(); |
208
|
0
|
|
|
|
|
|
$self->get_handle()->close(); |
209
|
0
|
|
|
|
|
|
return; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub id { |
213
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
214
|
0
|
|
|
|
|
|
my $id = $self->booking_code(); |
215
|
0
|
0
|
|
|
|
|
$id = md5_hex($self->get_handle() . $self->peer_address()) |
216
|
|
|
|
|
|
|
unless defined $id; |
217
|
0
|
|
|
|
|
|
return $id; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
222
|
|
|
|
|
|
|
__END__ |