line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::UP::Notify; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6137
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
4776
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
81134
|
|
|
1
|
|
|
|
|
442
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '1.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
0
|
|
my $package = shift; |
12
|
0
|
|
|
|
|
|
return bless({}, $package); |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub subscriberid { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
0
|
|
|
|
|
if (@_) { |
18
|
0
|
|
|
|
|
|
$self->{'subscriberid'} = shift; |
19
|
0
|
|
|
|
|
|
($self->{'connecthost'}) = ( $self->{'subscriberid'} =~ /\_(.+)/ ); |
20
|
|
|
|
|
|
|
}; |
21
|
0
|
|
|
|
|
|
return $self->{'subscriberid'}; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub location { |
25
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
26
|
0
|
0
|
|
|
|
|
if (@_) { |
27
|
0
|
|
|
|
|
|
$self->{'location'} = shift; |
28
|
|
|
|
|
|
|
}; |
29
|
0
|
|
|
|
|
|
return $self->{'location'}; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub description { |
33
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
34
|
0
|
0
|
|
|
|
|
if (@_) { |
35
|
0
|
|
|
|
|
|
$self->{'description'} = shift; |
36
|
|
|
|
|
|
|
}; |
37
|
0
|
|
|
|
|
|
return $self->{'description'}; |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub urgency { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
0
|
|
|
|
|
if (@_) { |
43
|
0
|
|
|
|
|
|
$self->{'urgency'} = shift; |
44
|
|
|
|
|
|
|
}; |
45
|
0
|
|
|
|
|
|
return $self->{'urgency'}; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub send { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
0
|
0
|
|
|
|
|
if (! $self->{'urgency'}) { $self->{'urgency'} = "HIGH" }; |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
54
|
0
|
|
|
|
|
|
$ua->agent("up-notify.pl/1.0"); |
55
|
0
|
|
|
|
|
|
my $req = HTTP::Request->new(POST => 'http://'.$self->{'connecthost'}.':4445/ntfn/add'); |
56
|
0
|
|
|
|
|
|
$req->header("x-up-upnotifyp-version" => "upnotifyp/3.0"); |
57
|
0
|
|
|
|
|
|
$req->header("x-up-subno" => "$self->{'subscriberid'}"); |
58
|
0
|
|
|
|
|
|
$req->header("x-up-ntfn-ttl" => "0"); |
59
|
0
|
|
|
|
|
|
$req->header("x-up-ntfn-channel" => "push"); |
60
|
0
|
|
|
|
|
|
$req->header("Content-Location" => "$self->{'location'}"); |
61
|
0
|
|
|
|
|
|
my $xmldoc= " \n \n{'description'}\" \nCOUNT = \"1\" \nHREF = \"\" \nURGENCY = \"$self->{'urgency'}\" />\n"; |
62
|
0
|
|
|
|
|
|
$req->content_type('application/vnd.uplanet.alert'); |
63
|
0
|
|
|
|
|
|
$req->content($xmldoc); |
64
|
0
|
|
|
|
|
|
my $res = $ua->request($req); |
65
|
0
|
|
|
|
|
|
my $toreturn; |
66
|
0
|
|
|
|
|
|
return $res->content; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
__END__ |