line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::UserAgentString::Browser; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
HTTP::UserAgentString::Browser - Web browser |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$browser = $p->parse($string) |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
print "This is a ", ($browser->isRobot()) ? "robot" : "browser", "\n"; |
12
|
|
|
|
|
|
|
print "Name: ", $browser->name(), "\n"; |
13
|
|
|
|
|
|
|
print "Version: ", $browser->version(), "\n"; |
14
|
|
|
|
|
|
|
print "URL: ", $browser->url(), "\n"; |
15
|
|
|
|
|
|
|
print "Company: ", $browser->company(), "\n"; |
16
|
|
|
|
|
|
|
print "Company URL: ", $browser->company_url(), "\n"; |
17
|
|
|
|
|
|
|
print "Info URL: ", $browser->info_url(), "\n"; |
18
|
|
|
|
|
|
|
print "Type: ", $browser->type(), "\n"; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$os = $browser->os(); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Used to represent web browsers returned by L. Object is read |
25
|
|
|
|
|
|
|
only. Accesors are provided for all capabilities defined by |
26
|
|
|
|
|
|
|
user-agent-string.info |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over 4 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item $browser->name() |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Browser name. Example: "Firefox" |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item $browser->version() |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
String version. Example: "3.5" |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item $browser->url() |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Web page for the browser |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item $browser->company() |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Name of the company that develops the browser |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item $browser->company_url() |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
URL of the company that develops the browser |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item $browser->ico() |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
PNG icon for the browser that can be obtained from http://user-agent-string.info/pub/img/ua/ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item $browser->info_url() |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Web page in http://user-agent-string.info/ that provides information on the browser |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item $browser->type() |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Numeric type (see browser_type_id[] in the .ini file) |
63
|
|
|
|
|
|
|
More accessors are provided to check for type: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over 4 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item $browser->typeDesc() |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
String description for the browser's type. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item $browser->isBrowser() |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Check for standard web browser |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item $browser->isOffline() |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Check for offline web browsers |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item $browser->isMobile() |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Check for mobile web browsers |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item $browser->isEmail() |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Check for e-mail clients |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item $browser->isWAP() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Check for WAP browsers |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item $browser->isLibrary() |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Check for HTTP libraries |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item $browser->os |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
If defined, L object representing the operating system |
100
|
|
|
|
|
|
|
where the browser is running. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L for the class representing operating systems, and |
107
|
|
|
|
|
|
|
L for robots. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 COPYRIGHT |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Copyright (c) 2011 Nicolas Moldavsky (http://www.e-planning.net/) |
112
|
|
|
|
|
|
|
This library is released under LGPL V3 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
140
|
|
117
|
4
|
|
|
4
|
|
20
|
use base qw(HTTP::UserAgentString::Sys); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
2354
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my @KEYS = qw(type name url company company_url ico info_url); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $BROWSER = 0; |
122
|
|
|
|
|
|
|
my $OFFLINE = 1; |
123
|
|
|
|
|
|
|
my $MOBILE = 3; |
124
|
|
|
|
|
|
|
my $EMAIL = 4; |
125
|
|
|
|
|
|
|
my $LIBRARY = 5; |
126
|
|
|
|
|
|
|
my $WAP = 6; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub new($$$;$$) { |
129
|
2
|
|
|
2
|
0
|
7
|
my ($pkg, $data, $typeDesc, $version, $os) = @_; |
130
|
|
|
|
|
|
|
|
131
|
2
|
|
|
|
|
5
|
my $h = {}; |
132
|
2
|
|
|
|
|
11
|
for (my $i = 0; $i < scalar(@KEYS); $i++) { |
133
|
14
|
|
|
|
|
21
|
my $val = $data->[$i]; |
134
|
14
|
50
|
33
|
|
|
62
|
if (defined($val) and (length($val) > 0)) { |
135
|
14
|
|
|
|
|
53
|
$h->{$KEYS[$i]} = $val; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
2
|
|
|
|
|
9
|
$h->{os} = $os; |
139
|
2
|
|
|
|
|
7
|
$h->{version} = $version; |
140
|
2
|
50
|
|
|
|
619
|
if (defined($version)) { |
141
|
2
|
|
|
|
|
18
|
my @v = split(/\./, $version); |
142
|
2
|
50
|
|
|
|
10
|
if (@v) { |
143
|
2
|
|
|
|
|
7
|
$h->{major_version} = shift(@v); |
144
|
2
|
50
|
|
|
|
9
|
if (@v) { |
145
|
2
|
|
|
|
|
9
|
$h->{minor_version} = shift(@v); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
2
|
|
|
|
|
6
|
$h->{typeDesc} = $typeDesc; |
151
|
2
|
|
|
|
|
17
|
return bless($h, $pkg); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
6
|
|
|
6
|
1
|
7555
|
sub type($) { $_[0]->{type} } |
155
|
0
|
|
|
0
|
1
|
0
|
sub info_url($) { $_[0]->{info_url} } |
156
|
5
|
|
|
5
|
1
|
880
|
sub os($) { $_[0]->{os} } |
157
|
4
|
|
|
4
|
1
|
23
|
sub version($) { $_[0]->{version} } |
158
|
0
|
|
|
0
|
0
|
0
|
sub major_version($) { $_[0]->{major_version} } |
159
|
0
|
|
|
0
|
0
|
0
|
sub minor_version($) { $_[0]->{minor_version} } |
160
|
1
|
|
|
1
|
1
|
14
|
sub typeDesc($) { $_[0]->{typeDesc} } |
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
1
|
0
|
6
|
sub isRobot($) { 0 } |
163
|
|
|
|
|
|
|
|
164
|
1
|
|
|
1
|
1
|
9
|
sub isBrowser($) { $BROWSER == $_[0]->type } |
165
|
0
|
|
|
0
|
1
|
0
|
sub isOffline($) { $OFFLINE == $_[0]->type } |
166
|
1
|
|
|
1
|
1
|
8
|
sub isMobile($) { $MOBILE == $_[0]->type } |
167
|
1
|
|
|
1
|
1
|
7
|
sub isEmail($) { $EMAIL == $_[0]->type } |
168
|
1
|
|
|
1
|
1
|
7
|
sub isLibrary($) { $LIBRARY == $_[0]->type } |
169
|
1
|
|
|
1
|
1
|
5
|
sub isWAP($) { $WAP == $_[0]->type } |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |