IQ: Information/Query (see RFC3920 - 9.2.3
A class used to build/parse IQ requests/responses
Create a new jabber:iq:auth set Stanza.
# File lib/xmpp4r/iq.rb, line 140 def Iq.new_authset(jid, password) iq = Iq.new(:set) query = IqQuery.new query.add_namespace('jabber:iq:auth') query.add(REXML::Element.new('username').add_text(jid.node)) query.add(REXML::Element.new('password').add_text(password)) query.add(REXML::Element.new('resource').add_text(jid.resource)) if not jid.resource.nil? iq.add(query) iq end
Create a new jabber:iq:auth set Stanza for Digest authentication
# File lib/xmpp4r/iq.rb, line 153 def Iq.new_authset_digest(jid, session_id, password) iq = Iq.new(:set) query = IqQuery.new query.add_namespace('jabber:iq:auth') query.add(REXML::Element.new('username').add_text(jid.node)) query.add(REXML::Element.new('digest').add_text(Digest::SHA1.hexdigest(session_id + password))) query.add(REXML::Element.new('resource').add_text(jid.resource)) if not jid.resource.nil? iq.add(query) iq end
Create a new jabber:iq:roster get Stanza.
# File lib/xmpp4r/iq.rb, line 203 def Iq.new_browseget iq = Iq.new(:get) query = IqQuery.new query.add_namespace('jabber:iq:browse') iq.add(query) iq end
Create a new Iq stanza with an unspecified query child (<query/> has no namespace)
# File lib/xmpp4r/iq.rb, line 131 def Iq.new_query(type = nil, to = nil) iq = Iq.new(type, to) query = IqQuery.new iq.add(query) iq end
Create a new jabber:iq:register set stanza for service/server registration
(Element will be ommited if unset)
(Element will be ommited if unset)
# File lib/xmpp4r/iq.rb, line 168 def Iq.new_register(username=nil, password=nil) iq = Iq.new(:set) query = IqQuery.new query.add_namespace('jabber:iq:register') query.add(REXML::Element.new('username').add_text(username)) if username query.add(REXML::Element.new('password').add_text(password)) if password iq.add(query) iq end
Create a new jabber:iq:register get stanza for retrieval of accepted registration information
# File lib/xmpp4r/iq.rb, line 181 def Iq.new_registerget iq = Iq.new(:get) query = IqQuery.new query.add_namespace('jabber:iq:register') iq.add(query) iq end
Create a new jabber:iq:roster get Stanza.
IqQueryRoster is unused here because possibly not require'd
# File lib/xmpp4r/iq.rb, line 193 def Iq.new_rosterget iq = Iq.new(:get) query = IqQuery.new query.add_namespace('jabber:iq:roster') iq.add(query) iq end
Create a new jabber:iq:roster set Stanza.
# File lib/xmpp4r/iq.rb, line 213 def Iq.new_rosterset iq = Iq.new(:set) query = IqQuery.new query.add_namespace('jabber:iq:roster') iq.add(query) iq end
Returns the iq's <command/> child, or nil
# File lib/xmpp4r/iq.rb, line 124 def command first_element("command") end
Returns the iq's <pubsub/> child, or nil
# File lib/xmpp4r/iq.rb, line 117 def pubsub first_element('pubsub') end
Returns the iq's query child, or nil
# File lib/xmpp4r/iq.rb, line 82 def query first_element('query') end
Delete old elements named newquery.name
will be added
# File lib/xmpp4r/iq.rb, line 90 def query=(newquery) delete_elements(newquery.name) add(newquery) end
Returns the iq's query's namespace, or nil
# File lib/xmpp4r/iq.rb, line 98 def queryns e = first_element('query') if e return e.namespace else return nil end end
Set the type of the Iq stanza (chaining-friendly)
or nil
# File lib/xmpp4r/iq.rb, line 74 def set_type(v) self.type = v self end
Get the type of the Iq stanza
The following values are allowed:
:get
:set
:result
:error
or nil
# File lib/xmpp4r/iq.rb, line 48 def type case super when 'get' then :get when 'set' then :set when 'result' then :result when 'error' then :error else nil end end
Returns the iq's <vCard/> child, or nil
# File lib/xmpp4r/iq.rb, line 110 def vcard first_element('vCard') end