line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache2::WurflSimple; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
23681
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
535
|
use Apache2::Const; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Apache2::RequestRec; |
10
|
|
|
|
|
|
|
use APR::Table; |
11
|
|
|
|
|
|
|
use Apache2::Module (); |
12
|
|
|
|
|
|
|
use Apache2::ServerUtil; |
13
|
|
|
|
|
|
|
use Net::WURFL::ScientiaMobile; |
14
|
|
|
|
|
|
|
use Net::WURFL::ScientiaMobile::Cache::Cookie; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# ABSTRACT: module that the Wurfl Perl client to retrieve capabilities data from the Wurfl server |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=pod |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Apache2::WurflPro -A module that the Wurfl Perl client to retrieve capabilities data from the Wurfl server |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
-A module that the Wurfl Perl client to retrieve capabilities data from the Wurfl server with a simple account |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use 5.010; |
34
|
|
|
|
|
|
|
use strict; |
35
|
|
|
|
|
|
|
use warnings; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 handler |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
The handler retrieves the user_agens and the api key. |
44
|
|
|
|
|
|
|
It then checks the cache for existing data |
45
|
|
|
|
|
|
|
If none is there is retrieves data from the Wurfl server |
46
|
|
|
|
|
|
|
and sets the environment accordingly. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_config { |
52
|
|
|
|
|
|
|
Apache2::Module::get_config('Apache2::Wurfl::Parameters', @_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub handler { |
57
|
|
|
|
|
|
|
my $r = shift; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#get user agent |
60
|
|
|
|
|
|
|
my $headers_in = $r->headers_in; |
61
|
|
|
|
|
|
|
my $user_agent = $headers_in->get('User-Agent'); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#get api key |
64
|
|
|
|
|
|
|
my $s = $r->server; |
65
|
|
|
|
|
|
|
my $dir_cfg = get_config($s, $r->per_dir_config); |
66
|
|
|
|
|
|
|
my $api_key = $dir_cfg->{WurflAPIKey}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#load wurflcloud client library with cookie cache |
69
|
|
|
|
|
|
|
my $cache = Net::WURFL::ScientiaMobile::Cache::Cookie->new; |
70
|
|
|
|
|
|
|
my $scientiamobile = Net::WURFL::ScientiaMobile->new( |
71
|
|
|
|
|
|
|
api_key => $api_key, |
72
|
|
|
|
|
|
|
cache => $cache, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#run device detection and retrieve data |
76
|
|
|
|
|
|
|
my $capabilities; |
77
|
|
|
|
|
|
|
my %env = %ENV; |
78
|
|
|
|
|
|
|
$env{'User-Agent'} = $user_agent unless $env{'User-Agent'}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$cache->env(\%env); |
81
|
|
|
|
|
|
|
$scientiamobile->detectDevice(\%env); |
82
|
|
|
|
|
|
|
$capabilities = $scientiamobile->capabilities(); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#load capabilities into apache environment |
85
|
|
|
|
|
|
|
foreach my $key (keys %{$capabilities}) { |
86
|
|
|
|
|
|
|
my $upperkey = uc($key); |
87
|
|
|
|
|
|
|
$r->subprocess_env("WURFL_$upperkey" => $capabilities->{$key}); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
return Apache2::Const::OK; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |