Class Jabber::Roster::IqQueryRoster
In: lib/xmpp4r/roster/iq/roster.rb
Parent: IqQuery
XMLStanza Message Presence Iq REXML::Element X IqQuery Error StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite Feature Identity Item XDataField XDataReported XDataTitle XDataInstructions IqVcard Singleton IdGenerator Connection Client Component Comparable JID RuntimeError ErrorException AuthenticationFailure SOCKS5Error Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder X XRoster XMUCUser XMUC XDelay XData MUCClient SimpleMUCClient Base DigestMD5 Plain FileSource StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.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/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.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 lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version 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/helper/simplemucclient.rb MUC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay 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 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/roster/iq/roster.rb, line 25
25:       def initialize
26:         super
27:         add_namespace('jabber:iq:roster')
28:       end

Public Instance methods

Get roster item by JID

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

[Source]

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

Iterate through all items

&block:Yield for every [RosterItem]

[Source]

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

Output for "p"

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

result:[String]

[Source]

    # File lib/xmpp4r/roster/iq/roster.rb, line 96
96:       def inspect
97:         jids = to_a.collect { |item| item.jid.inspect }
98:         jids.join(', ')
99:       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/roster/iq/roster.rb, line 83
83:       def receive_iq(iq, filter=true)
84:         if filter && (((iq.type != :set) && (iq.type != :result)) || (iq.queryns != 'jabber:iq:roster'))
85:           return
86:         end
87:         
88:         import(iq.query)
89:       end

Get all items

result:[Array] of [RosterItem]

[Source]

    # File lib/xmpp4r/roster/iq/roster.rb, line 70
70:       def to_a
71:         a = []
72:         each { |item|
73:           a.push(item)
74:         }
75:         a
76:       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/roster/iq/roster.rb, line 37
37:       def typed_add(element)
38:         if element.kind_of?(REXML::Element) && (element.name == 'item')
39:           item = RosterItem::new.import(element)
40:           super(item)
41:         else
42:           super(element)
43:         end
44:       end

[Validate]