class Jabber::Iq

IQ: Information/Query (see RFC3920 - 9.2.3

A class used to build/parse IQ requests/responses

Public Class Methods

new(type = nil, to = nil) click to toggle source

Build a new <iq/> stanza

type
Symbol

or nil, see #type

to
JID

Recipient

Calls superclass method
# File lib/xmpp4r/iq.rb, line 28
def initialize(type = nil, to = nil)
  super()

  if not to.nil?
    set_to(to)
  end
  if not type.nil?
    set_type(type)
  end
end
new_authset(jid, password) click to toggle source

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
new_authset_digest(jid, session_id, password) click to toggle source

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
new_browseget() click to toggle source

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
new_query(type = nil, to = nil) click to toggle source

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
new_register(username=nil, password=nil) click to toggle source

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)

# 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
new_registerget() click to toggle source

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
new_rosterget() click to toggle source

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
new_rosterset() click to toggle source

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

Public Instance Methods

command() click to toggle source

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

resulte
IqCommand
# File lib/xmpp4r/iq.rb, line 124
def command
  first_element("command")
end
pubsub() click to toggle source

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

result
IqVcard
# File lib/xmpp4r/iq.rb, line 117
def pubsub
  first_element('pubsub')
end
query() click to toggle source

Returns the iq's query child, or nil

result
IqQuery
# File lib/xmpp4r/iq.rb, line 82
def query
  first_element('query')
end
query=(newquery) click to toggle source

Delete old elements named newquery.name

newquery
REXML::Element

will be added

# File lib/xmpp4r/iq.rb, line 90
def query=(newquery)
  delete_elements(newquery.name)
  add(newquery)
end
queryns() click to toggle source

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

result
String
# File lib/xmpp4r/iq.rb, line 98
def queryns
  e = first_element('query')
  if e
    return e.namespace
  else
    return nil
  end
end
set_type(v) click to toggle source

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

v
Symbol

or nil

# File lib/xmpp4r/iq.rb, line 74
def set_type(v)
  self.type = v
  self
end
type() click to toggle source

Get the type of the Iq stanza

The following values are allowed:

  • :get

  • :set

  • :result

  • :error

result
Symbol

or nil

Calls superclass method
# 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
type=(v) click to toggle source

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

v
Symbol

or nil

Calls superclass method
# File lib/xmpp4r/iq.rb, line 61
def type=(v)
  case v
    when :get then super('get')
    when :set then super('set')
    when :result then super('result')
    when :error then super('error')
    else super(nil)
  end
end
vcard() click to toggle source

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

result
IqVcard
# File lib/xmpp4r/iq.rb, line 110
def vcard
  first_element('vCard')
end