line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::XMPP::IM::Delayed; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
66
|
use AnyEvent::XMPP::Util; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use AnyEvent::XMPP::IM::Message; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
AnyEvent::XMPP::IM::Delayed - A delayed "XML" stanza |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This module handles the delayed fields of stanzas and is a superclass of |
15
|
|
|
|
|
|
|
L and L. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=over 4 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=item B |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The constructor takes no arguments and makes just a new object of this class. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
|
|
|
|
|
|
my $this = shift; |
29
|
|
|
|
|
|
|
my $class = ref($this) || $this; |
30
|
|
|
|
|
|
|
bless { @_ }, $class |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item B |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Returns the L object for this stream error. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub xml_node { |
40
|
|
|
|
|
|
|
$_[0]->{node} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item B |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
C<$node> must be a L. This method will try to |
47
|
|
|
|
|
|
|
fetch the delay information from the C<$node>. It will look in the lists |
48
|
|
|
|
|
|
|
of child nodes for the delay elements and set it's values from there. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub fetch_delay_from_node { |
53
|
|
|
|
|
|
|
my ($self, $node) = @_; |
54
|
|
|
|
|
|
|
my ($delay) = $node->find_all ([qw/x_delay x/]); |
55
|
|
|
|
|
|
|
my ($newdelay) = $node->find_all ([qw/delay delay/]); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$delay = $newdelay if $newdelay; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if ($delay) { |
60
|
|
|
|
|
|
|
$self->{delay}->{from} = $delay->attr ('from'); |
61
|
|
|
|
|
|
|
$self->{delay}->{stamp} = $delay->attr ('stamp'); |
62
|
|
|
|
|
|
|
$self->{delay}->{reason} = $delay->text; |
63
|
|
|
|
|
|
|
} else { |
64
|
|
|
|
|
|
|
delete $self->{delay} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item B |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This method returns either the original source of a maybe delayed |
71
|
|
|
|
|
|
|
stanza. It's the JID of the original entity that sent the stanza. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This method returns undef if this stanza was not delayed. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
And this method returns undef if this stanza had no details about |
76
|
|
|
|
|
|
|
who sent the message in the first place. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
To find out whether this stanza was delayed use the C |
79
|
|
|
|
|
|
|
method. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub delay_from { |
84
|
|
|
|
|
|
|
my ($self) = @_; |
85
|
|
|
|
|
|
|
return unless exists $self->{delay}; |
86
|
|
|
|
|
|
|
$self->{delay}->{from} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item B |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This method returns the timestamp in XMPP format which can be fed |
92
|
|
|
|
|
|
|
to the C function documented in L. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
(Please note that this might be a newstyle XEP-0087 timestamp or |
95
|
|
|
|
|
|
|
old style legacy timestamp) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
If the stanza was not delayed this method returns undef. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub delay_stamp { |
102
|
|
|
|
|
|
|
my ($self) = @_; |
103
|
|
|
|
|
|
|
return unless exists $self->{delay}; |
104
|
|
|
|
|
|
|
$self->{delay}->{stamp} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item B |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This method might return a human readable string containing the reason |
110
|
|
|
|
|
|
|
why the stanza was delayed. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Will be undef if stanza contained no delay. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub delay_reason { |
117
|
|
|
|
|
|
|
my ($self) = @_; |
118
|
|
|
|
|
|
|
return unless exists $self->{delay}; |
119
|
|
|
|
|
|
|
$self->{delay}->{reason} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item B |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
If this method returns a true value then this stanza was delayed. |
125
|
|
|
|
|
|
|
Otherwise it returns undef. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub is_delayed { |
130
|
|
|
|
|
|
|
my ($self) = @_; |
131
|
|
|
|
|
|
|
$self->{delay} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 AUTHOR |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Robin Redeker, C<< >>, JID: C<< >> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Copyright 2007, 2008 Robin Redeker, all rights reserved. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
145
|
|
|
|
|
|
|
under the same terms as Perl itself. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |