| 1 | package AnyEvent::XMPP::Namespaces; | ||||||||||
| 2 | 21 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 21 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 21 | require Exporter; | |||||||||
| 5 | 21 | our @EXPORT_OK = qw/xmpp_ns set_xmpp_ns_alias xmpp_ns_maybe/; | |||||||||
| 6 | 21 | our @ISA = qw/Exporter/; | |||||||||
| 7 | |||||||||||
| 8 | 21 | our %NAMESPACES = ( | |||||||||
| 9 | client => 'jabber:client', | ||||||||||
| 10 | component => 'jabber:component:accept', | ||||||||||
| 11 | stream => 'http://etherx.jabber.org/streams', | ||||||||||
| 12 | streams => 'urn:ietf:params:xml:ns:xmpp-streams', | ||||||||||
| 13 | stanzas => 'urn:ietf:params:xml:ns:xmpp-stanzas', | ||||||||||
| 14 | sasl => 'urn:ietf:params:xml:ns:xmpp-sasl', | ||||||||||
| 15 | bind => 'urn:ietf:params:xml:ns:xmpp-bind', | ||||||||||
| 16 | tls => 'urn:ietf:params:xml:ns:xmpp-tls', | ||||||||||
| 17 | roster => 'jabber:iq:roster', | ||||||||||
| 18 | register => 'jabber:iq:register', | ||||||||||
| 19 | version => 'jabber:iq:version', | ||||||||||
| 20 | auth => 'jabber:iq:auth', | ||||||||||
| 21 | session => 'urn:ietf:params:xml:ns:xmpp-session', | ||||||||||
| 22 | xml => 'http://www.w3.org/XML/1998/namespace', | ||||||||||
| 23 | disco_info => 'http://jabber.org/protocol/disco#info', | ||||||||||
| 24 | disco_items => 'http://jabber.org/protocol/disco#items', | ||||||||||
| 25 | register_f => 'http://jabber.org/features/iq-register', | ||||||||||
| 26 | iqauth => 'http://jabber.org/features/iq-auth', | ||||||||||
| 27 | data_form => 'jabber:x:data', | ||||||||||
| 28 | iq_oob => 'jabber:iq:oob', | ||||||||||
| 29 | x_oob => 'jabber:x:oob', | ||||||||||
| 30 | muc => 'http://jabber.org/protocol/muc', | ||||||||||
| 31 | muc_user => 'http://jabber.org/protocol/muc#user', | ||||||||||
| 32 | muc_owner => 'http://jabber.org/protocol/muc#owner', | ||||||||||
| 33 | search => 'jabber:iq:search', | ||||||||||
| 34 | x_delay => 'jabber:x:delay', | ||||||||||
| 35 | delay => 'urn:xmpp:delay', | ||||||||||
| 36 | ping => 'urn:xmpp:ping', | ||||||||||
| 37 | |||||||||||
| 38 | vcard => 'vcard-temp', | ||||||||||
| 39 | vcard_upd => 'vcard-temp:x:update', | ||||||||||
| 40 | |||||||||||
| 41 | pubsub => 'http://jabber.org/protocol/pubsub', | ||||||||||
| 42 | pubsub_own => 'http://jabber.org/protocol/pubsub#owner', | ||||||||||
| 43 | pubsub_ev => 'http://jabber.org/protocol/pubsub#event', | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | =head1 NAME | ||||||||||
| 47 | |||||||||||
| 48 | AnyEvent::XMPP::Namespaces - XMPP namespace collection and aliasing class | ||||||||||
| 49 | |||||||||||
| 50 | =head1 SYNOPSIS | ||||||||||
| 51 | |||||||||||
| 52 | use AnyEvent::XMPP::Namespaces qw/xmpp_ns set_xmpp_ns_alias/; | ||||||||||
| 53 | |||||||||||
| 54 | set_xmpp_ns_alias (stanzas => 'urn:ietf:params:xml:ns:xmpp-stanzas'); | ||||||||||
| 55 | |||||||||||
| 56 | =head1 DESCRIPTION | ||||||||||
| 57 | |||||||||||
| 58 | This module represents a simple namespaces aliasing mechanism to ease handling | ||||||||||
| 59 | of namespaces when traversing AnyEvent::XMPP::Node objects and writing XML | ||||||||||
| 60 | with AnyEvent::XMPP::Writer. | ||||||||||
| 61 | |||||||||||
| 62 | =head1 XMPP NAMESPACES | ||||||||||
| 63 | |||||||||||
| 64 | There are already some aliases defined for the XMPP XML namespaces | ||||||||||
| 65 | which make handling of namepsaces a bit easier: | ||||||||||
| 66 | |||||||||||
| 67 | stream => http://etherx.jabber.org/streams | ||||||||||
| 68 | xml => http://www.w3.org/XML/1998/namespace | ||||||||||
| 69 | |||||||||||
| 70 | streams => urn:ietf:params:xml:ns:xmpp-streams | ||||||||||
| 71 | session => urn:ietf:params:xml:ns:xmpp-session | ||||||||||
| 72 | stanzas => urn:ietf:params:xml:ns:xmpp-stanzas | ||||||||||
| 73 | sasl => urn:ietf:params:xml:ns:xmpp-sasl | ||||||||||
| 74 | bind => urn:ietf:params:xml:ns:xmpp-bind | ||||||||||
| 75 | tls => urn:ietf:params:xml:ns:xmpp-tls | ||||||||||
| 76 | |||||||||||
| 77 | client => jabber:client | ||||||||||
| 78 | roster => jabber:iq:roster | ||||||||||
| 79 | version => jabber:iq:version | ||||||||||
| 80 | auth => jabber:iq:auth | ||||||||||
| 81 | |||||||||||
| 82 | iq_oob => jabber:iq:oob | ||||||||||
| 83 | x_oob => jabber:x:oob | ||||||||||
| 84 | |||||||||||
| 85 | disco_info => http://jabber.org/protocol/disco#info | ||||||||||
| 86 | disco_items => http://jabber.org/protocol/disco#items | ||||||||||
| 87 | |||||||||||
| 88 | register => http://jabber.org/features/iq-register | ||||||||||
| 89 | iqauth => http://jabber.org/features/iq-auth | ||||||||||
| 90 | data_form => jabber:x:data | ||||||||||
| 91 | |||||||||||
| 92 | ping => urn:xmpp:ping | ||||||||||
| 93 | |||||||||||
| 94 | vcard => vcard-temp | ||||||||||
| 95 | |||||||||||
| 96 | pubsub => http://jabber.org/protocol/pubsub | ||||||||||
| 97 | pubsub_own => http://jabber.org/protocol/pubsub#owner | ||||||||||
| 98 | pubsub_ev => http://jabber.org/protocol/pubsub#event | ||||||||||
| 99 | |||||||||||
| 100 | =head1 FUNCTIONS | ||||||||||
| 101 | |||||||||||
| 102 | =over 4 | ||||||||||
| 103 | |||||||||||
| 104 | =item B<xmpp_ns ($alias)> | ||||||||||
| 105 | |||||||||||
| 106 | Returns am uri for the registered C<$alias> or undef if none exists. | ||||||||||
| 107 | |||||||||||
| 108 | =cut | ||||||||||
| 109 | |||||||||||
| 110 | 0 | ▶ | sub xmpp_ns { return $NAMESPACES{$_[0]} } | ||||||||
|
Subroutine
xmpp_ns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 111 | |||||||||||
| 112 | |||||||||||
| 113 | =item B<xmpp_ns_maybe ($alias_or_namespace_uri)> | ||||||||||
| 114 | |||||||||||
| 115 | This method tries to find whether there is a alias C<$alias_or_namespace_uri> | ||||||||||
| 116 | registered and if not it returns C<$alias_or_namespace_uri>. | ||||||||||
| 117 | |||||||||||
| 118 | =cut | ||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub xmpp_ns_maybe { | ||||||||
|
Subroutine
xmpp_ns_maybe: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 121 | 0 | my ($alias) = @_; | |||||||||
| 122 | 0 | ▶ | return unless defined $alias; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 123 | 0 | my $n = xmpp_ns ($alias); | |||||||||
| 124 | 0 | ▶ | $n ? $n : $alias | ||||||||
|
Branch: 1 branch
| |||||||||||
| 125 | } | ||||||||||
| 126 | |||||||||||
| 127 | =item B<set_xmpp_ns_alias ($alias, $namespace_uri)> | ||||||||||
| 128 | |||||||||||
| 129 | Sets an C<$alias> for the C<$namespace_uri>. | ||||||||||
| 130 | |||||||||||
| 131 | =cut | ||||||||||
| 132 | |||||||||||
| 133 | 0 | ▶ | sub set_xmpp_ns_alias { $NAMESPACES{$_[0]} = $_[1] } | ||||||||
|
Subroutine
set_xmpp_ns_alias: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 134 | |||||||||||
| 135 | =back | ||||||||||
| 136 | |||||||||||
| 137 | =head1 AUTHOR | ||||||||||
| 138 | |||||||||||
| 139 | Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >> | ||||||||||
| 140 | |||||||||||
| 141 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 142 | |||||||||||
| 143 | Copyright 2007, 2008 Robin Redeker, all rights reserved. | ||||||||||
| 144 | |||||||||||
| 145 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 146 | under the same terms as Perl itself. | ||||||||||
| 147 | |||||||||||
| 148 | =cut | ||||||||||
| 149 | |||||||||||
| 150 | 21 | 1; # End of AnyEvent::XMPP | |||||||||