gmcmillan-xmpp4r 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +91 -0
- data/COPYING +340 -0
- data/LICENSE +59 -0
- data/README.rdoc +122 -0
- data/README_ruby19.txt +43 -0
- data/Rakefile +258 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/README +56 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +23 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +136 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/cube.xml +15 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/tower.xml +69 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +424 -0
- data/data/doc/xmpp4r/examples/advanced/fileserve.conf +11 -0
- data/data/doc/xmpp4r/examples/advanced/fileserve.rb +346 -0
- data/data/doc/xmpp4r/examples/advanced/getonline.rb +56 -0
- data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +315 -0
- data/data/doc/xmpp4r/examples/advanced/migrate.rb +88 -0
- data/data/doc/xmpp4r/examples/advanced/minimuc.rb +266 -0
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
- data/data/doc/xmpp4r/examples/advanced/recvfile.rb +85 -0
- data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +129 -0
- data/data/doc/xmpp4r/examples/advanced/sendfile.conf +10 -0
- data/data/doc/xmpp4r/examples/advanced/sendfile.rb +72 -0
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +51 -0
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +43 -0
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +10 -0
- data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +109 -0
- data/data/doc/xmpp4r/examples/advanced/xmpping.rb +146 -0
- data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +14 -0
- data/data/doc/xmpp4r/examples/basic/change_password.rb +41 -0
- data/data/doc/xmpp4r/examples/basic/client.rb +70 -0
- data/data/doc/xmpp4r/examples/basic/component.rb +11 -0
- data/data/doc/xmpp4r/examples/basic/echo.rb +37 -0
- data/data/doc/xmpp4r/examples/basic/jabbersend.rb +41 -0
- data/data/doc/xmpp4r/examples/basic/mass_sender.rb +68 -0
- data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +12 -0
- data/data/doc/xmpp4r/examples/basic/mucinfo.rb +41 -0
- data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +82 -0
- data/data/doc/xmpp4r/examples/basic/register.rb +42 -0
- data/data/doc/xmpp4r/examples/basic/remove_registration.rb +18 -0
- data/data/doc/xmpp4r/examples/basic/roster.rb +44 -0
- data/data/doc/xmpp4r/examples/basic/rosterprint.rb +50 -0
- data/data/doc/xmpp4r/examples/basic/rosterrename.rb +34 -0
- data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +171 -0
- data/data/doc/xmpp4r/examples/basic/send_vcard.rb +67 -0
- data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
- data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
- data/data/doc/xmpp4r/examples/basic/versionbot.rb +75 -0
- data/lib/xmpp4r.rb +118 -0
- data/lib/xmpp4r/base64.rb +32 -0
- data/lib/xmpp4r/bytestreams.rb +15 -0
- data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +321 -0
- data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +257 -0
- data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +31 -0
- data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +54 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +153 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +86 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +198 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +65 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +82 -0
- data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +170 -0
- data/lib/xmpp4r/bytestreams/iq/si.rb +206 -0
- data/lib/xmpp4r/callbacks.rb +133 -0
- data/lib/xmpp4r/caps.rb +1 -0
- data/lib/xmpp4r/caps/c.rb +67 -0
- data/lib/xmpp4r/caps/helper/generator.rb +160 -0
- data/lib/xmpp4r/caps/helper/helper.rb +84 -0
- data/lib/xmpp4r/client.rb +345 -0
- data/lib/xmpp4r/command/helper/responder.rb +53 -0
- data/lib/xmpp4r/command/iq/command.rb +154 -0
- data/lib/xmpp4r/component.rb +103 -0
- data/lib/xmpp4r/connection.rb +231 -0
- data/lib/xmpp4r/dataforms.rb +5 -0
- data/lib/xmpp4r/dataforms/x/data.rb +297 -0
- data/lib/xmpp4r/debuglog.rb +63 -0
- data/lib/xmpp4r/delay.rb +5 -0
- data/lib/xmpp4r/delay/x/delay.rb +99 -0
- data/lib/xmpp4r/discovery.rb +8 -0
- data/lib/xmpp4r/discovery/helper/helper.rb +58 -0
- data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
- data/lib/xmpp4r/discovery/iq/discoinfo.rb +211 -0
- data/lib/xmpp4r/discovery/iq/discoitems.rb +147 -0
- data/lib/xmpp4r/entity_time.rb +6 -0
- data/lib/xmpp4r/entity_time/iq.rb +45 -0
- data/lib/xmpp4r/entity_time/responder.rb +57 -0
- data/lib/xmpp4r/errors.rb +284 -0
- data/lib/xmpp4r/feature_negotiation.rb +5 -0
- data/lib/xmpp4r/feature_negotiation/iq/feature.rb +28 -0
- data/lib/xmpp4r/framework/base.rb +55 -0
- data/lib/xmpp4r/framework/bot.rb +148 -0
- data/lib/xmpp4r/httpbinding.rb +5 -0
- data/lib/xmpp4r/httpbinding/client.rb +275 -0
- data/lib/xmpp4r/idgenerator.rb +37 -0
- data/lib/xmpp4r/iq.rb +221 -0
- data/lib/xmpp4r/jid.rb +167 -0
- data/lib/xmpp4r/last.rb +2 -0
- data/lib/xmpp4r/last/helper/helper.rb +37 -0
- data/lib/xmpp4r/last/iq/last.rb +67 -0
- data/lib/xmpp4r/location.rb +2 -0
- data/lib/xmpp4r/location/helper/helper.rb +56 -0
- data/lib/xmpp4r/location/location.rb +179 -0
- data/lib/xmpp4r/message.rb +226 -0
- data/lib/xmpp4r/muc.rb +14 -0
- data/lib/xmpp4r/muc/helper/mucbrowser.rb +92 -0
- data/lib/xmpp4r/muc/helper/mucclient.rb +469 -0
- data/lib/xmpp4r/muc/helper/simplemucclient.rb +332 -0
- data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
- data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
- data/lib/xmpp4r/muc/iq/mucowner.rb +15 -0
- data/lib/xmpp4r/muc/item.rb +143 -0
- data/lib/xmpp4r/muc/x/muc.rb +70 -0
- data/lib/xmpp4r/muc/x/mucuserinvite.rb +60 -0
- data/lib/xmpp4r/muc/x/mucuseritem.rb +36 -0
- data/lib/xmpp4r/presence.rb +232 -0
- data/lib/xmpp4r/pubsub.rb +8 -0
- data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
- data/lib/xmpp4r/pubsub/children/event.rb +49 -0
- data/lib/xmpp4r/pubsub/children/item.rb +35 -0
- data/lib/xmpp4r/pubsub/children/items.rb +53 -0
- data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
- data/lib/xmpp4r/pubsub/children/publish.rb +38 -0
- data/lib/xmpp4r/pubsub/children/retract.rb +41 -0
- data/lib/xmpp4r/pubsub/children/subscription.rb +62 -0
- data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
- data/lib/xmpp4r/pubsub/children/unsubscribe.rb +63 -0
- data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +129 -0
- data/lib/xmpp4r/pubsub/helper/nodehelper.rb +156 -0
- data/lib/xmpp4r/pubsub/helper/oauth_service_helper.rb +90 -0
- data/lib/xmpp4r/pubsub/helper/servicehelper.rb +490 -0
- data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
- data/lib/xmpp4r/query.rb +15 -0
- data/lib/xmpp4r/reliable.rb +168 -0
- data/lib/xmpp4r/rexmladdons.rb +197 -0
- data/lib/xmpp4r/roster.rb +7 -0
- data/lib/xmpp4r/roster/helper/roster.rb +532 -0
- data/lib/xmpp4r/roster/iq/roster.rb +215 -0
- data/lib/xmpp4r/roster/x/roster.rb +138 -0
- data/lib/xmpp4r/rpc.rb +2 -0
- data/lib/xmpp4r/rpc/helper/client.rb +123 -0
- data/lib/xmpp4r/rpc/helper/server.rb +74 -0
- data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +67 -0
- data/lib/xmpp4r/rpc/iq/rpc.rb +23 -0
- data/lib/xmpp4r/sasl.rb +259 -0
- data/lib/xmpp4r/semaphore.rb +38 -0
- data/lib/xmpp4r/stream.rb +611 -0
- data/lib/xmpp4r/streamparser.rb +66 -0
- data/lib/xmpp4r/test/listener_mocker.rb +118 -0
- data/lib/xmpp4r/tune.rb +2 -0
- data/lib/xmpp4r/tune/helper/helper.rb +58 -0
- data/lib/xmpp4r/tune/tune.rb +113 -0
- data/lib/xmpp4r/vcard.rb +6 -0
- data/lib/xmpp4r/vcard/helper/vcard.rb +84 -0
- data/lib/xmpp4r/vcard/iq/vcard.rb +109 -0
- data/lib/xmpp4r/version.rb +7 -0
- data/lib/xmpp4r/version/helper/responder.rb +72 -0
- data/lib/xmpp4r/version/helper/simpleresponder.rb +44 -0
- data/lib/xmpp4r/version/iq/version.rb +105 -0
- data/lib/xmpp4r/x.rb +37 -0
- data/lib/xmpp4r/xhtml.rb +1 -0
- data/lib/xmpp4r/xhtml/html.rb +115 -0
- data/lib/xmpp4r/xmpp4r.rb +20 -0
- data/lib/xmpp4r/xmppelement.rb +168 -0
- data/lib/xmpp4r/xmppstanza.rb +162 -0
- data/setup.rb +1586 -0
- data/test/bytestreams/tc_ibb.rb +188 -0
- data/test/bytestreams/tc_socks5bytestreams.rb +114 -0
- data/test/caps/tc_helper.rb +158 -0
- data/test/dataforms/tc_data.rb +81 -0
- data/test/delay/tc_xdelay.rb +51 -0
- data/test/discovery/tc_responder.rb +91 -0
- data/test/entity_time/tc_responder.rb +65 -0
- data/test/last/tc_helper.rb +75 -0
- data/test/lib/assert_equal_xml.rb +14 -0
- data/test/lib/clienttester.rb +149 -0
- data/test/muc/tc_muc_mucclient.rb +834 -0
- data/test/muc/tc_muc_simplemucclient.rb +114 -0
- data/test/muc/tc_mucowner.rb +50 -0
- data/test/pubsub/tc_helper.rb +785 -0
- data/test/pubsub/tc_nodeconfig.rb +61 -0
- data/test/pubsub/tc_subscriptionconfig.rb +41 -0
- data/test/roster/tc_helper.rb +523 -0
- data/test/roster/tc_iqqueryroster.rb +173 -0
- data/test/roster/tc_xroster.rb +73 -0
- data/test/rpc/tc_helper.rb +96 -0
- data/test/tc_callbacks.rb +129 -0
- data/test/tc_class_names.rb +146 -0
- data/test/tc_client.rb +30 -0
- data/test/tc_errors.rb +146 -0
- data/test/tc_idgenerator.rb +30 -0
- data/test/tc_iq.rb +113 -0
- data/test/tc_iqquery.rb +31 -0
- data/test/tc_jid.rb +204 -0
- data/test/tc_presence.rb +150 -0
- data/test/tc_rexml.rb +139 -0
- data/test/tc_stream.rb +193 -0
- data/test/tc_streamComponent.rb +105 -0
- data/test/tc_streamError.rb +129 -0
- data/test/tc_streamSend.rb +59 -0
- data/test/tc_streamparser.rb +137 -0
- data/test/tc_xmppstanza.rb +135 -0
- data/test/ts_xmpp4r.rb +44 -0
- data/test/tune/tc_helper_recv.rb +82 -0
- data/test/tune/tc_helper_send.rb +74 -0
- data/test/tune/tc_tune.rb +79 -0
- data/test/vcard/tc_helper.rb +49 -0
- data/test/vcard/tc_iqvcard.rb +62 -0
- data/test/version/tc_helper.rb +60 -0
- data/test/version/tc_iqqueryversion.rb +97 -0
- data/test/xhtml/tc_html.rb +41 -0
- data/tools/gen_requires.bash +31 -0
- data/tools/xmpp4r-gemspec-test.rb +11 -0
- data/xmpp4r.gemspec +249 -0
- metadata +299 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
# =XMPP4R - XMPP Library for Ruby
|
2
|
+
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
|
3
|
+
# Website::http://home.gna.org/xmpp4r/
|
4
|
+
|
5
|
+
require 'xmpp4r/discovery/iq/discoinfo'
|
6
|
+
require 'xmpp4r/discovery/iq/discoitems'
|
7
|
+
require 'xmpp4r/discovery/helper/helper'
|
8
|
+
require 'xmpp4r/discovery/helper/responder'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# =XMPP4R - XMPP Library for Ruby
|
2
|
+
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
|
3
|
+
# Website::http://home.gna.org/xmpp4r/
|
4
|
+
|
5
|
+
require 'xmpp4r'
|
6
|
+
require 'xmpp4r/discovery'
|
7
|
+
|
8
|
+
module Jabber
|
9
|
+
module Discovery
|
10
|
+
##
|
11
|
+
# A Helper to manage service and item discovery.
|
12
|
+
class Helper
|
13
|
+
def initialize(client)
|
14
|
+
@stream = client
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# Service discovery on a JID.
|
19
|
+
# jid:: [JID]
|
20
|
+
# return:: [Jabber::Discovery::IqQueryDiscoInfo]
|
21
|
+
def get_info_for(jid, node = nil)
|
22
|
+
iq = Jabber::Iq.new(:get, jid)
|
23
|
+
iq.from = @stream.jid
|
24
|
+
disco = Jabber::Discovery::IqQueryDiscoInfo.new
|
25
|
+
disco.node = node
|
26
|
+
iq.add(disco)
|
27
|
+
|
28
|
+
res = nil
|
29
|
+
|
30
|
+
@stream.send_with_id(iq) { |reply|
|
31
|
+
res = reply.query
|
32
|
+
}
|
33
|
+
|
34
|
+
res
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Item discovery on a JID.
|
39
|
+
# jid:: [JID]
|
40
|
+
# return:: [Jabber::Discovery::IqQueryDiscoItems]
|
41
|
+
def get_items_for(jid, node = nil)
|
42
|
+
iq = Jabber::Iq.new(:get, jid)
|
43
|
+
iq.from = @stream.jid
|
44
|
+
disco = Jabber::Discovery::IqQueryDiscoItems.new
|
45
|
+
disco.node = node
|
46
|
+
iq.add(disco)
|
47
|
+
|
48
|
+
res = nil
|
49
|
+
|
50
|
+
@stream.send_with_id(iq) { |reply|
|
51
|
+
res = reply.query
|
52
|
+
}
|
53
|
+
|
54
|
+
res
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# =XMPP4R - XMPP Library for Ruby
|
2
|
+
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
|
3
|
+
# Website::http://home.gna.org/xmpp4r/
|
4
|
+
|
5
|
+
require 'xmpp4r/iq'
|
6
|
+
require 'xmpp4r/discovery/iq/discoinfo'
|
7
|
+
require 'xmpp4r/discovery/iq/discoitems'
|
8
|
+
require 'xmpp4r/caps/helper/generator'
|
9
|
+
|
10
|
+
module Jabber
|
11
|
+
module Discovery
|
12
|
+
##
|
13
|
+
# Responds to Service Discovery queries on a given node
|
14
|
+
#
|
15
|
+
# Modify returned elements by these attributes:
|
16
|
+
# * Responder#identities
|
17
|
+
# * Responder#features (Responder#add_features is a short-cut accepting an Array of Strings, too)
|
18
|
+
# * Responder#forms
|
19
|
+
# * Responder#items
|
20
|
+
class Responder
|
21
|
+
##
|
22
|
+
# Service Discovery node this Responder is responsible for
|
23
|
+
# (will not answer queries for other nodes)
|
24
|
+
attr_reader :node
|
25
|
+
|
26
|
+
##
|
27
|
+
# Identities returned on Discovery Info query
|
28
|
+
#
|
29
|
+
# Array of [Discovery::Identity]
|
30
|
+
attr_accessor :identities
|
31
|
+
##
|
32
|
+
# Features returned on Discovery Info query,
|
33
|
+
#
|
34
|
+
# Array of [Discovery::Feature]
|
35
|
+
attr_accessor :features
|
36
|
+
##
|
37
|
+
# Forms returned on Discovery Info query
|
38
|
+
# (such as Software Information)
|
39
|
+
#
|
40
|
+
# Array of [Dataforms::XData]
|
41
|
+
attr_accessor :forms
|
42
|
+
|
43
|
+
##
|
44
|
+
# Children returned on Discovery Item query
|
45
|
+
#
|
46
|
+
# May contain other Discovery::Responder instances
|
47
|
+
# which will generate an item dynamically from their
|
48
|
+
# first identity
|
49
|
+
#
|
50
|
+
# Array of [Discovery::Item] or [Discovery::Responder] (mixed)
|
51
|
+
attr_accessor :items
|
52
|
+
|
53
|
+
##
|
54
|
+
# Set the JID this helper feels responsible for
|
55
|
+
# (default: nil, responsible for any JID)
|
56
|
+
attr_accessor :my_jid
|
57
|
+
|
58
|
+
CALLBACK_PRIORITY = 180
|
59
|
+
|
60
|
+
##
|
61
|
+
# Initialize responder for a specific node
|
62
|
+
# stream:: [Jabber::Stream]
|
63
|
+
# node:: [nil] or [String]
|
64
|
+
def initialize(stream, node=nil, identities=[], features=[], items=[])
|
65
|
+
@stream = stream
|
66
|
+
@my_jid = nil
|
67
|
+
@node = node
|
68
|
+
@identities = identities
|
69
|
+
@features = []
|
70
|
+
add_features(features)
|
71
|
+
@forms = []
|
72
|
+
@items = items
|
73
|
+
|
74
|
+
@stream.add_iq_callback(CALLBACK_PRIORITY, self) do |iq|
|
75
|
+
my_nodes = [@node, "#{@node}##{generate_ver}"]
|
76
|
+
|
77
|
+
if iq.type == :get and
|
78
|
+
iq.query.kind_of? IqQueryDiscoInfo and
|
79
|
+
my_nodes.include?(iq.query.node)
|
80
|
+
|
81
|
+
answer = iq.answer(false)
|
82
|
+
answer.type = :result
|
83
|
+
query = answer.add(IqQueryDiscoInfo.new)
|
84
|
+
query.node = iq.query.node
|
85
|
+
(@identities + @features + @forms).each do |element|
|
86
|
+
query.add(element)
|
87
|
+
end
|
88
|
+
@stream.send(answer)
|
89
|
+
|
90
|
+
true # handled
|
91
|
+
|
92
|
+
elsif iq.type == :get and
|
93
|
+
iq.query.kind_of? IqQueryDiscoItems and
|
94
|
+
my_nodes.include?(iq.query.node)
|
95
|
+
|
96
|
+
answer = iq.answer(false)
|
97
|
+
answer.type = :result
|
98
|
+
query = answer.add(IqQueryDiscoItems.new)
|
99
|
+
query.node = iq.query.node
|
100
|
+
@items.each do |item|
|
101
|
+
if item.kind_of? Responder
|
102
|
+
query.add(item.generate_item)
|
103
|
+
else
|
104
|
+
query.add(item)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
@stream.send(answer)
|
108
|
+
|
109
|
+
true # handled
|
110
|
+
|
111
|
+
else
|
112
|
+
false # not handled
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
##
|
118
|
+
# Add a feature
|
119
|
+
# feature:: [Jabber::Discovery::Feature] or [String]
|
120
|
+
def add_feature(feature)
|
121
|
+
if feature.kind_of? Feature
|
122
|
+
@features << feature
|
123
|
+
else
|
124
|
+
@features << Feature.new(feature.to_s)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
##
|
129
|
+
# Add a series of features
|
130
|
+
# features:: Array of [Jabber::Discovery::Feature] or [String]
|
131
|
+
def add_features(features)
|
132
|
+
features.each { |feature|
|
133
|
+
add_feature(feature)
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# Generate a XEP-0115: Entity Capabilities <c/> element
|
139
|
+
# for inclusion in Presence stanzas. This enables efficient
|
140
|
+
# caching of Service Discovery information.
|
141
|
+
def generate_caps
|
142
|
+
Caps::C.new(@node, generate_ver)
|
143
|
+
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# Generate an item for inclusion in items discovery in other
|
147
|
+
# responders
|
148
|
+
# return:: [Discovery::Item] or nil
|
149
|
+
def generate_item
|
150
|
+
i = @identities.first
|
151
|
+
if i
|
152
|
+
Item.new(@my_jid || @stream.jid, i.iname, @node)
|
153
|
+
else
|
154
|
+
nil
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def generate_ver
|
161
|
+
Caps::generate_ver(@identities, @features, @forms)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
# =XMPP4R - XMPP Library for Ruby
|
2
|
+
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
|
3
|
+
# Website::http://home.gna.org/xmpp4r/
|
4
|
+
|
5
|
+
require 'xmpp4r/query'
|
6
|
+
|
7
|
+
module Jabber
|
8
|
+
module Discovery
|
9
|
+
NS_DISCO_INFO = 'http://jabber.org/protocol/disco#info'
|
10
|
+
|
11
|
+
##
|
12
|
+
# Class for handling Service Discovery queries,
|
13
|
+
# info
|
14
|
+
# (JEP 0030)
|
15
|
+
#
|
16
|
+
# This <query/> may contain multiple Identity and Feature
|
17
|
+
# elements, describing the type and the supported namespaces of
|
18
|
+
# the service.
|
19
|
+
class IqQueryDiscoInfo < IqQuery
|
20
|
+
name_xmlns 'query', NS_DISCO_INFO
|
21
|
+
|
22
|
+
##
|
23
|
+
# Get the queried Service Discovery node or nil
|
24
|
+
#
|
25
|
+
# See IqQueryDiscoItems#node for a
|
26
|
+
# small explanation of this.
|
27
|
+
def node
|
28
|
+
attributes['node']
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Set the queried Service Discovery node or nil
|
33
|
+
# val:: [String]
|
34
|
+
def node=(val)
|
35
|
+
attributes['node'] = val
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Set the queried Service Discovery node or nil
|
40
|
+
# (chaining-friendly)
|
41
|
+
# val:: [String]
|
42
|
+
def set_node(val)
|
43
|
+
self.node = val
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Get the first identity child
|
49
|
+
# result:: [Identity]
|
50
|
+
def identity
|
51
|
+
first_element('identity')
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Get list of identities
|
56
|
+
# result:: [Array] of [Identity]
|
57
|
+
def identities
|
58
|
+
get_elements('identity')
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Get list of features
|
63
|
+
# result:: [Array] of [String]
|
64
|
+
def features
|
65
|
+
res = []
|
66
|
+
each_element('feature') { |feature|
|
67
|
+
res.push(feature.var)
|
68
|
+
}
|
69
|
+
res
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
##
|
75
|
+
# Service Discovery identity to add() to IqQueryDiscoInfo
|
76
|
+
#
|
77
|
+
# Please note that XEP 0030 requires both category and type to occur,
|
78
|
+
# for a reference see: http://www.xmpp.org/registrar/disco-categories.html
|
79
|
+
class Identity < XMPPElement
|
80
|
+
name_xmlns 'identity', NS_DISCO_INFO
|
81
|
+
|
82
|
+
##
|
83
|
+
# Initialize a new Identity
|
84
|
+
# category:: [String] Initial category or nil
|
85
|
+
# iname:: [String] Initial identity name or nil
|
86
|
+
# type:: [String] Initial type or nil
|
87
|
+
def initialize(category=nil, iname=nil, type=nil)
|
88
|
+
super()
|
89
|
+
set_category(category)
|
90
|
+
set_iname(iname)
|
91
|
+
set_type(type)
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Get the identity's category or nil
|
96
|
+
# result:: [String]
|
97
|
+
def category
|
98
|
+
attributes['category']
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# Set the identity's category
|
103
|
+
#
|
104
|
+
# Service Discovery categories should be somewhat
|
105
|
+
# standardized by some registry, so clients may
|
106
|
+
# represent specific categories by specific icons...
|
107
|
+
# (see http://www.jabber.org/registrar/disco-categories.html)
|
108
|
+
# val:: [String]
|
109
|
+
def category=(val)
|
110
|
+
attributes['category'] = val
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Set the identity's category (chaining-friendly)
|
115
|
+
# val:: [String]
|
116
|
+
def set_category(val)
|
117
|
+
self.category = val
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
##
|
122
|
+
# Get the identity's name or nil
|
123
|
+
#
|
124
|
+
# This has been renamed from <name/> to "iname" here
|
125
|
+
# to keep REXML::Element#name accessible
|
126
|
+
# result:: [String]
|
127
|
+
def iname
|
128
|
+
attributes['name']
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Set the identity's name
|
133
|
+
# val:: [String]
|
134
|
+
def iname=(val)
|
135
|
+
attributes['name'] = val
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Set the identity's name (chaining-friendly)
|
140
|
+
# val:: [String]
|
141
|
+
def set_iname(val)
|
142
|
+
self.iname = val
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# Get the identity's type or nil
|
148
|
+
# result:: [String]
|
149
|
+
def type
|
150
|
+
attributes['type']
|
151
|
+
end
|
152
|
+
|
153
|
+
##
|
154
|
+
# Set the identity's type
|
155
|
+
# (see http://www.jabber.org/registrar/disco-categories.html)
|
156
|
+
# val:: [String]
|
157
|
+
def type=(val)
|
158
|
+
attributes['type'] = val
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Set the identity's type (chaining-friendly)
|
163
|
+
# val:: [String]
|
164
|
+
def set_type(val)
|
165
|
+
self.type = val
|
166
|
+
self
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# Service Discovery feature to add() to IqQueryDiscoInfo
|
172
|
+
#
|
173
|
+
# Please note that JEP 0030 requires var to be set,
|
174
|
+
# for a reference see: http://www.xmpp.org/registrar/disco-features.html
|
175
|
+
class Feature < XMPPElement
|
176
|
+
name_xmlns 'feature', NS_DISCO_INFO
|
177
|
+
|
178
|
+
##
|
179
|
+
# Create a new <feature/> element
|
180
|
+
# var:: [String] New var
|
181
|
+
def initialize(var=nil)
|
182
|
+
super()
|
183
|
+
set_var(var)
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# Get the feature's var or nil
|
188
|
+
# result:: [String]
|
189
|
+
def var
|
190
|
+
attributes['var']
|
191
|
+
end
|
192
|
+
|
193
|
+
##
|
194
|
+
# Set the feature's var
|
195
|
+
#
|
196
|
+
# This is a namespace the identity supports.
|
197
|
+
# val:: [String]
|
198
|
+
def var=(val)
|
199
|
+
attributes['var'] = val
|
200
|
+
end
|
201
|
+
|
202
|
+
##
|
203
|
+
# Set the feature's var (chaining-friendly)
|
204
|
+
# val:: [String]
|
205
|
+
def set_var(val)
|
206
|
+
self.var = val
|
207
|
+
self
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# =XMPP4R - XMPP Library for Ruby
|
2
|
+
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
|
3
|
+
# Website::http://home.gna.org/xmpp4r/
|
4
|
+
|
5
|
+
require 'xmpp4r/query'
|
6
|
+
|
7
|
+
module Jabber
|
8
|
+
module Discovery
|
9
|
+
NS_DISCO_ITEMS = 'http://jabber.org/protocol/disco#items'
|
10
|
+
|
11
|
+
##
|
12
|
+
# Class for handling Service Discovery queries,
|
13
|
+
# items
|
14
|
+
# (JEP 0030)
|
15
|
+
#
|
16
|
+
# This <query/> may contain multiple Item elements,
|
17
|
+
# describing multiple services to be browsed by Jabber clients.
|
18
|
+
# These may then get further information about these items by
|
19
|
+
# querying IqQueryDiscoInfo and further sub-items by querying
|
20
|
+
# IqQueryDiscoItems.
|
21
|
+
class IqQueryDiscoItems < IqQuery
|
22
|
+
name_xmlns 'query', NS_DISCO_ITEMS
|
23
|
+
|
24
|
+
##
|
25
|
+
# Get the queried Service Discovery node or nil
|
26
|
+
#
|
27
|
+
# A Service Discovery node is _not_ a JID node,
|
28
|
+
# this may be a bit confusing. It's just to make
|
29
|
+
# Service Discovery browsing a bit more structured.
|
30
|
+
def node
|
31
|
+
attributes['node']
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Set the queried Service Discovery node or nil
|
36
|
+
def node=(val)
|
37
|
+
attributes['node'] = val
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Set the queried Service Discovery node or nil
|
42
|
+
# (chaining-friendly)
|
43
|
+
def set_node(val)
|
44
|
+
self.node = val
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Get all item children
|
50
|
+
# result:: Array of [Discovery::Item]
|
51
|
+
def items
|
52
|
+
get_elements('item')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
##
|
58
|
+
# Service Discovery item to add() to IqQueryDiscoItems
|
59
|
+
#
|
60
|
+
# Please note that JEP 0030 requires the jid to occur
|
61
|
+
class Item < XMPPElement
|
62
|
+
name_xmlns 'item', NS_DISCO_ITEMS
|
63
|
+
|
64
|
+
##
|
65
|
+
# Initialize a new Service Discovery <item/>
|
66
|
+
# to be added to IqQueryDiscoItems
|
67
|
+
# jid:: [JID]
|
68
|
+
# iname:: [String] Item name
|
69
|
+
# node:: [String] Service Discovery node (_not_ JID#node)
|
70
|
+
def initialize(jid=nil, iname=nil, node=nil)
|
71
|
+
super()
|
72
|
+
set_jid(jid)
|
73
|
+
set_iname(iname)
|
74
|
+
set_node(node)
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Get the item's jid or nil
|
79
|
+
# result:: [String]
|
80
|
+
def jid
|
81
|
+
JID.new(attributes['jid'])
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Set the item's jid
|
86
|
+
# val:: [JID]
|
87
|
+
def jid=(val)
|
88
|
+
attributes['jid'] = val.to_s
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Set the item's jid (chaining-friendly)
|
93
|
+
# val:: [JID]
|
94
|
+
def set_jid(val)
|
95
|
+
self.jid = val
|
96
|
+
self
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Get the item's name or nil
|
101
|
+
#
|
102
|
+
# This has been renamed from <name/> to "iname" here
|
103
|
+
# to keep REXML::Element#name accessible
|
104
|
+
# result:: [String]
|
105
|
+
def iname
|
106
|
+
attributes['name']
|
107
|
+
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# Set the item's name
|
111
|
+
# val:: [String]
|
112
|
+
def iname=(val)
|
113
|
+
attributes['name'] = val
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Set the item's name (chaining-friendly)
|
118
|
+
# val:: [String]
|
119
|
+
def set_iname(val)
|
120
|
+
self.iname = val
|
121
|
+
self
|
122
|
+
end
|
123
|
+
|
124
|
+
##
|
125
|
+
# Get the item's Service Discovery node or nil
|
126
|
+
# result:: [String]
|
127
|
+
def node
|
128
|
+
attributes['node']
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Set the item's Service Discovery node
|
133
|
+
# val:: [String]
|
134
|
+
def node=(val)
|
135
|
+
attributes['node'] = val
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Set the item's Service Discovery node (chaining-friendly)
|
140
|
+
# val:: [String]
|
141
|
+
def set_node(val)
|
142
|
+
self.node = val
|
143
|
+
self
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|