| 1 | package Net::GrowlClient; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006000; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Digest::MD5 qw( md5_hex ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Digest::SHA qw( sha256_hex ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 11 | 1 | require Exporter; | |||||||||||||||||||||||||||||
| 12 | 1 | our @ISA = ("Exporter"); | |||||||||||||||||||||||||||||
| 13 | 1 | our @EXPORT = qw(notify $VERSION @ISA); | |||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||
| 16 | ############################################## | ||||||||||||||||||||||||||||||
| 17 | ## CONSTANTS | ||||||||||||||||||||||||||||||
| 18 | ############################################## | ||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use constant GROWL_UDP_PORT => '9887'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use constant GROWL_PROTOCOL_VERSION => '1'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use constant GROWL_PROTOCOL_VERSION_AES128 => '2'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use constant GROWL_TYPE_REGISTRATION => '0'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use constant GROWL_TYPE_NOTIFICATION => '1'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use constant GROWL_TYPE_REGISTRATION_SHA256 => '2'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use constant GROWL_TYPE_NOTIFICATION_SHA256 => '3'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use constant GROWL_TYPE_REGISTRATION_NOAUTH => '4'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use constant GROWL_TYPE_NOTIFICATION_NOAUTH => '5'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use constant CLIENT_DEFAULT_APPNAME => 'Net::GrowlClient'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use constant CLIENT_DEFAULT_NOTIFICATION_LIST => ['Net::GrowlClient Notification']; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use constant CLIENT_DEFAULT_NOTIFICATION => CLIENT_DEFAULT_NOTIFICATION_LIST->[0]; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use constant CLIENT_DEFAULT_TITLE => 'Hello from Net::GrowlClient!'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use constant CLIENT_DEFAULT_MESSAGE => "Yeah! It Works!\nThis is the default message."; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use constant CLIENT_DEFAULT_PRIORITY => 0; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use constant FALSE => 0; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | use constant TRUE => 1; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||
| 38 | ############################################## | ||||||||||||||||||||||||||||||
| 39 | ## CONSTRUCTOR | ||||||||||||||||||||||||||||||
| 40 | ############################################## | ||||||||||||||||||||||||||||||
| 41 | sub init | ||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||
| 43 | 1 | my $caller = shift; | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||
| 45 | 1 | my $self = { | |||||||||||||||||||||||||||||
| 46 | 'CLIENT_PASSWORD' => FALSE, | ||||||||||||||||||||||||||||||
| 47 | 'CLIENT_PEER_HOST' => FALSE, | ||||||||||||||||||||||||||||||
| 48 | 'CLIENT_PEER_PORT' => FALSE, | ||||||||||||||||||||||||||||||
| 49 | 'CLIENT_STICKY' => FALSE, | ||||||||||||||||||||||||||||||
| 50 | 'CLIENT_SKIP_REGISTER' => FALSE, | ||||||||||||||||||||||||||||||
| 51 | 'CLIENT_CRYPT' => FALSE, | ||||||||||||||||||||||||||||||
| 52 | 'CLIENT_APPLICATION_NAME' => CLIENT_DEFAULT_APPNAME, | ||||||||||||||||||||||||||||||
| 53 | 'CLIENT_NOTIFICATION_LIST' => CLIENT_DEFAULT_NOTIFICATION_LIST, | ||||||||||||||||||||||||||||||
| 54 | 'CLIENT_TYPE_REGISTRATION' => GROWL_TYPE_REGISTRATION_NOAUTH, | ||||||||||||||||||||||||||||||
| 55 | 'CLIENT_TYPE_NOTIFICATION' => GROWL_TYPE_NOTIFICATION_NOAUTH, | ||||||||||||||||||||||||||||||
| 56 | 'CLIENT_NOTIFICATION' => CLIENT_DEFAULT_NOTIFICATION, | ||||||||||||||||||||||||||||||
| 57 | 'CLIENT_TITLE' => CLIENT_DEFAULT_TITLE, | ||||||||||||||||||||||||||||||
| 58 | 'CLIENT_MESSAGE' => CLIENT_DEFAULT_MESSAGE, | ||||||||||||||||||||||||||||||
| 59 | 'CLIENT_PRIORITY' => CLIENT_DEFAULT_PRIORITY, | ||||||||||||||||||||||||||||||
| 60 | @_ | ||||||||||||||||||||||||||||||
| 61 | }; | ||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||
| 63 | 1 | bless($self, $class); | |||||||||||||||||||||||||||||
| 64 | 1 | &_init($self); | |||||||||||||||||||||||||||||
| 65 | 1 | ▶ | &_register($self) unless $self->{'CLIENT_SKIP_REGISTER'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 66 | 1 | return $self; | |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||
| 69 | ############################################## | ||||||||||||||||||||||||||||||
| 70 | ## INITIALIZE UDP SOCKET | ||||||||||||||||||||||||||||||
| 71 | ############################################## | ||||||||||||||||||||||||||||||
| 72 | sub _init | ||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=4 SCAR=15.8
| |||||||||||||||||||||||||||||||
| 74 | 1 | my $self = shift; | |||||||||||||||||||||||||||||
| 75 | $self->{'CLIENT_SOCKET'} = IO::Socket::INET->new | ||||||||||||||||||||||||||||||
| 76 | ( | ||||||||||||||||||||||||||||||
| 77 | PeerPort => $self->{'CLIENT_PEER_PORT'} || GROWL_UDP_PORT, | ||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | PeerHost => $self->{'CLIENT_PEER_HOST'} || 'localhost', | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$self->{'CLIENT_PEER_PORT'} || '9887'
$self->{'CLIENT_PEER_HOST'} || 'localhost'
MC/DC0%0/1
$self->{'CLIENT_PEER_PORT'} || '9887'
$self->{'CLIENT_PEER_PORT'}
MC/DC0%0/1
$self->{'CLIENT_PEER_HOST'} || 'localhost'
$self->{'CLIENT_PEER_HOST'}
Truth table50%1/2
A
A= $self->{'CLIENT_PEER_PORT'}
Truth table50%1/2
A
A= $self->{'CLIENT_PEER_HOST'}
| |||||||||||||||||||||||||||||||
| 79 | Proto => 'udp', | ||||||||||||||||||||||||||||||
| 80 | Type => SOCK_DGRAM, | ||||||||||||||||||||||||||||||
| 81 | ReuseAddr => 1 | ||||||||||||||||||||||||||||||
| 82 | ) or croak __PACKAGE__." --> $@"; | ||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||
| 85 | ############################################## | ||||||||||||||||||||||||||||||
| 86 | ## REGISTER | ||||||||||||||||||||||||||||||
| 87 | ############################################## | ||||||||||||||||||||||||||||||
| 88 | sub _register | ||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
_register: not called CC=5 SCAR=31.4
| |||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | use bytes; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 92 | 0 | my ($data, $ckecksum, $notification_pack, $default_pack, $packet, $checksum); | |||||||||||||||||||||||||||||
| 93 | 0 | my $notification_list_ptr = $self->{'CLIENT_NOTIFICATION_LIST'}; | |||||||||||||||||||||||||||||
| 94 | 0 | my $application_name = $self->{'CLIENT_APPLICATION_NAME'}; | |||||||||||||||||||||||||||||
| 95 | 0 | my $password = $self->{'CLIENT_PASSWORD'}; | |||||||||||||||||||||||||||||
| 96 | 0 | utf8::encode($password); | |||||||||||||||||||||||||||||
| 97 | 0 | utf8::encode($application_name); | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||
| 99 | 0 | foreach my $notification ( @$notification_list_ptr ) | |||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||||
| 101 | 0 | utf8::encode($notification); | |||||||||||||||||||||||||||||
| 102 | 0 | $notification_pack .= pack ( | |||||||||||||||||||||||||||||
| 103 | 'na*', | ||||||||||||||||||||||||||||||
| 104 | bytes::length($notification), | ||||||||||||||||||||||||||||||
| 105 | $notification | ||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||
| 108 | 0 | foreach my $default_notification (0..scalar @$notification_list_ptr - 1) | |||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||
| 110 | 0 | $default_pack .= pack('C', $default_notification); | |||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||
| 113 | $data = pack ( | ||||||||||||||||||||||||||||||
| 114 | 'CCnCC', | ||||||||||||||||||||||||||||||
| 115 | GROWL_PROTOCOL_VERSION, | ||||||||||||||||||||||||||||||
| 116 | 0 | $self->{'CLIENT_TYPE_REGISTRATION'}, | |||||||||||||||||||||||||||||
| 117 | bytes::length($application_name), | ||||||||||||||||||||||||||||||
| 118 | (scalar @$notification_list_ptr), | ||||||||||||||||||||||||||||||
| 119 | (scalar @$notification_list_ptr) | ||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||
| 121 | 0 | $data .= pack ('a*', $application_name); | |||||||||||||||||||||||||||||
| 122 | 0 | $data .= $notification_pack . $default_pack; | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ($self->{'CLIENT_TYPE_REGISTRATION'} eq GROWL_TYPE_REGISTRATION) | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||||
| 126 | 0 | $checksum = pack ('H32', md5_hex($data . $password)); | |||||||||||||||||||||||||||||
| 127 | 0 | $packet = $data . $checksum; | |||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||
| 129 | elsif ($self->{'CLIENT_TYPE_REGISTRATION'} eq GROWL_TYPE_REGISTRATION_SHA256) | ||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||
| 131 | 0 | $checksum = pack ('H64', sha256_hex($data . $password)); | |||||||||||||||||||||||||||||
| 132 | 0 | $packet = $data . $checksum; | |||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||
| 134 | else | ||||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||||
| 136 | 0 | $packet = $data; | |||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||
| 139 | 0 | &_sender($self, $packet); | |||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||
| 142 | ############################################## | ||||||||||||||||||||||||||||||
| 143 | ## NOTIFY | ||||||||||||||||||||||||||||||
| 144 | ############################################## | ||||||||||||||||||||||||||||||
| 145 | sub notify | ||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
notify: not called CC=11 SCAR=47.4
Pod
documented
| |||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | use bytes; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 148 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 149 | 0 | my %notify_args = @_; | |||||||||||||||||||||||||||||
| 150 | 0 | my ($notification_name, $title, $message, $application_name, $checksum, $data, $packet, $priority, $flags, $sticky, $password); | |||||||||||||||||||||||||||||
| 151 | 0 | my %priority = ( | |||||||||||||||||||||||||||||
| 152 | "-2" => "011", | ||||||||||||||||||||||||||||||
| 153 | "Low" => "011", | ||||||||||||||||||||||||||||||
| 154 | "Very Low" => "011", | ||||||||||||||||||||||||||||||
| 155 | "-1" => "111", | ||||||||||||||||||||||||||||||
| 156 | "Moderate" => "111", | ||||||||||||||||||||||||||||||
| 157 | "0" => "000", | ||||||||||||||||||||||||||||||
| 158 | "Normal" => "000", | ||||||||||||||||||||||||||||||
| 159 | "1" => "100", | ||||||||||||||||||||||||||||||
| 160 | "High" => "100", | ||||||||||||||||||||||||||||||
| 161 | "2" => "010", | ||||||||||||||||||||||||||||||
| 162 | "Emergency" => "010" | ||||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||
| 165 | 0 | $password = $self->{'CLIENT_PASSWORD'};utf8::encode($password); | |||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $application_name = $notify_args{'application'} || $self->{'CLIENT_APPLICATION_NAME'};utf8::encode($application_name); | ||||||||||||||||||||||||||||
|
Condition0%0/3
$notify_args{'application'} || $self->{'CLIENT_APPLICATION_NAME'}
MC/DC0%0/2
$notify_args{'application'} || $self->{'CLIENT_APPLICATION_NAME'}
$notify_args{'application'}
$self->{'CLIENT_APPLICATION_NAME'}
Truth table0%0/3
A || B
A= $notify_args{'application'}B= $self->{'CLIENT_APPLICATION_NAME'}
| |||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | $notification_name = $notify_args{'notification'} || $self->{'CLIENT_NOTIFICATION'};utf8::encode($notification_name); | ||||||||||||||||||||||||||||
|
Condition0%0/3
$notify_args{'notification'} || $self->{'CLIENT_NOTIFICATION'}
MC/DC0%0/2
$notify_args{'notification'} || $self->{'CLIENT_NOTIFICATION'}
$notify_args{'notification'}
$self->{'CLIENT_NOTIFICATION'}
Truth table0%0/3
A || B
A= $notify_args{'notification'}B= $self->{'CLIENT_NOTIFICATION'}
| |||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | $title = $notify_args{'title'} || $self->{'CLIENT_TITLE'};utf8::encode($title); | ||||||||||||||||||||||||||||
|
Condition0%0/3
$notify_args{'title'} || $self->{'CLIENT_TITLE'}
MC/DC0%0/2
$notify_args{'title'} || $self->{'CLIENT_TITLE'}
$notify_args{'title'}
$self->{'CLIENT_TITLE'}
Truth table0%0/3
A || B
A= $notify_args{'title'}B= $self->{'CLIENT_TITLE'}
| |||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $message = $notify_args{'message'} || $self->{'CLIENT_MESSAGE'};utf8::encode($message); | ||||||||||||||||||||||||||||
|
Condition0%0/3
$notify_args{'message'} || $self->{'CLIENT_MESSAGE'}
MC/DC0%0/2
$notify_args{'message'} || $self->{'CLIENT_MESSAGE'}
$notify_args{'message'}
$self->{'CLIENT_MESSAGE'}
Truth table0%0/3
A || B
A= $notify_args{'message'}B= $self->{'CLIENT_MESSAGE'}
| |||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | $sticky = $notify_args{'sticky'} || $self->{'CLIENT_STICKY'}; | ||||||||||||||||||||||||||||
|
Condition0%0/3
$notify_args{'sticky'} || $self->{'CLIENT_STICKY'}
MC/DC0%0/2
$notify_args{'sticky'} || $self->{'CLIENT_STICKY'}
$notify_args{'sticky'}
$self->{'CLIENT_STICKY'}
Truth table0%0/3
A || B
A= $notify_args{'sticky'}B= $self->{'CLIENT_STICKY'}
| |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if (($notify_args{'priority'}) and (grep (/^$notify_args{'priority'}$/, keys %priority))) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$notify_args{"priority"} and grep /^$notify_args{"priority"}$/, keys %priority
MC/DC0%0/2
$notify_args{"priority"} and grep /^$notify_args{"priority"}$/, keys %priority
$notify_args{"priority"}
grep /^$notify_args{"priority"}$/, keys %priority
Truth table0%0/3
A and B
A= $notify_args{"priority"}B= grep /^$notify_args{"priority"}$/, keys %priority
| |||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||
| 174 | 0 | $priority = $priority{$notify_args{'priority'}}; | |||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||
| 176 | else | ||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||
| 178 | 0 | $priority = $self->{'CLIENT_PRIORITY'}; | |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | carp __PACKAGE__." --> Unknown Priority \'$notify_args{'priority'}\'" if ($notify_args{'priority'}); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||
| 182 | 0 | $flags = '0'x12 .$priority.$sticky; | |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||
| 184 | $data = pack ( 'CCb[16]nnnna*', | ||||||||||||||||||||||||||||||
| 185 | GROWL_PROTOCOL_VERSION, | ||||||||||||||||||||||||||||||
| 186 | 0 | $self->{'CLIENT_TYPE_NOTIFICATION'}, | |||||||||||||||||||||||||||||
| 187 | $flags, | ||||||||||||||||||||||||||||||
| 188 | bytes::length($notification_name), | ||||||||||||||||||||||||||||||
| 189 | bytes::length($title), | ||||||||||||||||||||||||||||||
| 190 | bytes::length($message), | ||||||||||||||||||||||||||||||
| 191 | bytes::length($application_name), | ||||||||||||||||||||||||||||||
| 192 | "$notification_name$title$message$application_name" | ||||||||||||||||||||||||||||||
| 193 | ); | ||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ($self->{'CLIENT_TYPE_NOTIFICATION'} eq GROWL_TYPE_NOTIFICATION) | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||
| 197 | 0 | $checksum = pack ('H32', md5_hex($data . $password)); | |||||||||||||||||||||||||||||
| 198 | 0 | $packet = $data . $checksum; | |||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||
| 200 | elsif ($self->{'CLIENT_TYPE_NOTIFICATION'} eq GROWL_TYPE_NOTIFICATION_SHA256) | ||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||
| 202 | 0 | $checksum = pack ('H64', sha256_hex($data . $password)); | |||||||||||||||||||||||||||||
| 203 | 0 | $packet = $data . $checksum; | |||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||
| 205 | else | ||||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||||
| 207 | 0 | $packet = $data; | |||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||
| 210 | 0 | &_sender($self, $packet); | |||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||
| 212 | ############################################## | ||||||||||||||||||||||||||||||
| 213 | ## DATA CRYPT (AES128) | ||||||||||||||||||||||||||||||
| 214 | ############################################## | ||||||||||||||||||||||||||||||
| 215 | sub _aescrypt | ||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
_aescrypt: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 217 | 0 | my $self=shift; | |||||||||||||||||||||||||||||
| 218 | 0 | my $packet; | |||||||||||||||||||||||||||||
| 219 | 0 | return $packet; | |||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||
| 221 | ############################################## | ||||||||||||||||||||||||||||||
| 222 | ## SOCKET PRINTER | ||||||||||||||||||||||||||||||
| 223 | ############################################## | ||||||||||||||||||||||||||||||
| 224 | sub _sender | ||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
_sender: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 227 | 0 | my $packet = shift; | |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | $self->{'CLIENT_SOCKET'}->send($packet) or carp __PACKAGE__." --> $@"; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||
| 231 | ############################################## | ||||||||||||||||||||||||||||||
| 232 | ## DESTRUCTOR | ||||||||||||||||||||||||||||||
| 233 | ############################################### | ||||||||||||||||||||||||||||||
| 234 | sub DESTROY | ||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 236 | #Still thinking about what I could insert here; | ||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||
| 238 | 1 | 1; | |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||
| 240 | __END__ | ||||||||||||||||||||||||||||||