ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-XMPP2/lib/Net/XMPP2/Namespaces.pm
Revision: 1.11
Committed: Thu Jul 19 11:36:33 2007 UTC (19 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.10: +2 -1 lines
Log Message:
added initial_presence argument to the IM::Connection and the
Client. added and upgraded some examples. further work on the
registration forms.

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