line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::YMSG::Buddy; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use constant IM_AVAILABLE => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
5
|
1
|
|
|
1
|
|
5
|
use constant BE_RIGHT_BACK => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
6
|
1
|
|
|
1
|
|
5
|
use constant BUSY => 2; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
55
|
|
7
|
1
|
|
|
1
|
|
5
|
use constant NOT_AT_HOME => 3; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
8
|
1
|
|
|
1
|
|
5
|
use constant NOT_AT_MY_DESK => 4; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
9
|
1
|
|
|
1
|
|
5
|
use constant NOT_IN_THE_OFFICE => 5; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
10
|
1
|
|
|
1
|
|
5
|
use constant ON_THE_PHONE => 6; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
11
|
1
|
|
|
1
|
|
4
|
use constant ON_VACATION => 7; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
12
|
1
|
|
|
1
|
|
5
|
use constant OUT_TO_LUNCH => 8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
13
|
1
|
|
|
1
|
|
5
|
use constant STEPPED_OUT => 9; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
14
|
1
|
|
|
1
|
|
4
|
use constant CUSTOM_STATUS => 99; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
15
|
1
|
|
|
1
|
|
5
|
use constant SLEEP => 999; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
13
|
use constant ICON_AVAILABLE => 0; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
18
|
1
|
|
|
1
|
|
4
|
use constant ICON_BUSY => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
19
|
1
|
|
|
1
|
|
5
|
use constant ICON_SLEEP => 2; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
50
|
use constant STATUS_MESSAGE => [ |
22
|
|
|
|
|
|
|
"I'm Available", |
23
|
|
|
|
|
|
|
'Be Right Back', |
24
|
|
|
|
|
|
|
'Busy', |
25
|
|
|
|
|
|
|
'Not At Home', |
26
|
|
|
|
|
|
|
'Not At My Desk', |
27
|
|
|
|
|
|
|
'Not In The Office', |
28
|
|
|
|
|
|
|
'On The Phone', |
29
|
|
|
|
|
|
|
'On Vacation', |
30
|
|
|
|
|
|
|
'Out To Lunch', |
31
|
|
|
|
|
|
|
'Stepped Out', |
32
|
1
|
|
|
1
|
|
5
|
]; |
|
1
|
|
|
|
|
2
|
|
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
4
|
use constant IS_ONLINE => 1; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
35
|
1
|
|
|
1
|
|
5
|
use constant IS_OFFLINE => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1528
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new |
38
|
|
|
|
|
|
|
{ |
39
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
40
|
0
|
|
|
|
|
|
bless { |
41
|
|
|
|
|
|
|
name => 'nobody', |
42
|
|
|
|
|
|
|
status => IM_AVAILABLE, |
43
|
|
|
|
|
|
|
custom_status => '', |
44
|
|
|
|
|
|
|
busy => ICON_AVAILABLE, |
45
|
|
|
|
|
|
|
online => IS_OFFLINE, |
46
|
|
|
|
|
|
|
session_id => 0, |
47
|
|
|
|
|
|
|
}, $class; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub name |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
54
|
0
|
0
|
|
|
|
|
$self->{name} = shift if @_; |
55
|
0
|
|
|
|
|
|
$self->{name}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub status |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
62
|
0
|
0
|
|
|
|
|
if (@_) { |
63
|
0
|
|
|
|
|
|
$self->{status} = shift; |
64
|
0
|
0
|
|
|
|
|
$self->busy(ICON_BUSY) if $self->{status} <= STEPPED_OUT; |
65
|
0
|
0
|
|
|
|
|
$self->busy(ICON_SLEEP) if $self->{status} == SLEEP; |
66
|
0
|
0
|
0
|
|
|
|
$self->busy(ICON_AVAILABLE) if $self->{status} == CUSTOM_STATUS |
67
|
|
|
|
|
|
|
|| $self->{status} == IM_AVAILABLE; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
$self->{status}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub custom_status |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
0
|
|
|
|
|
if (@_) { |
77
|
0
|
|
|
|
|
|
$self->{custom_status} = shift; |
78
|
0
|
|
|
|
|
|
$self->status(CUSTOM_STATUS); |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
$self->{custom_status}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub busy |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
87
|
0
|
0
|
|
|
|
|
if (@_) { |
88
|
0
|
|
|
|
|
|
$self->{busy} = shift; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
|
$self->{busy}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub online |
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
97
|
0
|
0
|
|
|
|
|
if (@_) { |
98
|
0
|
|
|
|
|
|
$self->{online} = shift; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
$self->{online}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub session_id |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
107
|
0
|
0
|
|
|
|
|
$self->{session_id} = shift if @_; |
108
|
0
|
|
|
|
|
|
$self->{session_id}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub is_online |
113
|
|
|
|
|
|
|
{ |
114
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
115
|
0
|
|
|
|
|
|
$self->online; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub get_status_message |
120
|
|
|
|
|
|
|
{ |
121
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
122
|
0
|
0
|
|
|
|
|
return unless $self->is_online; |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
0
|
|
|
|
if ($self->status == SLEEP) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
return sprintf '%s', |
126
|
|
|
|
|
|
|
'Sleep'; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
elsif ($self->status == CUSTOM_STATUS) { |
129
|
0
|
|
|
|
|
|
return sprintf '%s', |
130
|
|
|
|
|
|
|
$self->custom_status; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
elsif ($self->status >= IM_AVAILABLE && $self->status <= STEPPED_OUT) { |
133
|
0
|
|
|
|
|
|
return sprintf '%s', |
134
|
|
|
|
|
|
|
STATUS_MESSAGE->[$self->status]; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
0
|
|
|
|
|
|
return 'Unknown'; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub to_string |
144
|
|
|
|
|
|
|
{ |
145
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
146
|
0
|
0
|
|
|
|
|
if ($self->is_online) { |
147
|
0
|
0
|
|
|
|
|
return sprintf "%s %s (%s)", |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$self->busy == ICON_AVAILABLE ? ':->' |
149
|
|
|
|
|
|
|
: $self->busy == ICON_BUSY ? ':-@' |
150
|
|
|
|
|
|
|
: $self->busy == ICON_SLEEP ? ':-Z' |
151
|
|
|
|
|
|
|
: '?', |
152
|
|
|
|
|
|
|
$self->name, |
153
|
|
|
|
|
|
|
$self->get_status_message; |
154
|
|
|
|
|
|
|
} else { |
155
|
0
|
|
|
|
|
|
return sprintf "%s %s (%s)", |
156
|
|
|
|
|
|
|
' ', |
157
|
|
|
|
|
|
|
$self->name, |
158
|
|
|
|
|
|
|
'Not online'; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub to_string_curses |
163
|
|
|
|
|
|
|
{ |
164
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
165
|
0
|
0
|
|
|
|
|
if ($self->is_online) { |
166
|
0
|
|
|
|
|
|
return sprintf "[%s]", |
167
|
|
|
|
|
|
|
$self->name; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
1; |
171
|
|
|
|
|
|
|
__END__ |