Class Jabber::Iq
In: lib/xmpp4r/iq.rb
Parent: XMPPStanza
Message Presence XMPPStanza Iq Singleton IdGenerator XMPPElement X IqQuery Error Connection Client Component Client Comparable JID RuntimeError AuthenticationFailure ErrorException NoNameXmlnsRegistered SOCKS5Error REXML::Element Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator XMPPElement StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite IqPubSub Items Subscription IqPubSubOwner Item Event Feature Item Identity XDataField XDataReported XDataTitle XDataInstructions IqVcard SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryMUCOwner IqQueryRPC IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder Iq IqCommand RosterXItem XRoster RosterX X XMUCUser XMUC XDelay XData XParent MUCClient SimpleMUCClient XMLRPC::ParserWriterChooseMixin Client Server XMLRPC::ParseContentType XMLRPC::BasicServer Base DigestMD5 Plain ServiceHelper NodeHelper FileSource CallbackList Callback Semaphore StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Responder Helper MUCBrowser NodeBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/xmppstanza.rb lib/xmpp4r/callbacks.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/client.rb lib/xmpp4r/stream.rb lib/xmpp4r/semaphore.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/xmppelement.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams XParent lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/command/iq/command.rb lib/xmpp4r/command/helper/responder.rb Command lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/iq/mucowner.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/rpc/helper/server.rb lib/xmpp4r/rpc/helper/client.rb lib/xmpp4r/rpc/iq/rpc.rb RPC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/pubsub/stanzas/subscription.rb lib/xmpp4r/pubsub/helper/servicehelper.rb lib/xmpp4r/pubsub/stanzas/item.rb lib/xmpp4r/pubsub/helper/nodehelper.rb lib/xmpp4r/pubsub/iq/pubsub.rb lib/xmpp4r/pubsub/stanzas/event.rb lib/xmpp4r/pubsub/helper/nodebrowser.rb lib/xmpp4r/pubsub/stanzas/items.rb PubSub lib/xmpp4r/httpbinding/client.rb HTTPBinding lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_80_0.png

IQ: Information/Query (see RFC3920 - 9.2.3

A class used to build/parse IQ requests/responses

Methods

Public Class methods

Build a new <iq/> stanza

type:[Symbol] or nil, see Iq#type
to:[JID] Recipient

[Source]

    # File lib/xmpp4r/iq.rb, line 28
28:     def initialize(type = nil, to = nil)
29:       super()
30: 
31:       if not to.nil?
32:         set_to(to)
33:       end
34:       if not type.nil?
35:         set_type(type)
36:       end
37:     end

Create a new jabber:iq:auth set Stanza.

[Source]

     # File lib/xmpp4r/iq.rb, line 140
140:     def Iq.new_authset(jid, password)
141:       iq = Iq::new(:set)
142:       query = IqQuery::new
143:       query.add_namespace('jabber:iq:auth')
144:       query.add(REXML::Element::new('username').add_text(jid.node))
145:       query.add(REXML::Element::new('password').add_text(password))
146:       query.add(REXML::Element::new('resource').add_text(jid.resource)) if not jid.resource.nil?
147:       iq.add(query)
148:       iq
149:     end

Create a new jabber:iq:auth set Stanza for Digest authentication

[Source]

     # File lib/xmpp4r/iq.rb, line 153
153:     def Iq.new_authset_digest(jid, session_id, password)
154:       iq = Iq::new(:set)
155:       query = IqQuery::new
156:       query.add_namespace('jabber:iq:auth')
157:       query.add(REXML::Element::new('username').add_text(jid.node))
158:       query.add(REXML::Element::new('digest').add_text(Digest::SHA1.hexdigest(session_id + password)))
159:       query.add(REXML::Element::new('resource').add_text(jid.resource)) if not jid.resource.nil?
160:       iq.add(query)
161:       iq
162:     end

Create a new jabber:iq:roster get Stanza.

[Source]

     # File lib/xmpp4r/iq.rb, line 192
192:     def Iq.new_browseget
193:       iq = Iq::new(:get)
194:       query = IqQuery::new
195:       query.add_namespace('jabber:iq:browse')
196:       iq.add(query)
197:       iq
198:     end

Create a new Iq stanza with an unspecified query child (<query/> has no namespace)

[Source]

     # File lib/xmpp4r/iq.rb, line 131
131:     def Iq.new_query(type = nil, to = nil)
132:       iq = Iq::new(type, to)
133:       query = IqQuery::new
134:       iq.add(query)
135:       iq
136:     end

Create a new jabber:iq:register set stanza for service/server registration

username:[String] (Element will be ommited if unset)
password:[String] (Element will be ommited if unset)

[Source]

     # File lib/xmpp4r/iq.rb, line 168
168:     def Iq.new_register(username=nil, password=nil)
169:       iq = Iq::new(:set)
170:       query = IqQuery::new
171:       query.add_namespace('jabber:iq:register')
172:       query.add(REXML::Element::new('username').add_text(username)) if username
173:       query.add(REXML::Element::new('password').add_text(password)) if password
174:       iq.add(query)
175:       iq
176:     end

Create a new jabber:iq:roster get Stanza.

IqQueryRoster is unused here because possibly not require‘d

[Source]

     # File lib/xmpp4r/iq.rb, line 182
182:     def Iq.new_rosterget
183:       iq = Iq::new(:get)
184:       query = IqQuery::new
185:       query.add_namespace('jabber:iq:roster')
186:       iq.add(query)
187:       iq
188:     end

Create a new jabber:iq:roster set Stanza.

[Source]

     # File lib/xmpp4r/iq.rb, line 202
202:     def Iq.new_rosterset
203:       iq = Iq::new(:set)
204:       query = IqQuery::new
205:       query.add_namespace('jabber:iq:roster')
206:       iq.add(query)
207:       iq
208:     end

Public Instance methods

Returns the iq‘s <command/> child, or nil

resulte:[IqCommand]

[Source]

     # File lib/xmpp4r/iq.rb, line 124
124:     def command
125:       first_element("command")
126:     end

Returns the iq‘s <pubsub/> child, or nil

result:[IqVcard]

[Source]

     # File lib/xmpp4r/iq.rb, line 117
117:     def pubsub
118:       first_element('pubsub')
119:     end

Returns the iq‘s query child, or nil

result:[IqQuery]

[Source]

    # File lib/xmpp4r/iq.rb, line 82
82:     def query 
83:       first_element('query')
84:     end

Delete old elements named newquery.name

newquery:[REXML::Element] will be added

[Source]

    # File lib/xmpp4r/iq.rb, line 90
90:     def query=(newquery)
91:       delete_elements(newquery.name)
92:       add(newquery)
93:     end

Returns the iq‘s query‘s namespace, or nil

result:[String]

[Source]

     # File lib/xmpp4r/iq.rb, line 98
 98:     def queryns
 99:       e = first_element('query')
100:       if e
101:         return e.namespace
102:       else
103:         return nil
104:       end
105:     end

Set the type of the Iq stanza (chaining-friendly)

v:[Symbol] or nil

[Source]

    # File lib/xmpp4r/iq.rb, line 74
74:     def set_type(v)
75:       self.type = v
76:       self
77:     end

Get the type of the Iq stanza

The following values are allowed:

  • :get
  • :set
  • :result
  • :error
result:[Symbol] or nil

[Source]

    # File lib/xmpp4r/iq.rb, line 48
48:     def type
49:       case super
50:         when 'get' then :get
51:         when 'set' then :set
52:         when 'result' then :result
53:         when 'error' then :error
54:         else nil
55:       end
56:     end

Set the type of the Iq stanza (see Iq#type)

v:[Symbol] or nil

[Source]

    # File lib/xmpp4r/iq.rb, line 61
61:     def type=(v)
62:       case v
63:         when :get then super('get')
64:         when :set then super('set')
65:         when :result then super('result')
66:         when :error then super('error')
67:         else super(nil)
68:       end
69:     end

Returns the iq‘s <vCard/> child, or nil

result:[IqVcard]

[Source]

     # File lib/xmpp4r/iq.rb, line 110
110:     def vcard
111:       first_element('vCard')
112:     end

[Validate]