| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# =========================================================================== |
|
2
|
|
|
|
|
|
|
# POE::Component::Growl - version 1.00 - 31 Jul 2005 |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Growl notification dispatcher for POE |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Author: Alessandro Ranellucci |
|
7
|
|
|
|
|
|
|
# Copyright (c) 2005 - All Rights Reserved. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# See below for documentation. |
|
10
|
|
|
|
|
|
|
#Ê |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package POE::Component::Growl; |
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
28813
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
45
|
|
|
15
|
1
|
|
|
1
|
|
7
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
152
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
7
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
83
|
|
|
18
|
1
|
|
|
1
|
|
537
|
use Mac::Growl ':all'; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use POE; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$VERSION = '1.00'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# object fields ("SF" stands for "self") |
|
24
|
|
|
|
|
|
|
sub SF_ALIAS () { 0 } |
|
25
|
|
|
|
|
|
|
sub SF_APPNAME () { 1 } |
|
26
|
|
|
|
|
|
|
sub SF_NOTIF () { 2 } |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub spawn { |
|
29
|
|
|
|
|
|
|
my $type = shift; |
|
30
|
|
|
|
|
|
|
croak "$type requires an even number of parameters" if @_ % 2; |
|
31
|
|
|
|
|
|
|
my %params = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# let's check params |
|
34
|
|
|
|
|
|
|
my $alias = delete $params{Alias} || 'Growl'; |
|
35
|
|
|
|
|
|
|
my $appname = delete $params{AppName} || croak("Missing AppName parameter"); |
|
36
|
|
|
|
|
|
|
my $notif = delete $params{Notifications} || croak("Missing Notifications parameter"); |
|
37
|
|
|
|
|
|
|
my $defaultnotif = delete $params{DefaultNotifications} || $notif; |
|
38
|
|
|
|
|
|
|
my $icon = delete $params{IconOfApp} || undef; |
|
39
|
|
|
|
|
|
|
croak("Unknown parameters: ", join(', ', sort keys %params)) |
|
40
|
|
|
|
|
|
|
if scalar keys %params; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# register our app with Mac::Growl |
|
43
|
|
|
|
|
|
|
RegisterNotifications($appname, $notif, $defaultnotif, $icon); |
|
44
|
|
|
|
|
|
|
my $self = bless [ |
|
45
|
|
|
|
|
|
|
$alias, |
|
46
|
|
|
|
|
|
|
$appname, |
|
47
|
|
|
|
|
|
|
$notif |
|
48
|
|
|
|
|
|
|
], $type; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# register session with POE |
|
51
|
|
|
|
|
|
|
POE::Session->create( |
|
52
|
|
|
|
|
|
|
object_states => [ |
|
53
|
|
|
|
|
|
|
$self => { |
|
54
|
|
|
|
|
|
|
_start => '_start', |
|
55
|
|
|
|
|
|
|
post => 'post' |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
] |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return $self; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _start { |
|
64
|
|
|
|
|
|
|
my ($object, $kernel) = @_[OBJECT, KERNEL]; |
|
65
|
|
|
|
|
|
|
$kernel->alias_set( $object->[SF_ALIAS] ); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub post { |
|
69
|
|
|
|
|
|
|
my ($object, $kernel, $not) = @_[OBJECT, KERNEL, ARG0]; |
|
70
|
|
|
|
|
|
|
$object->notify($not); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub notify { |
|
74
|
|
|
|
|
|
|
my ($self, $not) = @_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
&PostNotification( |
|
77
|
|
|
|
|
|
|
$self->[SF_APPNAME], |
|
78
|
|
|
|
|
|
|
@$not{ qw/name title descr/ }, |
|
79
|
|
|
|
|
|
|
map { $not->{$_} || 0 } qw/sticky priority/, |
|
80
|
|
|
|
|
|
|
$not->{imagepath} |
|
81
|
|
|
|
|
|
|
); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |