ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-XMPP2/lib/Net/XMPP2/Namespaces.pm
Revision: 1.10
Committed: Fri Jul 6 22:22:21 2007 UTC (19 years, 3 months ago) by elmex
Branch: MAIN
Changes since 1.9: +24 -3 lines
Log Message:
implemented dataforms - phew! that was a bullet of work

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