ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-XMPP2/lib/Net/XMPP2/Namespaces.pm
Revision: 1.12
Committed: Fri Jul 20 20:41:48 2007 UTC (19 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.11: +1 -0 lines
Log Message:
lots of changes. added as_string to Net::XMPP2::Node to restore
the original xml document part of a stanza or subtree.
also implemented the jabber component protocol.

File Contents

# Content
1 package Net::XMPP2::Namespaces;
2 use warnings;
3 use strict;
4 require Exporter;
5 our @EXPORT_OK = qw/xmpp_ns set_xmpp_ns_alias xmpp_ns_maybe/;
6 our @ISA = qw/Exporter/;
7
8 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 session => 'urn:ietf:params:xml:ns:xmpp-session',
21 xml => 'http://www.w3.org/XML/1998/namespace',
22 disco_info => 'http://jabber.org/protocol/disco#info',
23 disco_items => 'http://jabber.org/protocol/disco#items',
24 register_f => 'http://jabber.org/features/iq-register',
25 iqauth => 'http://jabber.org/features/iq-auth',
26 data_form => 'jabber:x:data',
27 muc => 'http://jabber.org/protocol/muc',
28 muc_user => 'http://jabber.org/protocol/muc#user',
29 muc_owner => 'http://jabber.org/protocol/muc#owner',
30 search => 'jabber:iq:search',
31 );
32
33 =head1 NAME
34
35 Net::XMPP2::Namespaces - XMPP namespace collection and aliasing class
36
37 =head1 SYNOPSIS
38
39 use Net::XMPP2::Namespaces qw/xmpp_ns set_xmpp_ns_alias/;
40
41 set_xmpp_ns_alias (stanzas => 'urn:ietf:params:xml:ns:xmpp-stanzas');
42 $node->find_all ($p, [xmpp_ns ('stanzas'), 'iq']);
43
44 =head1 DESCRIPTION
45
46 This module represents a simple namespaces aliasing mechanism to ease handling
47 of namespaces when traversing Net::XMPP2::Node objects and writing XML
48 with Net::XMPP2::Writer.
49
50 =head1 XMPP NAMESPACES
51
52 There are already some aliases defined for the XMPP XML namespaces
53 which make handling of namepsaces a bit easier:
54
55 stream => http://etherx.jabber.org/streams
56 xml => http://www.w3.org/XML/1998/namespace
57
58 streams => urn:ietf:params:xml:ns:xmpp-streams
59 session => urn:ietf:params:xml:ns:xmpp-session
60 stanzas => urn:ietf:params:xml:ns:xmpp-stanzas
61 sasl => urn:ietf:params:xml:ns:xmpp-sasl
62 bind => urn:ietf:params:xml:ns:xmpp-bind
63 tls => urn:ietf:params:xml:ns:xmpp-tls
64
65 client => jabber:client
66 roster => jabber:iq:roster
67 version => jabber:iq:version
68
69 disco_info => http://jabber.org/protocol/disco#info
70 disco_items => http://jabber.org/protocol/disco#items
71
72 register => http://jabber.org/features/iq-register
73 iqauth => http://jabber.org/features/iq-auth
74 data_form => jabber:x:data
75
76 =head1 FUNCTIONS
77
78 =over 4
79
80 =item B<xmpp_ns ($alias)>
81
82 Returns am uri for the registered C<$alias> or undef if none exists.
83
84 =cut
85
86 sub xmpp_ns { return $NAMESPACES{$_[0]} }
87
88
89 =item B<xmpp_ns_maybe ($alias_or_namespace_uri)>
90
91 This method tries to find whether there is a alias C<$alias_or_namespace_uri>
92 registered and if not it returns C<$alias_or_namespace_uri>.
93
94 =cut
95
96 sub xmpp_ns_maybe {
97 my ($alias) = @_;
98 return unless defined $alias;
99 my $n = xmpp_ns ($alias);
100 $n ? $n : $alias
101 }
102
103 =item B<set_xmpp_ns_alias ($alias, $namespace_uri)>
104
105 Sets an C<$alias> for the C<$namespace_uri>.
106
107 =cut
108
109 sub set_xmpp_ns_alias { return $NAMESPACES{$_[0]} }
110
111 =back
112
113 =head1 AUTHOR
114
115 Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
116
117 =head1 COPYRIGHT & LICENSE
118
119 Copyright 2007 Robin Redeker, all rights reserved.
120
121 This program is free software; you can redistribute it and/or modify it
122 under the same terms as Perl itself.
123
124 =cut
125
126 1; # End of Net::XMPP2