1Net::XMPP::IQ(3)      User Contributed Perl Documentation     Net::XMPP::IQ(3)
2
3
4

NAME

6       Net::XMPP::IQ - XMPP Info/Query Module
7

SYNOPSIS

9         Net::XMPP::IQ is a companion to the Net::XMPP module. It
10         provides the user a simple interface to set and retrieve all
11         parts of an XMPP IQ.
12

DESCRIPTION

14         Net::XMPP::IQ differs from the other Net::XMPP::* modules in that
15         the XMLNS of the query is split out into a submodule under
16         IQ.  For specifics on each module please view the documentation
17         for the Net::XMPP::Namespaces module.
18
19         A Net::XMPP::IQ object is passed to the callback function for the
20         message.  Also, the first argument to the callback functions is the
21         session ID from XML::Stream.  There are some cases where you might
22         want this information, like if you created a Client that connects to
23         two servers at once, or for writing a mini server.
24
25           use Net::XMPP;
26
27           sub iq {
28             my ($sid,$IQ) = @_;
29             .
30             .
31             my $reply = $IQ->Reply();
32             my $replyQuery->GetQuery();
33             .
34           }
35
36         You now have access to all of the retrieval functions available.
37
38         To create a new iq to send to the server:
39
40           use Net::XMPP;
41
42           $IQ = new Net::XMPP::IQ();
43           $IQType = $IQ->NewChild( type );
44           $IQType->SetXXXXX("yyyyy");
45
46         Now you can call the creation functions for the IQ, and for the
47         <query/> on the new query object itself.  See below for the <iq/>
48         functions, and in each query module for those functions.
49

METHODS

51       General functions
52
53         Reply(%args) - Creates a return <iq/> with the to and from
54                        filled in correctly, and a query object already
55                        added in.  The %args that you pass are passed
56                        to SetIQ() and will overwrite the IQ settings
57                        that Reply sets.
58
59       Retrieval functions
60
61         GetTo()      - returns either a string with the JID, or a
62         GetTo("jid")   Net::XMPP::JID object for the person who is
63                        going to receive the <iq/>.  To get the JID
64                        object set the string to "jid", otherwise leave
65                        blank for the text string.
66
67                        $to    = $IQ->GetTo();
68                        $toJID = $IQ->GetTo("jid");
69
70         GetFrom()      -  returns either a string with the JID, or a
71         GetFrom("jid")    Net::XMPP::JID object for the person who
72                           sent the <iq/>.  To get the JID object set
73                           the string to "jid", otherwise leave blank for the
74                           text string.
75
76                           $from    = $IQ->GetFrom();
77                           $fromJID = $IQ->GetFrom("jid");
78
79         GetType() - returns a string with the type <iq/> this is.
80
81                     $type = $IQ->GetType();
82
83         GetID() - returns an integer with the id of the <iq/>.
84
85                   $id = $IQ->GetID();
86
87         GetError() - returns a string with the text description of the error.
88
89                      $error = $IQ->GetError();
90
91         GetErrorCode() - returns a string with the code of error.
92
93                          $errorCode = $IQ->GetErrorCode();
94
95         GetQuery() - returns a Net::XMPP::Stanza object that contains the data
96                      in the query of the <iq/>.  Basically, it returns the
97                      first child in the <iq/>.
98
99                      $query = $IQ->GetQuery();
100
101         GetQueryXMLNS() - returns a string with the namespace of the query
102                           for this <iq/>, if one exists.
103
104                           $xmlns = $IQ->GetQueryXMLNS();
105
106       Creation functions
107
108         SetIQ(to=>string⎪JID,    - set multiple fields in the <iq/> at one
109               from=>string⎪JID,    time.  This is a cumulative and over
110               id=>string,          writing action.  If you set the "to"
111               type=>string,        attribute twice, the second setting is
112               errorcode=>string,   what is used.  If you set the status, and
113               error=>string)       then set the priority then both will be in
114                                    the <iq/> tag.  For valid settings read the
115                                    specific Set functions below.
116
117                                    $IQ->SetIQ(type=>"get",
118                                               to=>"bob\@jabber.org");
119
120                                    $IQ->SetIQ(to=>"bob\@jabber.org",
121                                               errorcode=>403,
122                                               error=>"Permission Denied");
123
124         SetTo(string) - sets the to attribute.  You can either pass a string
125         SetTo(JID)      or a JID object.  They must be a valid Jabber
126                         Identifiers or the server will return an error message.
127                         (ie.  bob@jabber.org, etc...)
128
129                         $IQ->SetTo("bob\@jabber.org");
130
131         SetFrom(string) - sets the from attribute.  You can either pass a
132         SetFrom(JID)      string or a JID object.  They must be a valid JIDs
133                           or the server will return an error message.
134                           (ie.  bob@jabber.org, etc...)
135
136                           $IQ->SetFrom("me\@jabber.org");
137
138         SetType(string) - sets the type attribute.  Valid settings are:
139
140                           get      request information
141                           set      set information
142                           result   results of a get
143                           error    there was an error
144
145                           $IQ->SetType("set");
146
147         SetErrorCode(string) - sets the error code of the <iq/>.
148
149                                $IQ->SetErrorCode(403);
150
151         SetError(string) - sets the error string of the <iq/>.
152
153                            $IQ->SetError("Permission Denied");
154
155         NewChild(string) - creates a new Net::XMPP::Stanza object with the
156                            namespace in the string.  In order for this
157                            function to work with a custom namespace, you
158                            must define and register that namespace with the
159                            IQ module.  For more information please read the
160                            documentation for Net::XMPP::Stanza.
161
162                            $queryObj = $IQ->NewChild("jabber:iq:auth");
163                            $queryObj = $IQ->NewChild("jabber:iq:roster");
164
165         Reply(hash) - creates a new IQ object and populates the to/from
166                       fields.  If you specify a hash the same as with SetIQ
167                       then those values will override the Reply values.
168
169                       $iqReply = $IQ->Reply();
170                       $iqReply = $IQ->Reply(type=>"result");
171
172       Removal functions
173
174         RemoveTo() - removes the to attribute from the <iq/>.
175
176                      $IQ->RemoveTo();
177
178         RemoveFrom() - removes the from attribute from the <iq/>.
179
180                        $IQ->RemoveFrom();
181
182         RemoveID() - removes the id attribute from the <iq/>.
183
184                      $IQ->RemoveID();
185
186         RemoveType() - removes the type attribute from the <iq/>.
187
188                        $IQ->RemoveType();
189
190         RemoveError() - removes the <error/> element from the <iq/>.
191
192                         $IQ->RemoveError();
193
194         RemoveErrorCode() - removes the code attribute from the <error/>
195                             element in the <iq/>.
196
197                             $IQ->RemoveErrorCode();
198
199       Test functions
200
201         DefinedTo() - returns 1 if the to attribute is defined in the <iq/>,
202                       0 otherwise.
203
204                       $test = $IQ->DefinedTo();
205
206         DefinedFrom() - returns 1 if the from attribute is defined in the
207                         <iq/>, 0 otherwise.
208
209                         $test = $IQ->DefinedFrom();
210
211         DefinedID() - returns 1 if the id attribute is defined in the <iq/>,
212                       0 otherwise.
213
214                       $test = $IQ->DefinedID();
215
216         DefinedType() - returns 1 if the type attribute is defined in the
217                         <iq/>, 0 otherwise.
218
219                         $test = $IQ->DefinedType();
220
221         DefinedError() - returns 1 if <error/> is defined in the <iq/>,
222                          0 otherwise.
223
224                          $test = $IQ->DefinedError();
225
226         DefinedErrorCode() - returns 1 if the code attribute is defined in
227                              <error/>, 0 otherwise.
228
229                              $test = $IQ->DefinedErrorCode();
230
231         DefinedQuery() - returns 1 if there is at least one namespaced
232                          child in the object.
233

AUTHOR

235       Ryan Eatmon
236
238       This module is free software, you can redistribute it and/or modify it
239       under the LGPL.
240
241
242
243perl v5.8.8                       2007-04-02                  Net::XMPP::IQ(3)
Impressum