line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OBEX::Response; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
3927
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
102
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.001001'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
587
|
use Net::OBEX::Response::Generic; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
43
|
|
9
|
2
|
|
|
2
|
|
537
|
use Net::OBEX::Response::Connect; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
10
|
2
|
|
|
2
|
|
563
|
use Net::OBEX::Packet::Headers; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
63
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
10
|
use base 'Class::Data::Accessor'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
902
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->mk_classaccessors( qw(obj_connect obj_generic obj_head error ) ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
1
|
|
|
1
|
1
|
369
|
my $class = shift; |
17
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
18
|
1
|
|
|
|
|
17
|
$self->obj_connect( Net::OBEX::Response::Connect->new ); |
19
|
1
|
|
|
|
|
22
|
$self->obj_generic( Net::OBEX::Response::Generic->new ); |
20
|
1
|
|
|
|
|
15
|
$self->obj_head( Net::OBEX::Packet::Headers->new ); |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
7
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parse { |
26
|
2
|
|
|
2
|
1
|
1309
|
my ( $self, $packet, $is_connect ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
2
|
100
|
|
|
|
7
|
if ( $is_connect ) { |
29
|
1
|
|
|
|
|
4
|
return $self->obj_connect->parse_info( $packet ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
1
|
|
|
|
|
11
|
return $self->obj_generic->parse_info( $packet ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub parse_sock { |
37
|
0
|
|
|
0
|
1
|
|
my ( $self, $sock, $is_connect ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $read_buffer; |
40
|
0
|
0
|
|
|
|
|
unless ( $sock->read( $read_buffer, ( $is_connect ? 7 : 3 ) ) ) { |
|
|
0
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->error( 'Socket error: ' . $sock->error ); |
42
|
0
|
|
|
|
|
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my %response = ( |
46
|
|
|
|
|
|
|
raw_packet => $read_buffer, |
47
|
|
|
|
|
|
|
info => $self->parse( $read_buffer, $is_connect ), |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ( my $length = $response{info}{headers_length} ) { |
51
|
0
|
0
|
|
|
|
|
unless ( $sock->read( $read_buffer, $length ) ) { |
52
|
0
|
|
|
|
|
|
$self->error( 'Socket error: ' . $sock->error ); |
53
|
0
|
|
|
|
|
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
$response{raw_packet} .= $read_buffer; |
56
|
0
|
|
|
|
|
|
$response{headers} = $self->obj_head->parse( $read_buffer ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return \%response; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |