line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::XUL::Application; |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# Copyright Philip Gwyn 2007-2010. All rights reserved. |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1527
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
7
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
84
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.0601'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use POE; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
12
|
1
|
|
|
1
|
|
358
|
use POE::Component::XUL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
13
|
1
|
|
|
1
|
|
6
|
use POE::XUL::Logging; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
83
|
|
14
|
1
|
|
|
1
|
|
417
|
use POE::XUL::Session; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
16
|
|
15
|
1
|
|
|
1
|
|
93
|
use constant DEBUG => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
93
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
4
|
use vars qw( $window $server ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
407
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require Exporter; |
20
|
|
|
|
|
|
|
our @ISA = qw( Exporter ); |
21
|
|
|
|
|
|
|
our @EXPORT = qw( window server ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
################################################################ |
24
|
0
|
|
|
0
|
1
|
0
|
sub window () { return $window; } |
25
|
0
|
|
|
0
|
1
|
0
|
sub server () { return $server; } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
################################################################ |
28
|
|
|
|
|
|
|
sub create_server |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
|
|
0
|
0
|
0
|
my( $package, $name ) = @_; |
31
|
0
|
|
|
|
|
0
|
POE::Component::XUL->spawn( { |
32
|
|
|
|
|
|
|
apps => { |
33
|
|
|
|
|
|
|
$name => $package |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} ); |
36
|
0
|
|
|
|
|
0
|
$poe_kernel->run; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
################################################################ |
40
|
|
|
|
|
|
|
sub spawn |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
0
|
0
|
0
|
my( $self, $event ) = @_; |
43
|
0
|
0
|
|
|
|
0
|
$self = $self->new unless ref $self; |
44
|
0
|
|
|
|
|
0
|
$self->SID( $event->SID ); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
POE::XUL::Session->create( $self ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
################################################################ |
50
|
|
|
|
|
|
|
sub new |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
0
|
0
|
0
|
my( $package ) = @_; |
53
|
0
|
|
|
|
|
0
|
return bless {}, $package; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
################################################################ |
57
|
|
|
|
|
|
|
sub connect |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
1
|
0
|
my( $self, $event ) = @_; |
60
|
0
|
|
|
|
|
0
|
die "You must overload ", ref( $self ), "->connect"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
################################################################ |
64
|
|
|
|
|
|
|
sub __mk_accessor |
65
|
|
|
|
|
|
|
{ |
66
|
2
|
|
|
2
|
|
2
|
my( $name ) = @_; |
67
|
|
|
|
|
|
|
return sub { |
68
|
0
|
|
|
0
|
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my $rv = $self->{$name}; |
70
|
0
|
0
|
|
|
|
|
$self->{$name} = $_[0] if @_; |
71
|
0
|
|
|
|
|
|
return $rv; |
72
|
2
|
|
|
|
|
8
|
}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
*SID = __mk_accessor( 'SID' ); |
76
|
|
|
|
|
|
|
*name = __mk_accessor( 'name' ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
################################################################ |
79
|
|
|
|
|
|
|
sub createHandler |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
|
0
|
1
|
|
my( $self, $name, $what ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
croak "Unable to createHandler outside of a POE::XUL::Application" |
84
|
|
|
|
|
|
|
unless $server; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# TODO: Make sure current_session is our session! |
87
|
0
|
0
|
0
|
|
|
|
if( $what and ref $what ) { |
88
|
0
|
|
|
|
|
|
$poe_kernel->state( $name, $what ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else { |
91
|
0
|
|
|
|
|
|
$poe_kernel->state( $name, $self, $what ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
################################################################ |
96
|
|
|
|
|
|
|
sub removeHandler |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
0
|
1
|
|
my( $self, $name ) = @_; |
99
|
|
|
|
|
|
|
# TODO: Make sure current_session is our session! |
100
|
0
|
|
|
|
|
|
$poe_kernel->state( $name ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |