| 1 | package POE::XUL::Event; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # $Id: Event.pm 1566 2010-11-03 03:13:32Z fil $ | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright Philip Gwyn 2007-2010. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Based on code Copyright 2003-2004 Ran Eilam. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use POE::XUL::Logging; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use constant DEBUG => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 15 | our $VERSION = '0.0600'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 17 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 18 | { | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | my( $package, $event_type, $CM, $response ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | croak "Why didn't you give me a ChangeManager" unless $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | croak "Why didn't you give me a HTTP::Response" unless $response; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 25 | event_type => $event_type, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | CM => $CM, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | response => $response, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | canceled => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | done => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 30 | }, $package; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | $CM->request_start( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | DEBUG and xwarn "$self.CM=$self->{CM}"; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 40 | sub __init | ||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | my( $self, $req ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__init: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 8 | $self->{app} = $req->param( 'app' ); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | ▶ | if( $self->{event_type} ne 'connect' and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->{"event_type"} ne "connect" and $self->{"event_type"} ne "disconnect" and $self->{"event_type"} ne "boot"
$self->{"event_type"} ne "connect" and $self->{"event_type"} ne "disconnect"
MC/DC100%3/3
$self->{"event_type"} ne "connect" and $self->{"event_type"} ne "disconnect" and $self->{"event_type"} ne "boot"
$self->{"event_type"} ne "connect"
$self->{"event_type"} ne "disconnect"
$self->{"event_type"} ne "boot"
Truth table100%4/4
A and B and C
A= $self->{"event_type"} ne "connect"B= $self->{"event_type"} ne "disconnect"C= $self->{"event_type"} ne "boot"
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | $self->{event_type} ne 'disconnect' and | ||||||||||||||||||||||||||||||||||||||||||
| 47 | $self->{event_type} ne 'boot' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | my $source_id = $req->param( 'source_id' ); | |||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | my $rc = $self->__source_id( $source_id ); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | ▶ | die $rc if $rc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | foreach my $f ( $req->params ) { | |||||||||||||||||||||||||||||||||||||||||
| 54 | 24 | ▶ | next if $f eq 'source_id'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 16 | $self->set( $f => $req->param( $f ) ); | |||||||||||||||||||||||||||||||||||||||||
| 56 | # warn "$f=", $self->get( $f ); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 8 | ▶ | if( $self->{event_type} ne 'connect' and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"event_type"} ne "connect" and $self->{"event_type"} ne "boot"
MC/DC100%2/2
$self->{"event_type"} ne "connect" and $self->{"event_type"} ne "boot"
$self->{"event_type"} ne "connect"
$self->{"event_type"} ne "boot"
Truth table100%3/3
A and B
A= $self->{"event_type"} ne "connect"B= $self->{"event_type"} ne "boot"
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | $self->{event_type} ne 'boot' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | my $winID = $req->param( 'window' ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | my $rc = $self->__window_id( $winID ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 6 | ▶ | die $rc if $rc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 69 | sub __source_id | ||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | ▶ | my( $self, $id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__source_id: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | my $node = $self->{CM}->getElementById( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | ▶ | unless( $node ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | # xwarn "known = ", join ',', grep { $_ !~ /PXN/ } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | # keys %{ $self->{CM}{nodes} }; | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return "Can't find source node $id"; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | $self->{source} = $node; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 5 | $self->{source_id} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 85 | sub __window_id | ||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 6 | ▶ | my( $self, $id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__window_id: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 6 | my $node; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | ▶ | if( $id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | $node = $self->{CM}->getElementById( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | DEBUG and xwarn "winID=$id node=$node"; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 5 | ▶ | return "Can't find window node $id" unless $node; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif( $self->{CM} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | $node = $self->{CM}->window; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 6 | ▶ | $id ||= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$id ||= ""
MC/DC100%1/1
$id ||= ""
$id
Truth table100%2/2
A
A= $id
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 6 | $self->{window} = $node; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 6 | $self->{window_id} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # Accessors | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 17 | ▶ | sub set { $_[0]->{ $_[1] } = $_[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | sub get { $_[0]->{ $_[1] } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | sub name { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 13 | ▶ | return $_[0]->{event_type} unless 2==@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 6 | $_[0]->{event_type} = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 15 | *event = \&name; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub type { $_[0]->{event_type} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | sub session { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | carp "Please use SID() instead of session()"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | shift->SID( @_ ) | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | sub resp { $_[0]->{response} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resp: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub response { $_[0]->{response} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub req { $_[0]->{response}->connection->request } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
req: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub request { $_[0]->{response}->connection->request } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # general accessor/mutator | ||||||||||||||||||||||||||||||||||||||||||
| 125 | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 30 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 30 | my $key = our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 30 | ▶ | return if $key =~ /DESTROY$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 29 | $key =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 29 | ▶ | return $self->{$key} if @_ == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 9 | $self->{$key} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 15 | *target = \&source; | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 137 | sub coderef | ||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | ▶ | my( $self, $coderef ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coderef: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | $self->{coderef} = $coderef; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 147 | sub run | ||||||||||||||||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | local $POE::XUL::Logging::SINGLETON->{app} = $self->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # Tell the ChangeManager to keep the Node in sync with the browser | ||||||||||||||||||||||||||||||||||||||||||
| 154 | # elements. This is where event "side-effects" happen | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | my $method = "handle_" . $self->event; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | my $CMm = $self->{CM}->can( $method ); | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 5 | ▶ | if( $CMm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | DEBUG and xdebug "$method = $CMm"; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | $self->wrap( sub { $CMm->( $self->{CM}, $self ) } ) ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | return if $self->{CM}{responded}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | # Call code that our builder thinks we should execute | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | ▶ | if( $self->{coderef} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||
| 167 | xdebug "coderef"; | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | $self->wrap( delete $self->{coderef} ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # Call code that the application thinks we should execute | ||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||
| 173 | xdebug "do_event"; | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | $self->do_event(); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | sub do_event | ||||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_event: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | local $POE::XUL::Logging::SINGLETON->{app} = $self->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | my $bt = delete $self->{bubble_to}; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | foreach my $N ( $self->{source}, $bt ) { | |||||||||||||||||||||||||||||||||||||||||
| 185 | 4 | ▶ | next unless $N; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 4 | my $listener = $N->event( $self->{event_type} ); | |||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||
| 189 | xdebug "========== $N listener=$listener"; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | ▶ | next unless $listener; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | $self->{source} = $N; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | $self->wrap( sub { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | if( ref $listener ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | $listener->( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | DEBUG and xdebug "Posting to $self->{SID}/$listener"; | |||||||||||||||||||||||||||||||||||||||||
| 200 | $POE::Kernel::poe_kernel->call( $self->{SID}, | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $listener, | |||||||||||||||||||||||||||||||||||||||||
| 202 | $self | ||||||||||||||||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | } ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 212 | sub wrap | ||||||||||||||||||||||||||||||||||||||||||
| 213 | { | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 6 | ▶ | my( $self, $coderef ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 6 | local $POE::XUL::Logging::SINGLETON->{app} = $self->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | local $SIG{__DIE__} = 'DEFAULT'; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 6 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||
| 220 | xcarp "Wrapping user code CM=$self->{CM}"; | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 6 | local $POE::XUL::Node::CM = $self->{CM}; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 6 | $coderef->( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 6 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | my $err = "APPLICATION ERROR: $@"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | $self->wrapped_error( $err ); | |||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 233 | ## Make sure it is still possible to respond to this event | ||||||||||||||||||||||||||||||||||||||||||
| 234 | sub __respondable | ||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | my( $self, $action ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__respondable: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | if( $self->{canceled} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | xcarp2 "Attempt to $action a canceled event"; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | if( $self->has_response ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | xcarp2 "Attempt to $action to a responded event"; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 250 | sub cancel | ||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cancel: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $self->{canceled} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | unless( $self->has_response ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | xlog "Event canceled before CM responded"; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $self->{done} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | xlog "Event canceled"; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 264 | sub canceled | ||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canceled: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | return $self->{canceled}; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 271 | sub handled | ||||||||||||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handled: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | local $POE::XUL::Logging::SINGLETON->{app} = $self->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | $self->done( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | DEBUG and xcarp "Event finished"; | |||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | $self->flush(); | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 15 | *finish = \&handled; | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 284 | sub has_response | ||||||||||||||||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_response: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 2 | ▶ | return 1 unless $self->{CM}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | ▶ | return 1 if $self->{CM}->responded; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 293 | sub defer | ||||||||||||||||||||||||||||||||||||||||||
| 294 | { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defer: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | ▶ | return unless $self->__respondable( 'defer' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | $self->done( 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 301 | sub flushed | ||||||||||||||||||||||||||||||||||||||||||
| 302 | { | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flushed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | return $self->{is_flushed}; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 308 | # Flush is called from Controler->xul_request or from Event->finish/flush | ||||||||||||||||||||||||||||||||||||||||||
| 309 | sub flush | ||||||||||||||||||||||||||||||||||||||||||
| 310 | { | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | local $POE::XUL::Logging::SINGLETON->{app} = $self->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | ▶ | if( $self->{is_flushed} or not $self->{CM} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"is_flushed"} or not $self->{"CM"}
MC/DC50%1/2
$self->{"is_flushed"} or not $self->{"CM"}
$self->{"is_flushed"}
not $self->{"CM"}
Truth table66%2/3
A or not(B)
A= $self->{"is_flushed"}B= not $self->{"CM"}
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | Carp::confess "This event was already flushed!"; | |||||||||||||||||||||||||||||||||||||||||
| 316 | # $self->dispose if $self->{CM}; # TODO is this a good idea? | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | return unless $self->__respondable( 'flush' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | $self->{is_flushed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | DEBUG and xdebug "$self->flush"; | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | # TODO don't do this in case of error | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | $self->{CM}->response( $self->{response} ); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 330 | sub wrapped_error | ||||||||||||||||||||||||||||||||||||||||||
| 331 | { | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | ▶ | my( $self, $err ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wrapped_error: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | local $POE::XUL::Logging::SINGLETON->{app} = $self->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | DEBUG and xdebug "wrapped_error via $self->{CM} ($err)"; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | ▶ | unless( $self->{CM} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | xlog "No CM for error response: ", Dumper $err; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | $self->{CM}->error_response( $self->{response}, $err ); | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 344 | sub data_response | ||||||||||||||||||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | my( $self, $data ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_response: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | local $POE::XUL::Logging::SINGLETON->{app} = $self->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $self->{CM}->data_response( $self->{response}, $data ); | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 352 | sub dispose | ||||||||||||||||||||||||||||||||||||||||||
| 353 | { | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispose: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | $self->{is_flushed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | delete $self->{CM}; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | delete $self->{response}; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | DEBUG and xdebug "$self->dispose"; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||