ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/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

# User Rev Content
1 elmex 1.1 package Net::XMPP2::Namespaces;
2     use warnings;
3     use strict;
4     require Exporter;
5 elmex 1.10 our @EXPORT_OK = qw/xmpp_ns set_xmpp_ns_alias xmpp_ns_maybe/;
6 elmex 1.1 our @ISA = qw/Exporter/;
7    
8     our %NAMESPACES = (
9 elmex 1.6 client => 'jabber:client',
10 elmex 1.12 component => 'jabber:component:accept',
11 elmex 1.6 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 elmex 1.11 register => 'jabber:iq:register',
19 elmex 1.6 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 elmex 1.11 register_f => 'http://jabber.org/features/iq-register',
25 elmex 1.7 iqauth => 'http://jabber.org/features/iq-auth',
26 elmex 1.10 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 elmex 1.1 );
32    
33     =head1 NAME
34    
35 elmex 1.9 Net::XMPP2::Namespaces - XMPP namespace collection and aliasing class
36 elmex 1.1
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 elmex 1.2 tls => urn:ietf:params:xml:ns:xmpp-tls
64 elmex 1.1
65     client => jabber:client
66     roster => jabber:iq:roster
67     version => jabber:iq:version
68    
69 elmex 1.8 disco_info => http://jabber.org/protocol/disco#info
70     disco_items => http://jabber.org/protocol/disco#items
71    
72 elmex 1.10 register => http://jabber.org/features/iq-register
73     iqauth => http://jabber.org/features/iq-auth
74     data_form => jabber:x:data
75 elmex 1.5
76 elmex 1.1 =head1 FUNCTIONS
77    
78 elmex 1.8 =over 4
79    
80     =item B<xmpp_ns ($alias)>
81 elmex 1.1
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 elmex 1.10
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 elmex 1.8 =item B<set_xmpp_ns_alias ($alias, $namespace_uri)>
104 elmex 1.1
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 elmex 1.8 =back
112    
113 elmex 1.1 =head1 AUTHOR
114    
115 elmex 1.8 Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
116 elmex 1.1
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