| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package AnyEvent::XMPP::Ext::HTML; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$AnyEvent::XMPP::Ext::HTML::VERSION = '0.02'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: XEP-0071: XHTML-IM (Version 1.5) for AnyEvent::XMPP |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
51142
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
48
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
43
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1400
|
use AnyEvent::XMPP::Ext; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use AnyEvent::XMPP::Namespaces qw/set_xmpp_ns_alias xmpp_ns/; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw/AnyEvent::XMPP::Ext/; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
|
|
|
|
|
|
my $this = shift; |
|
18
|
|
|
|
|
|
|
my $class = ref($this) || $this; |
|
19
|
|
|
|
|
|
|
my $self = bless { @_ }, $class; |
|
20
|
|
|
|
|
|
|
$self->init; |
|
21
|
|
|
|
|
|
|
$self; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub init { |
|
26
|
|
|
|
|
|
|
my $self = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
set_xmpp_ns_alias(xhtml_im => 'http://jabber.org/protocol/xhtml-im'); |
|
29
|
|
|
|
|
|
|
set_xmpp_ns_alias(xhtml => 'http://www.w3.org/1999/xhtml'); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->{disco}->enable_feature($self->disco_feature) if defined $self->{disco}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$self->{cb_id} = $self->reg_cb( |
|
34
|
|
|
|
|
|
|
send_message_hook => sub { |
|
35
|
|
|
|
|
|
|
my ($self, $con, $id, $to, $type, $attrs, $create_cb) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return unless exists $attrs->{html}; |
|
38
|
|
|
|
|
|
|
my $html = delete $attrs->{html}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
push @$create_cb, sub { |
|
41
|
|
|
|
|
|
|
my ($w) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$w->addPrefix(xmpp_ns('xhtml_im'), ''); |
|
44
|
|
|
|
|
|
|
$w->startTag([xmpp_ns('xhtml_im'), 'html']); |
|
45
|
|
|
|
|
|
|
if (ref($html) eq 'HASH') { |
|
46
|
|
|
|
|
|
|
for (keys %$html) { |
|
47
|
|
|
|
|
|
|
$w->addPrefix(xmpp_ns('xhtml'), ''); |
|
48
|
|
|
|
|
|
|
$w->startTag([xmpp_ns('xhtml'), 'body'], ($_ ne '' ? ([xmpp_ns('xml'), 'lang'] => $_) : ())); |
|
49
|
|
|
|
|
|
|
$w->raw($html->{$_}); |
|
50
|
|
|
|
|
|
|
$w->endTag; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} else { |
|
53
|
|
|
|
|
|
|
$w->addPrefix(xmpp_ns('xhtml'), ''); |
|
54
|
|
|
|
|
|
|
$w->startTag([xmpp_ns('xhtml'), 'body']); |
|
55
|
|
|
|
|
|
|
$w->raw($html); |
|
56
|
|
|
|
|
|
|
$w->endTag; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
$w->endTag; |
|
59
|
|
|
|
|
|
|
}; |
|
60
|
|
|
|
|
|
|
}, |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub disco_feature { |
|
65
|
|
|
|
|
|
|
xmpp_ns('xhtml_im'); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub DESTROY { |
|
69
|
|
|
|
|
|
|
my $self = shift; |
|
70
|
|
|
|
|
|
|
$self->unreg_cb($self->{cb_id}); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |