1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://xmpp4r.github.io
require 'xmpp4r/query'
module Jabber
module Discovery
NS_DISCO_ITEMS = 'http://jabber.org/protocol/disco#items'
##
# Class for handling Service Discovery queries,
# items
# (JEP 0030)
#
# This <query/> may contain multiple Item elements,
# describing multiple services to be browsed by Jabber clients.
# These may then get further information about these items by
# querying IqQueryDiscoInfo and further sub-items by querying
# IqQueryDiscoItems.
class IqQueryDiscoItems < IqQuery
name_xmlns 'query', NS_DISCO_ITEMS
##
# Get the queried Service Discovery node or nil
#
# A Service Discovery node is _not_ a JID node,
# this may be a bit confusing. It's just to make
# Service Discovery browsing a bit more structured.
def node
attributes['node']
end
##
# Set the queried Service Discovery node or nil
def node=(val)
attributes['node'] = val
end
##
# Set the queried Service Discovery node or nil
# (chaining-friendly)
def set_node(val)
self.node = val
self
end
##
# Get all item children
# result:: Array of [Discovery::Item]
def items
get_elements('item')
end
end
##
# Service Discovery item to add() to IqQueryDiscoItems
#
# Please note that JEP 0030 requires the jid to occur
class Item < XMPPElement
name_xmlns 'item', NS_DISCO_ITEMS
##
# Initialize a new Service Discovery <item/>
# to be added to IqQueryDiscoItems
# jid:: [JID]
# iname:: [String] Item name
# node:: [String] Service Discovery node (_not_ JID#node)
def initialize(jid=nil, iname=nil, node=nil)
super()
set_jid(jid)
set_iname(iname)
set_node(node)
end
##
# Get the item's jid or nil
# result:: [String]
def jid
JID.new(attributes['jid'])
end
##
# Set the item's jid
# val:: [JID]
def jid=(val)
attributes['jid'] = val.to_s
end
##
# Set the item's jid (chaining-friendly)
# val:: [JID]
def set_jid(val)
self.jid = val
self
end
##
# Get the item's name or nil
#
# This has been renamed from <name/> to "iname" here
# to keep REXML::Element#name accessible
# result:: [String]
def iname
attributes['name']
end
##
# Set the item's name
# val:: [String]
def iname=(val)
attributes['name'] = val
end
##
# Set the item's name (chaining-friendly)
# val:: [String]
def set_iname(val)
self.iname = val
self
end
##
# Get the item's Service Discovery node or nil
# result:: [String]
def node
attributes['node']
end
##
# Set the item's Service Discovery node
# val:: [String]
def node=(val)
attributes['node'] = val
end
##
# Set the item's Service Discovery node (chaining-friendly)
# val:: [String]
def set_node(val)
self.node = val
self
end
end
end
end
|