mojodna-switchboard 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/bin/switchboard +1 -0
- data/lib/switchboard/helpers/oauth_pubsub.rb +2 -2
- data/lib/switchboard/switchboard.rb +1 -1
- data/lib/switchboard/version.rb +1 -1
- data/switchboard.gemspec +3 -3
- metadata +4 -6
- data/lib/switchboard/xmpp4r/location.rb +0 -2
- data/lib/switchboard/xmpp4r/location/helper/helper.rb +0 -56
- data/lib/switchboard/xmpp4r/location/location.rb +0 -179
- data/lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb +0 -107
data/Rakefile
CHANGED
data/bin/switchboard
CHANGED
|
@@ -7,8 +7,8 @@ rescue LoadError => e
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
require 'oauth/version'
|
|
10
|
-
if OAuth::VERSION < "0.3.1.
|
|
11
|
-
puts "The OAuth library must be at least version 0.3.1.
|
|
10
|
+
if OAuth::VERSION < "0.3.1.4"
|
|
11
|
+
puts "The OAuth library must be at least version 0.3.1.4."
|
|
12
12
|
exit 1
|
|
13
13
|
end
|
|
14
14
|
|
data/lib/switchboard/version.rb
CHANGED
data/switchboard.gemspec
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# this file is automatically generated
|
|
2
2
|
Gem::Specification.new do |s|
|
|
3
3
|
s.name = "switchboard"
|
|
4
|
-
s.version = "0.0.
|
|
4
|
+
s.version = "0.0.12"
|
|
5
5
|
s.summary = "XMPP toolkit."
|
|
6
6
|
s.description = "A toolkit for assembling XMPP clients and interacting with XMPP servers."
|
|
7
7
|
s.authors = ["Seth Fitzsimmons"]
|
|
8
8
|
s.email = ["seth@mojodna.net"]
|
|
9
9
|
|
|
10
|
-
s.files = ["bin/switchboard", "examples/election_results.rb", "lib/switchboard/client.rb", "lib/switchboard/colors.rb", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/disco/disco.rb", "lib/switchboard/commands/disco/info.rb", "lib/switchboard/commands/disco/items.rb", "lib/switchboard/commands/disco.rb", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/last/last.rb", "lib/switchboard/commands/last.rb", "lib/switchboard/commands/pep/location.rb", "lib/switchboard/commands/pep/pep.rb", "lib/switchboard/commands/pep/tune.rb", "lib/switchboard/commands/pep.rb", "lib/switchboard/commands/pubsub/affiliations.rb", "lib/switchboard/commands/pubsub/config.rb", "lib/switchboard/commands/pubsub/create.rb", "lib/switchboard/commands/pubsub/delete.rb", "lib/switchboard/commands/pubsub/info.rb", "lib/switchboard/commands/pubsub/items.rb", "lib/switchboard/commands/pubsub/listen.rb", "lib/switchboard/commands/pubsub/nodes.rb", "lib/switchboard/commands/pubsub/options.rb", "lib/switchboard/commands/pubsub/publish.rb", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/purge.rb", "lib/switchboard/commands/pubsub/retract.rb", "lib/switchboard/commands/pubsub/subscribe.rb", "lib/switchboard/commands/pubsub/subscriptions.rb", "lib/switchboard/commands/pubsub/unsubscribe.rb", "lib/switchboard/commands/pubsub.rb", "lib/switchboard/commands/register.rb", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/online.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.rb", "lib/switchboard/component.rb", "lib/switchboard/core.rb", "lib/switchboard/ext/delegate.rb", "lib/switchboard/ext/instance_exec.rb", "lib/switchboard/helpers/oauth_pubsub.rb", "lib/switchboard/helpers/pubsub.rb", "lib/switchboard/jacks/auto_accept.rb", "lib/switchboard/jacks/debug.rb", "lib/switchboard/jacks/notify.rb", "lib/switchboard/jacks/oauth_pubsub.rb", "lib/switchboard/jacks/pubsub.rb", "lib/switchboard/jacks/roster_debug.rb", "lib/switchboard/jacks.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard
|
|
10
|
+
s.files = ["bin/switchboard", "examples/election_results.rb", "lib/switchboard/client.rb", "lib/switchboard/colors.rb", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/disco/disco.rb", "lib/switchboard/commands/disco/info.rb", "lib/switchboard/commands/disco/items.rb", "lib/switchboard/commands/disco.rb", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/last/last.rb", "lib/switchboard/commands/last.rb", "lib/switchboard/commands/pep/location.rb", "lib/switchboard/commands/pep/pep.rb", "lib/switchboard/commands/pep/tune.rb", "lib/switchboard/commands/pep.rb", "lib/switchboard/commands/pubsub/affiliations.rb", "lib/switchboard/commands/pubsub/config.rb", "lib/switchboard/commands/pubsub/create.rb", "lib/switchboard/commands/pubsub/delete.rb", "lib/switchboard/commands/pubsub/info.rb", "lib/switchboard/commands/pubsub/items.rb", "lib/switchboard/commands/pubsub/listen.rb", "lib/switchboard/commands/pubsub/nodes.rb", "lib/switchboard/commands/pubsub/options.rb", "lib/switchboard/commands/pubsub/publish.rb", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/purge.rb", "lib/switchboard/commands/pubsub/retract.rb", "lib/switchboard/commands/pubsub/subscribe.rb", "lib/switchboard/commands/pubsub/subscriptions.rb", "lib/switchboard/commands/pubsub/unsubscribe.rb", "lib/switchboard/commands/pubsub.rb", "lib/switchboard/commands/register.rb", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/online.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.rb", "lib/switchboard/component.rb", "lib/switchboard/core.rb", "lib/switchboard/ext/delegate.rb", "lib/switchboard/ext/instance_exec.rb", "lib/switchboard/helpers/oauth_pubsub.rb", "lib/switchboard/helpers/pubsub.rb", "lib/switchboard/jacks/auto_accept.rb", "lib/switchboard/jacks/debug.rb", "lib/switchboard/jacks/notify.rb", "lib/switchboard/jacks/oauth_pubsub.rb", "lib/switchboard/jacks/pubsub.rb", "lib/switchboard/jacks/roster_debug.rb", "lib/switchboard/jacks.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard.rb", "Rakefile", "README.markdown", "switchboard-0.0.11.gem", "switchboard.gemspec", "switchboard.gemspec.me"]
|
|
11
11
|
s.executables = ["switchboard"]
|
|
12
12
|
s.require_paths = ["lib"]
|
|
13
13
|
|
|
14
|
-
s.add_dependency("mojodna-xmpp4r", ">=", "0.4.0.
|
|
14
|
+
s.add_dependency("mojodna-xmpp4r", ">=", "0.4.0.3")
|
|
15
15
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mojodna-switchboard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Seth Fitzsimmons
|
|
@@ -22,7 +22,7 @@ dependencies:
|
|
|
22
22
|
version: "0"
|
|
23
23
|
- - "="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.4.0.
|
|
25
|
+
version: 0.4.0.3
|
|
26
26
|
version:
|
|
27
27
|
description: A toolkit for assembling XMPP clients and interacting with XMPP servers.
|
|
28
28
|
email:
|
|
@@ -96,14 +96,12 @@ files:
|
|
|
96
96
|
- lib/switchboard/settings.rb
|
|
97
97
|
- lib/switchboard/switchboard.rb
|
|
98
98
|
- lib/switchboard/version.rb
|
|
99
|
-
- lib/switchboard/xmpp4r/location/helper/helper.rb
|
|
100
|
-
- lib/switchboard/xmpp4r/location/location.rb
|
|
101
|
-
- lib/switchboard/xmpp4r/location.rb
|
|
102
|
-
- lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb
|
|
103
99
|
- lib/switchboard.rb
|
|
104
100
|
- Rakefile
|
|
105
101
|
- README.markdown
|
|
102
|
+
- switchboard-0.0.11.gem
|
|
106
103
|
- switchboard.gemspec
|
|
104
|
+
- switchboard.gemspec.me
|
|
107
105
|
has_rdoc: false
|
|
108
106
|
homepage:
|
|
109
107
|
post_install_message:
|
|
@@ -1,56 +0,0 @@
|
|
|
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/pubsub'
|
|
7
|
-
require 'xmpp4r/location/location'
|
|
8
|
-
|
|
9
|
-
module Jabber
|
|
10
|
-
module UserLocation
|
|
11
|
-
##
|
|
12
|
-
# A Helper for XEP-0080 User Location
|
|
13
|
-
#
|
|
14
|
-
# Use this helper to send a user's location, or receive them from a
|
|
15
|
-
# specified jid. Described at http://www.xmpp.org/extensions/xep-0080.html
|
|
16
|
-
#
|
|
17
|
-
# For example:
|
|
18
|
-
# <pre>
|
|
19
|
-
# h = UserLocation::Helper( @client, 'radio1@hug.hellomatty.com' )
|
|
20
|
-
# h.add_userlocation_callback do |location|
|
|
21
|
-
# puts "Now in: #{location.locality}"
|
|
22
|
-
# end
|
|
23
|
-
# </pre>
|
|
24
|
-
class Helper < PubSub::ServiceHelper
|
|
25
|
-
##
|
|
26
|
-
# Send out the current location.
|
|
27
|
-
#
|
|
28
|
-
# location:: [Jabber::UserLocation::Location] current_location
|
|
29
|
-
def current_location(location)
|
|
30
|
-
item = Jabber::PubSub::Item.new()
|
|
31
|
-
item.add(location)
|
|
32
|
-
|
|
33
|
-
publish_item_to(NS_USERLOCATION, item)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
##
|
|
37
|
-
# Use this method to indicate that you wish to stop publishing
|
|
38
|
-
# a location.
|
|
39
|
-
def stop_publishing
|
|
40
|
-
current_location(Jabber::UserLocation::Location.new())
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
##
|
|
44
|
-
# Add a callback that will be invoked when a location is received
|
|
45
|
-
# from the jid specified when you constructed the Helper.
|
|
46
|
-
def add_userlocation_callback(prio = 200, ref = nil, &block)
|
|
47
|
-
add_event_callback(prio, ref) do |event|
|
|
48
|
-
location = event.first_element('items/item/location')
|
|
49
|
-
if location
|
|
50
|
-
block.call(location)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
@@ -1,179 +0,0 @@
|
|
|
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 'time'
|
|
6
|
-
require 'xmpp4r/xmppelement'
|
|
7
|
-
require 'rexml/element'
|
|
8
|
-
|
|
9
|
-
module Jabber
|
|
10
|
-
module UserLocation
|
|
11
|
-
NS_USERLOCATION = 'http://jabber.org/protocol/geoloc'
|
|
12
|
-
ALLOWABLE_ATTRIBUTES = %w(accuracy alt area bearing building country
|
|
13
|
-
datum description floor lat locality lon postalcode region room
|
|
14
|
-
speed street text timestamp uri)
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
# The <geoloc> XMPP element, as defined in XEP-0080 User Location
|
|
18
|
-
#
|
|
19
|
-
# See http://xmpp.org/extensions/xep-0080.html - this element
|
|
20
|
-
# encapsulates data about a user's current location. These are
|
|
21
|
-
# expressed as child elements such as <locality>, <lat>, etc.
|
|
22
|
-
# which are also managed by this class.
|
|
23
|
-
#
|
|
24
|
-
# If the element has no children then it indicates that the user
|
|
25
|
-
# has stopped publishing their location.
|
|
26
|
-
class Location < XMPPElement
|
|
27
|
-
name_xmlns 'geoloc', NS_USERLOCATION
|
|
28
|
-
force_xmlns true
|
|
29
|
-
|
|
30
|
-
##
|
|
31
|
-
# Construct a new <location> element.
|
|
32
|
-
#
|
|
33
|
-
# Supply no arguments to make an empty element to indicate that
|
|
34
|
-
# location is no longer being published.
|
|
35
|
-
#
|
|
36
|
-
# attributes:: [Hash] location attributes
|
|
37
|
-
def initialize(attributes = {})
|
|
38
|
-
super()
|
|
39
|
-
|
|
40
|
-
# validate attributes
|
|
41
|
-
attributes = attributes.select do |k,v|
|
|
42
|
-
ALLOWABLE_ATTRIBUTES.include?(k) && !v.nil?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
attributes.each do |k,v|
|
|
46
|
-
v = x.xmlschema if v.is_a?(Time)
|
|
47
|
-
add_element(REXML::Element.new(k)).text = v.to_s
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
##
|
|
53
|
-
# Returns true if a location is currently being published, otherwise false.
|
|
54
|
-
def published?
|
|
55
|
-
(elements.size > 0)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
##
|
|
59
|
-
# Get the accuracy attribute of this location.
|
|
60
|
-
def accuracy
|
|
61
|
-
first_element('accuracy').text if first_element('accuracy')
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
##
|
|
65
|
-
# Get the alt attribute of this location.
|
|
66
|
-
def alt
|
|
67
|
-
first_element('alt').text if first_element('alt')
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
##
|
|
71
|
-
# Get the area attribute of this location.
|
|
72
|
-
def area
|
|
73
|
-
first_element('area').text if first_element('area')
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
##
|
|
77
|
-
# Get the bearing attribute of this location.
|
|
78
|
-
def bearing
|
|
79
|
-
first_element('bearing').text if first_element('bearing')
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
##
|
|
83
|
-
# Get the building attribute of this location.
|
|
84
|
-
def building
|
|
85
|
-
first_element('building').text if first_element('building')
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
##
|
|
89
|
-
# Get the country attribute of this location.
|
|
90
|
-
def country
|
|
91
|
-
first_element('country').text if first_element('country')
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
##
|
|
95
|
-
# Get the datum attribute of this location.
|
|
96
|
-
def datum
|
|
97
|
-
first_element('datum').text if first_element('datum')
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
##
|
|
101
|
-
# Get the description attribute of this location.
|
|
102
|
-
def description
|
|
103
|
-
first_element('description').text if first_element('description')
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
##
|
|
107
|
-
# Get the floor attribute of this location.
|
|
108
|
-
def floor
|
|
109
|
-
first_element('floor').text if first_element('floor')
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
##
|
|
113
|
-
# Get the lat attribute of this location.
|
|
114
|
-
def lat
|
|
115
|
-
first_element('lat').text if first_element('lat')
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
##
|
|
119
|
-
# Get the locality attribute of this location.
|
|
120
|
-
def locality
|
|
121
|
-
first_element('locality').text if first_element('locality')
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
##
|
|
125
|
-
# Get the lon attribute of this location.
|
|
126
|
-
def lon
|
|
127
|
-
first_element('lon').text if first_element('lon')
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
##
|
|
131
|
-
# Get the postalcode attribute of this location.
|
|
132
|
-
def postalcode
|
|
133
|
-
first_element('postalcode').text if first_element('postalcode')
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
##
|
|
137
|
-
# Get the region attribute of this location.
|
|
138
|
-
def region
|
|
139
|
-
first_element('region').text if first_element('region')
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
##
|
|
143
|
-
# Get the room attribute of this location.
|
|
144
|
-
def room
|
|
145
|
-
first_element('room').text if first_element('room')
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
##
|
|
149
|
-
# Get the speed attribute of this location.
|
|
150
|
-
def speed
|
|
151
|
-
first_element('speed').text if first_element('speed')
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
##
|
|
155
|
-
# Get the street attribute of this location.
|
|
156
|
-
def street
|
|
157
|
-
first_element('street').text if first_element('street')
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
##
|
|
161
|
-
# Get the text attribute of this location.
|
|
162
|
-
def text
|
|
163
|
-
first_element('text').text if first_element('text')
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
##
|
|
167
|
-
# Get the timestamp attribute of this location.
|
|
168
|
-
def timestamp
|
|
169
|
-
first_element('timestamp').text if first_element('timestamp')
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
##
|
|
173
|
-
# Get the uri attribute of this location.
|
|
174
|
-
def uri
|
|
175
|
-
first_element('uri').text if first_element('uri')
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
end
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
module Jabber
|
|
2
|
-
module PubSub
|
|
3
|
-
# PubSub service helper for use with OAuth-authenticated nodes
|
|
4
|
-
class OAuthServiceHelper < ServiceHelper
|
|
5
|
-
def initialize(stream, pubsubjid)
|
|
6
|
-
super(stream, pubsubjid)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
# override #get_subscriptions_from_all_nodes to add an oauth element
|
|
10
|
-
def get_subscriptions_from_all_nodes(oauth_consumer, oauth_token)
|
|
11
|
-
iq = basic_pubsub_query(:get)
|
|
12
|
-
|
|
13
|
-
iq.pubsub.add(create_oauth_node(oauth_consumer, oauth_token))
|
|
14
|
-
|
|
15
|
-
entities = iq.pubsub.add(REXML::Element.new('subscriptions'))
|
|
16
|
-
res = nil
|
|
17
|
-
@stream.send_with_id(iq) { |reply|
|
|
18
|
-
if reply.pubsub.first_element('subscriptions')
|
|
19
|
-
res = []
|
|
20
|
-
reply.pubsub.first_element('subscriptions').each_element('subscription') { |subscription|
|
|
21
|
-
res << Jabber::PubSub::Subscription.import(subscription)
|
|
22
|
-
}
|
|
23
|
-
end
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
res
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# override #subscribe_to to add an oauth element
|
|
30
|
-
def subscribe_to(node, oauth_consumer, oauth_token)
|
|
31
|
-
iq = basic_pubsub_query(:set)
|
|
32
|
-
sub = REXML::Element.new('subscribe')
|
|
33
|
-
sub.attributes['node'] = node
|
|
34
|
-
sub.attributes['jid'] = @stream.jid.strip.to_s
|
|
35
|
-
|
|
36
|
-
sub.add(create_oauth_node(oauth_consumer, oauth_token))
|
|
37
|
-
|
|
38
|
-
iq.pubsub.add(sub)
|
|
39
|
-
res = nil
|
|
40
|
-
@stream.send_with_id(iq) do |reply|
|
|
41
|
-
pubsubanswer = reply.pubsub
|
|
42
|
-
if pubsubanswer.first_element('subscription')
|
|
43
|
-
res = PubSub::Subscription.import(pubsubanswer.first_element('subscription'))
|
|
44
|
-
end
|
|
45
|
-
end # @stream.send_with_id(iq)
|
|
46
|
-
res
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# override #unsubscribe_from to add an oauth element
|
|
50
|
-
def unsubscribe_from(node, oauth_consumer, oauth_token, subid=nil)
|
|
51
|
-
iq = basic_pubsub_query(:set)
|
|
52
|
-
unsub = PubSub::Unsubscribe.new
|
|
53
|
-
unsub.node = node
|
|
54
|
-
unsub.jid = @stream.jid.strip
|
|
55
|
-
|
|
56
|
-
unsub.add(create_oauth_node(oauth_consumer, oauth_token))
|
|
57
|
-
|
|
58
|
-
iq.pubsub.add(unsub)
|
|
59
|
-
ret = false
|
|
60
|
-
@stream.send_with_id(iq) { |reply|
|
|
61
|
-
ret = reply.kind_of?(Jabber::Iq) and reply.type == :result
|
|
62
|
-
} # @stream.send_with_id(iq)
|
|
63
|
-
ret
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
protected
|
|
67
|
-
|
|
68
|
-
# add the OAuth sauce (XEP-235)
|
|
69
|
-
def create_oauth_node(oauth_consumer, oauth_token)
|
|
70
|
-
require 'oauth/signature/hmac/sha1'
|
|
71
|
-
require 'cgi'
|
|
72
|
-
|
|
73
|
-
request = OAuth::RequestProxy.proxy \
|
|
74
|
-
"method" => "iq",
|
|
75
|
-
"uri" => [@stream.jid.strip.to_s, @pubsubjid.strip.to_s] * "&",
|
|
76
|
-
"parameters" => {
|
|
77
|
-
"oauth_consumer_key" => oauth_consumer.key,
|
|
78
|
-
"oauth_token" => oauth_token.token,
|
|
79
|
-
"oauth_signature_method" => "HMAC-SHA1"
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
signature = OAuth::Signature.sign(request, :consumer => oauth_consumer, :token => oauth_token)
|
|
83
|
-
|
|
84
|
-
oauth = REXML::Element.new("oauth")
|
|
85
|
-
oauth.attributes['xmlns'] = 'urn:xmpp:oauth'
|
|
86
|
-
|
|
87
|
-
oauth_consumer_key = REXML::Element.new("oauth_consumer_key")
|
|
88
|
-
oauth_consumer_key.text = oauth_consumer.key
|
|
89
|
-
oauth.add(oauth_consumer_key)
|
|
90
|
-
|
|
91
|
-
oauth_token_node = REXML::Element.new("oauth_token")
|
|
92
|
-
oauth_token_node.text = oauth_token.token
|
|
93
|
-
oauth.add(oauth_token_node)
|
|
94
|
-
|
|
95
|
-
oauth_signature_method = REXML::Element.new("oauth_signature_method")
|
|
96
|
-
oauth_signature_method.text = "HMAC-SHA1"
|
|
97
|
-
oauth.add(oauth_signature_method)
|
|
98
|
-
|
|
99
|
-
oauth_signature = REXML::Element.new("oauth_signature")
|
|
100
|
-
oauth_signature.text = signature
|
|
101
|
-
oauth.add(oauth_signature)
|
|
102
|
-
|
|
103
|
-
oauth
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|