Class Jabber::IqQueryRoster
In: lib/xmpp4r/iq/query/roster.rb
Parent: IqQuery
X XDelay XMuc XRoster XMucUser REXML::Element XRosterItem IqQuery XMLStanza IqVcard DiscoIdentity XMucUserItem DiscoItem Error RosterItem DiscoFeature IqQueryRoster IqQueryVersion IqQueryDiscoItems IqQueryDiscoInfo Message Presence Iq Singleton IdGenerator Connection Client Component Comparable JID RuntimeError ErrorException AuthenticationFailure RosterItem Stream StreamParser Roster Vcard Version lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/iq/query/roster.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/iq/query/version.rb lib/xmpp4r/connection.rb lib/xmpp4r/x/mucuseritem.rb lib/xmpp4r/x/roster.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/iq/query.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/x/delay.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/client.rb lib/xmpp4r/stream.rb lib/xmpp4r/x/muc.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/iq/vcard.rb lib/xmpp4r/iq/query/discoinfo.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/message.rb lib/xmpp4r/iq/query/discoitems.rb lib/xmpp4r/presence.rb lib/xmpp4r/helpers/roster.rb lib/xmpp4r/helpers/vcard.rb lib/xmpp4r/helpers/version.rb Helpers Jabber Module: Jabber

Class for handling roster updates

You must do ‘client.send(Iq.new_rosterget)’ or else you will have nothing to put in receive_iq()

You must require ‘xmpp4r/rosterquery’ to use this class as its functionality is not needed for a working XMPP implementation. This will make [IqQuery] convert all Queries with namespace ‘jabber:iq:roster’ to [IqQueryRoster]

This <query/> contains multiple <item/> children. See RosterItem.

Methods

[]   each   inspect   new   receive_iq   to_a   typed_add  

Public Class methods

Create a new <query xmlns=’jabber:iq:roster’/>

stream:[Stream] Stream to handle

[Source]

    # File lib/xmpp4r/iq/query/roster.rb, line 24
24:     def initialize
25:       super
26:       add_namespace('jabber:iq:roster')
27:     end

Public Instance methods

Get roster item by JID

jid:[JID] or [Nil]
result:[RosterItem]

[Source]

    # File lib/xmpp4r/iq/query/roster.rb, line 59
59:     def [](jid)
60:       each { |item|
61:         return(item) if item.jid == jid
62:       }
63:       nil
64:     end

Iterate through all items

&block:Yield for every [RosterItem]

[Source]

    # File lib/xmpp4r/iq/query/roster.rb, line 48
48:     def each(&block)
49:       each_element { |item|
50:         # XPath won't work here as it's missing a prefix...
51:         yield(item) if item.kind_of?(RosterItem)
52:       }
53:     end

Output for "p"

JIDs of all contained [RosterItem] elements are joined with a comma

result:[String]

[Source]

    # File lib/xmpp4r/iq/query/roster.rb, line 95
95:     def inspect
96:       jids = to_a.collect { |item| item.jid.inspect }
97:       jids.join(', ')
98:     end

Update roster by <iq/> stanza (to be fed by an iq_callback)

iq:[Iq] Containing new roster
filter:[Boolean] If false import non-roster-like results too

[Source]

    # File lib/xmpp4r/iq/query/roster.rb, line 82
82:     def receive_iq(iq, filter=true)
83:       if filter && (((iq.type != :set) && (iq.type != :result)) || (iq.queryns != 'jabber:iq:roster'))
84:         return
85:       end
86: 
87:       import(iq.query)
88:     end

Get all items

result:[Array] of [RosterItem]

[Source]

    # File lib/xmpp4r/iq/query/roster.rb, line 69
69:     def to_a
70:       a = []
71:       each { |item|
72:         a.push(item)
73:       }
74:       a
75:     end

Add an element to the roster

Converts <item/> elements to RosterItem

Previous RosterItems with the same JID will not be deleted!

[Source]

    # File lib/xmpp4r/iq/query/roster.rb, line 36
36:     def typed_add(element)
37:       if element.kind_of?(REXML::Element) && (element.name == 'item')
38:         item = RosterItem::new.import(element)
39:         super(item)
40:       else
41:         super(element)
42:       end
43:     end

[Validate]