1Net::Jabber::XDB(3) User Contributed Perl Documentation Net::Jabber::XDB(3)
2
3
4
6 Net::Jabber::XDB - Jabber XDB Library
7
9 Net::Jabber::XDB is a companion to the Net::Jabber module. It
10 provides the user a simple interface to set and retrieve all
11 parts of a Jabber XDB.
12
14 Net::Jabber::XDB differs from the other Net::Jabber::* modules in that
15 the XMLNS of the data is split out into more submodules under
16 XDB. For specifics on each module please view the documentation
17 for each Net::Jabber::Data::* module. To see the list of avilable
18 namspaces and modules see Net::Jabber::Data.
19
20 To initialize the XDB with a Jabber <xdb/> you must pass it the
21 XML::Parser Tree array. For example:
22
23 my $xdb = new Net::Jabber::XDB(@tree);
24
25 There has been a change from the old way of handling the callbacks.
26 You no longer have to do the above, a Net::Jabber::XDB object is passed
27 to the callback function for the xdb:
28
29 use Net::Jabber qw(Component);
30
31 sub xdb {
32 my ($XDB) = @_;
33 .
34 .
35 .
36 }
37
38 You now have access to all of the retrieval functions available.
39
40 To create a new xdb to send to the server:
41
42 use Net::Jabber;
43
44 $XDB = new Net::Jabber::XDB();
45 $XDBType = $XDB->NewData( type );
46 $XDBType->SetXXXXX("yyyyy");
47
48 Now you can call the creation functions for the XDB, and for the <data/>
49 on the new Data object itself. See below for the <xdb/> functions, and
50 in each data module for those functions.
51
52 For more information about the array format being passed to the CallBack
53 please read the Net::Jabber::Client documentation.
54
56 Retrieval functions
57 GetTo() - returns either a string with the Jabber Identifier,
58 GetTo("jid") or a Net::Jabber::JID object for the person who is
59 going to receive the <xdb/>. To get the JID
60 object set the string to "jid", otherwise leave
61 blank for the text string.
62
63 $to = $XDB->GetTo();
64 $toJID = $XDB->GetTo("jid");
65
66 GetFrom() - returns either a string with the Jabber Identifier,
67 GetFrom("jid") or a Net::Jabber::JID object for the person who
68 sent the <xdb/>. To get the JID object set
69 the string to "jid", otherwise leave blank for the
70 text string.
71
72 $from = $XDB->GetFrom();
73 $fromJID = $XDB->GetFrom("jid");
74
75 GetType() - returns a string with the type <xdb/> this is.
76
77 $type = $XDB->GetType();
78
79 GetID() - returns an integer with the id of the <xdb/>.
80
81 $id = $XDB->GetID();
82
83 GetAction() - returns a string with the action <xdb/> this is.
84
85 $action = $XDB->GetAction();
86
87 GetMatch() - returns a string with the match <xdb/> this is.
88
89 $match = $XDB->GetMatch();
90
91 GetError() - returns a string with the text description of the error.
92
93 $error = $XDB->GetError();
94
95 GetErrorCode() - returns a string with the code of error.
96
97 $errorCode = $XDB->GetErrorCode();
98
99 GetData() - returns a Net::Jabber::Data object that contains the data
100 in the <data/> of the <xdb/>.
101
102 $dataTag = $XDB->GetData();
103
104 GetDataXMLNS() - returns a string with the namespace of the data
105 for this <xdb/>, if one exists.
106
107 $xmlns = $XDB->GetDataXMLNS();
108
109 Creation functions
110 SetXDB(to=>string|JID, - set multiple fields in the <xdb/> at one
111 from=>string|JID, time. This is a cumulative and over
112 id=>string, writing action. If you set the "to"
113 type=>string, attribute twice, the second setting is
114 action=>string, what is used. If you set the status, and
115 match=>string) then set the priority then both will be in
116 errorcode=>string, the <xdb/> tag. For valid settings read the
117 error=>string) specific Set functions below.
118
119 $XDB->SetXDB(type=>"get",
120 to=>"bob\@jabber.org",
121 data=>"info");
122
123 $XDB->SetXDB(to=>"bob\@jabber.org",
124 errorcode=>403,
125 error=>"Permission Denied");
126
127 SetTo(string) - sets the to attribute. You can either pass a string
128 SetTo(JID) or a JID object. They must be a valid Jabber
129 Identifiers or the server will return an error message.
130 (ie. jabber:bob@jabber.org, etc...)
131
132 $XDB->SetTo("bob\@jabber.org");
133
134 SetFrom(string) - sets the from attribute. You can either pass a string
135 SetFrom(JID) or a JID object. They must be a valid Jabber
136 Identifiers or the server will return an error message.
137 (ie. jabber:bob@jabber.org, etc...)
138
139 $XDB->SetFrom("me\@jabber.org");
140
141 SetType(string) - sets the type attribute. Valid settings are:
142
143 get request information
144 set set information
145 result results of a get
146 error there was an error
147
148 $XDB->SetType("set");
149
150 SetAction(string) - sets the error code of the <xdb/>.
151
152 $XDB->SetAction("foo");
153
154 SetMatch(string) - sets the error code of the <xdb/>.
155
156 $XDB->SetMatch("foo");
157
158 SetErrorCode(string) - sets the error code of the <xdb/>.
159
160 $XDB->SetErrorCode(403);
161
162 SetError(string) - sets the error string of the <xdb/>.
163
164 $XDB->SetError("Permission Denied");
165
166 NewData(string) - creates a new Net::Jabber::Data object with the
167 namespace in the string. In order for this function
168 to work with a custom namespace, you must define and
169 register that namespace with the XDB module. For more
170 information please read the documentation for
171 Net::Jabber::Data.
172
173 $dataObj = $XDB->NewData("jabber:xdb:auth");
174 $dataObj = $XDB->NewData("jabber:xdb:roster");
175
176 Reply(hash) - creates a new XDB object and populates the to/from
177 fields. If you specify a hash the same as with SetXDB
178 then those values will override the Reply values.
179
180 $xdbReply = $XDB->Reply();
181 $xdbReply = $XDB->Reply(type=>"result");
182
183 Test functions
184 DefinedTo() - returns 1 if the to attribute is defined in the <xdb/>,
185 0 otherwise.
186
187 $test = $XDB->DefinedTo();
188
189 DefinedFrom() - returns 1 if the from attribute is defined in the <xdb/>,
190 0 otherwise.
191
192 $test = $XDB->DefinedFrom();
193
194 DefinedID() - returns 1 if the id attribute is defined in the <xdb/>,
195 0 otherwise.
196
197 $test = $XDB->DefinedID();
198
199 DefinedType() - returns 1 if the type attribute is defined in the <xdb/>,
200 0 otherwise.
201
202 $test = $XDB->DefinedType();
203
204 DefinedAction() - returns 1 if the action attribute is defined in the <xdb/>,
205 0 otherwise.
206
207 $test = $XDB->DefinedAction();
208
209 DefinedMatch() - returns 1 if the match attribute is defined in the <xdb/>,
210 0 otherwise.
211
212 $test = $XDB->DefinedMatch();
213
214 DefinedError() - returns 1 if <error/> is defined in the <xdb/>,
215 0 otherwise.
216
217 $test = $XDB->DefinedError();
218
219 DefinedErrorCode() - returns 1 if the code attribute is defined in
220 <error/>, 0 otherwise.
221
222 $test = $XDB->DefinedErrorCode();
223
225 By Ryan Eatmon in May of 2001 for http://jabber.org..
226
228 This module is free software; you can redistribute it and/or modify it
229 under the same terms as Perl itself.
230
231
232
233perl v5.30.1 2020-01-30 Net::Jabber::XDB(3)