xmpp4r 0.5 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/CHANGELOG +21 -0
  2. data/README.rdoc +29 -38
  3. data/Rakefile +11 -18
  4. data/data/doc/xmpp4r/examples/advanced/recvfile.rb +5 -4
  5. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +2 -0
  6. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +1 -0
  7. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +1 -1
  8. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +4 -1
  9. data/lib/xmpp4r/caps/helper/generator.rb +2 -2
  10. data/lib/xmpp4r/client.rb +18 -4
  11. data/lib/xmpp4r/connection.rb +8 -5
  12. data/lib/xmpp4r/delay/x/delay.rb +1 -1
  13. data/lib/xmpp4r/entity_time.rb +6 -0
  14. data/lib/xmpp4r/entity_time/iq.rb +45 -0
  15. data/lib/xmpp4r/entity_time/responder.rb +57 -0
  16. data/lib/xmpp4r/httpbinding/client.rb +178 -44
  17. data/lib/xmpp4r/message.rb +46 -0
  18. data/lib/xmpp4r/muc/helper/mucclient.rb +8 -1
  19. data/lib/xmpp4r/observable.rb +9 -0
  20. data/lib/xmpp4r/observable/contact.rb +61 -0
  21. data/lib/xmpp4r/observable/helper.rb +389 -0
  22. data/lib/xmpp4r/observable/observable_thing.rb +191 -0
  23. data/lib/xmpp4r/observable/pubsub.rb +211 -0
  24. data/lib/xmpp4r/observable/subscription.rb +57 -0
  25. data/lib/xmpp4r/observable/thread_store.rb +65 -0
  26. data/lib/xmpp4r/pubsub/children/unsubscribe.rb +16 -1
  27. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +48 -14
  28. data/lib/xmpp4r/rexmladdons.rb +46 -6
  29. data/lib/xmpp4r/roster/helper/roster.rb +19 -9
  30. data/lib/xmpp4r/sasl.rb +1 -1
  31. data/lib/xmpp4r/stream.rb +2 -2
  32. data/lib/xmpp4r/xmpp4r.rb +1 -1
  33. data/test/bytestreams/tc_socks5bytestreams.rb +2 -2
  34. data/test/entity_time/tc_responder.rb +65 -0
  35. data/test/roster/tc_helper.rb +2 -3
  36. data/test/tc_message.rb +52 -1
  37. data/test/tc_stream.rb +2 -2
  38. data/test/tc_streamComponent.rb +11 -1
  39. data/test/ts_xmpp4r.rb +11 -2
  40. data/xmpp4r.gemspec +20 -9
  41. metadata +41 -35
data/CHANGELOG CHANGED
@@ -1,3 +1,24 @@
1
+ mad-p-xmpp4r 0.6.3 (02/03/2013)
2
+ ===============================
3
+ * Removed unnecessary dependency on pry.
4
+
5
+ mad-p-xmpp4r 0.6.2 (26/02/2013)
6
+ ===============================
7
+ * Merge pull request #1 from Strech/patch-1
8
+ * Non-bosh connection flushes correctly
9
+ * Elaborated debug messages in HTTPBinding::Client
10
+
11
+ mad-p-xmpp4r 0.6.1 (21/02/2013)
12
+ ===============================
13
+ * Modified to work with BOSH with HTTPBinding::Client
14
+ - Support stream restart with urn:xmpp:xbosh way.
15
+ - Removed unnecessary wait until authenticated.
16
+ - Added Semaphore to wait for auth and bind response.
17
+ - Hook to setup SSL flags (certificate, etc.)
18
+ - Adjusted HTTP::Net read_timeout according to http_wait.
19
+ - Proxy handling.
20
+ - Respect poll/request BOSH parameters to avoid overactivity.
21
+
1
22
  XMPP4R 0.5 (15/06/2009)
2
23
  =======================
3
24
  * Many bugs fixed and tests cleanups (better Ruby 1.9 support, in
@@ -1,20 +1,22 @@
1
1
  = XMPP4R
2
2
 
3
+ A XMPP/Jabber library for ruby
4
+
5
+
3
6
  == Project Home
4
7
 
5
8
  You can find info about the xmpp4r project and how to contribute
6
9
  at the project home page:
7
10
 
8
- http://home.gna.org/xmpp4r/
11
+ http://xmpp4r.github.io
9
12
 
10
13
  If you need to ask questions, or want feedback on proposed changes
11
- please feel free to ask them on the 'xmpp4r-devel@gna.org' mailing
12
- list. You can join or view archives of the mailing list at:
14
+ please feel free to ask them on the github issues tracker.
13
15
 
14
- https://gna.org/mail/?group=xmpp4r
16
+ https://github.com/xmpp4r/xmpp4r/issues
15
17
 
16
18
  If you are having a problem and would like to report it
17
- to the mailing list please include a protocol dump
19
+ please include a protocol dump
18
20
  which can be enabled in your code with:
19
21
 
20
22
  Jabber::debug = true
@@ -22,24 +24,14 @@ which can be enabled in your code with:
22
24
 
23
25
  == Contributors
24
26
 
25
- Lucas Nussbaum <lucas@lucas-nussbaum.net>
26
- Stephan Maka <stephan@spaceboyz.net>
27
- Kirill A. Shutemov <k.shutemov@gmail.com>
28
- Glenn Rempe <glenn@rempe.us>
29
- Jacob Burkhart <jacob@brontes3d.com>
30
- Yuki Mitsui
31
- Peter Schrammel
32
- Olli
33
- Vojtech Vobr
34
- Andreas Wiese
35
- Chris Zelenak
36
- Matthew Wood
37
- Sam Ruby
38
- Tim Carey-Smith
39
- Scott Lillibridge
40
- Joshua Sierles
41
- Ripta Pasay <github@r8y.org>
42
- Seth Fitzsimmons
27
+ === Present Maintainers
28
+
29
+ Harisankar P S (hsps@rubykitchen.org)
30
+ Manu S Ajith (manu@rubykitchen.org)
31
+
32
+ === List of Contributors
33
+
34
+ http://github.com/xmpp4r/xmpp4r/contributors
43
35
 
44
36
 
45
37
  == Source Code
@@ -47,7 +39,7 @@ which can be enabled in your code with:
47
39
  The source for xmpp4r is managed using the Git SCM and can be
48
40
  found in our GitHub.com project page:
49
41
 
50
- http://github.com/ln/xmpp4r/tree/master
42
+ http://github.com/xmpp4r/xmpp4r/tree/master
51
43
 
52
44
 
53
45
  == Installation
@@ -57,17 +49,10 @@ on your needs and the methods you prefer.
57
49
 
58
50
  === Install over the network using RubyGems
59
51
 
60
- You can install the current release of the xmpp4r library from a stable
61
- release gem on RubyForge using RubyGems:
52
+ You can install the current release of the xmpp4r library via rubygems:
62
53
 
63
54
  sudo gem install xmpp4r
64
55
 
65
- === Install over the network using a Debian package
66
-
67
- You can install the current release of the xmpp4r library from a stable release copy
68
- on your .deb friendly linux system (e.g. Debian or Ubuntu) using apt:
69
-
70
- sudo apt-get install libxmpp4r-ruby
71
56
 
72
57
  === Install from local source code (Developers Only)
73
58
 
@@ -77,15 +62,11 @@ need to get a local copy.
77
62
 
78
63
  Clone the Git repository (recommended):
79
64
 
80
- git clone git://github.com/ln/xmpp4r.git
81
-
82
- OR download a stable release tarball from:
83
-
84
- http://download.gna.org/xmpp4r/xmpp4r-0.3.2.tgz
65
+ git clone git://github.com/xmpp4r/xmpp4r.git
85
66
 
86
67
  OR download a snapshot of the latest source in .tar.gz format from:
87
68
 
88
- http://github.com/ln/xmpp4r/tarball/master
69
+ http://github.com/xmpp4r/xmpp4r/tarball/master
89
70
 
90
71
  ==== Install : Using Rake
91
72
 
@@ -105,9 +86,19 @@ require RubyGems to be installed.
105
86
  ./setup.rb
106
87
 
107
88
 
89
+ == Contributing
90
+
91
+ 1. Fork it
92
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
93
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
94
+ 4. Push to the branch (`git push origin my-new-feature`)
95
+ 5. Create new Pull Request
96
+
108
97
  == License
109
98
 
110
99
  XMPP4R is released under the Ruby license (see the LICENSE file), which is
111
100
  compatible with the GNU GPL (see the COPYING file) via an explicit
112
101
  dual-licensing clause.
113
102
 
103
+
104
+
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rake'
2
2
  require "rake/clean"
3
3
  require 'rake/testtask'
4
- require 'rake/rdoctask'
4
+ require 'rdoc/task'
5
5
 
6
6
  $:.unshift 'lib'
7
7
  require "xmpp4r"
@@ -12,16 +12,16 @@ require "xmpp4r"
12
12
 
13
13
  PKG_NAME = 'xmpp4r'
14
14
  PKG_VERSION = Jabber::XMPP4R_VERSION
15
- AUTHORS = ['Lucas Nussbaum', 'Stephan Maka', 'Glenn Rempe']
16
- EMAIL = "xmpp4r-devel@gna.org"
17
- HOMEPAGE = "http://home.gna.org/xmpp4r/"
18
- SUMMARY = "XMPP4R is an XMPP/Jabber library for Ruby."
15
+ AUTHORS = ['Lucas Nussbaum', 'Stephan Maka', 'Glenn Rempe', 'Kaoru Maeda', 'Harisankar P S']
16
+ EMAIL = "mailme@hsps.in"
17
+ HOMEPAGE = "https://xmpp4r.github.io"
18
+ SUMMARY = "XMPP/Jabber library for ruby"
19
19
 
20
20
  # These are the common rdoc options that are shared between generation of
21
21
  # rdoc files using BOTH 'rake rdoc' and the installation by users of a
22
22
  # RubyGem version which builds rdoc's along with its installation. Any
23
23
  # rdoc options that are ONLY for developers running 'rake rdoc' should be
24
- # added in the 'Rake::RDocTask' block below.
24
+ # added in the 'RDoc::Task' block below.
25
25
  RDOC_OPTIONS = [
26
26
  "--quiet",
27
27
  "--title", SUMMARY,
@@ -61,7 +61,7 @@ end
61
61
 
62
62
  # RDOC
63
63
  #######
64
- Rake::RDocTask.new do |rd|
64
+ RDoc::Task.new do |rd|
65
65
 
66
66
  # which dir should rdoc files be installed in?
67
67
  rd.rdoc_dir = 'rdoc'
@@ -108,13 +108,6 @@ task :gen_requires_graph do
108
108
  sh %{cd tools; ./gen_requires.bash}
109
109
  end
110
110
 
111
- # UPDATE WEBSITE (for Lucas only)
112
- #################################
113
- desc "Update website (for Lucas only)"
114
- task :update_website do
115
- sh %{cp website/* ~/dev/xmpp4r/website/ && cd ~/dev/xmpp4r/website/ && svn commit -m "website update"}
116
- end
117
-
118
111
 
119
112
  ##############################################################################
120
113
  # SYNTAX CHECKING
@@ -134,7 +127,7 @@ end
134
127
  CLEAN.include ["*.gem", "pkg", "rdoc", "coverage", "tools/*.png"]
135
128
 
136
129
  begin
137
- require 'rake/gempackagetask'
130
+ require 'rubygems/package_task'
138
131
 
139
132
  spec = Gem::Specification.new do |s|
140
133
  s.name = PKG_NAME
@@ -156,7 +149,7 @@ begin
156
149
  s.required_ruby_version = ">= 1.8.4"
157
150
  end
158
151
 
159
- Rake::GemPackageTask.new(spec) do |pkg|
152
+ Gem::PackageTask.new(spec) do |pkg|
160
153
  pkg.gem_spec = spec
161
154
  pkg.need_tar = true
162
155
  pkg.need_zip = true
@@ -182,14 +175,14 @@ begin
182
175
  # Thanks to the Merb project for this code.
183
176
  desc "Update Github Gemspec"
184
177
  task :update_gemspec do
185
- skip_fields = %w(new_platform original_platform date)
178
+ skip_fields = %w(new_platform original_platform date cache_dir cache_file loaded)
186
179
 
187
180
  result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
188
181
  result << "# RUN : 'rake gem:update_gemspec'\n\n"
189
182
  result << "Gem::Specification.new do |s|\n"
190
183
  spec.instance_variables.sort.each do |ivar|
191
184
  value = spec.instance_variable_get(ivar)
192
- name = ivar.split("@").last
185
+ name = ivar.to_s.split("@").last
193
186
  next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
194
187
  if name == "dependencies"
195
188
  value.each do |d|
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'xmpp4r'
4
- require 'xmpp4r/helpers/filetransfer'
4
+ require 'xmpp4r/bytestreams/helper/filetransfer'
5
5
 
6
+ Jabber::debug = true
6
7
 
7
8
  if ARGV.size != 3
8
9
  puts "Usage: #{$0} <jid> <password> <incoming-directory>"
@@ -18,7 +19,7 @@ cl.connect
18
19
  puts "Authenticating..."
19
20
  cl.auth ARGV[1]
20
21
 
21
- ft = Jabber::Helpers::FileTransfer.new(cl)
22
+ ft = Jabber::FileTransfer::Helper.new(cl)
22
23
  ft.add_incoming_callback { |iq,file|
23
24
  puts "Incoming file transfer from #{iq.from}: #{file.fname} (#{file.size / 1024} KB)"
24
25
 
@@ -40,7 +41,7 @@ ft.add_incoming_callback { |iq,file|
40
41
  begin
41
42
  puts "Accepting #{file.fname}"
42
43
  stream = ft.accept(iq, offset)
43
- if stream.kind_of?(Jabber::Helpers::SOCKS5Bytestreams)
44
+ if stream.kind_of?(Jabber::Bytestreams::SOCKS5Bytestreams)
44
45
  stream.connect_timeout = 5
45
46
  stream.add_streamhost_callback { |streamhost,state,e|
46
47
  case state
@@ -58,7 +59,7 @@ ft.add_incoming_callback { |iq,file|
58
59
  if stream.accept
59
60
  puts "Stream established"
60
61
  outfile = File.new(filename, (offset ? 'a' : 'w'))
61
- while buf = stream.read
62
+ while buf = stream.read(65536)
62
63
  outfile.write(buf)
63
64
  print '.'
64
65
  $stdout.flush
@@ -4,9 +4,11 @@
4
4
 
5
5
  require 'xmpp4r/callbacks'
6
6
  require 'xmpp4r/bytestreams/iq/si'
7
+ require 'xmpp4r/bytestreams/iq/bytestreams'
7
8
  require 'xmpp4r/dataforms/x/data'
8
9
  require 'xmpp4r/bytestreams/helper/ibb/base'
9
10
  require 'xmpp4r/bytestreams/helper/socks5bytestreams/base'
11
+ require 'xmpp4r/bytestreams/helper/socks5bytestreams/target'
10
12
 
11
13
  module Jabber
12
14
  module FileTransfer
@@ -8,6 +8,7 @@ require 'timeout'
8
8
  require 'digest/sha1'
9
9
 
10
10
  require 'xmpp4r/callbacks'
11
+ require 'xmpp4r/bytestreams/helper/socks5bytestreams/socks5'
11
12
 
12
13
  module Jabber
13
14
  module Bytestreams
@@ -31,7 +31,7 @@ module Jabber
31
31
  elsif streamhost.kind_of?(String) or streamhost.kind_of?(JID)
32
32
  @streamhosts << SOCKS5Bytestreams::query_streamhost(@stream, streamhost, @initiator_jid)
33
33
  else
34
- raise "Unknwon streamhost type: #{streamhost.class}"
34
+ raise "Unknown streamhost type: #{streamhost.class}"
35
35
  end
36
36
  end
37
37
 
@@ -26,10 +26,12 @@ module Jabber
26
26
  def accept
27
27
  error = nil
28
28
  connect_sem = Semaphore.new
29
+ iq_received_sem = Semaphore.new
29
30
 
30
31
  @stream.add_iq_callback(200, self) { |iq|
31
32
  if iq.type == :set and iq.from == @initiator_jid and iq.to == @target_jid and iq.query.kind_of?(IqQueryBytestreams)
32
33
  begin
34
+ iq_received_sem.run
33
35
  @stream.delete_iq_callback(self)
34
36
 
35
37
  iq.query.each_element('streamhost') { |streamhost|
@@ -66,7 +68,8 @@ module Jabber
66
68
  }
67
69
  @accept_ready.run
68
70
  begin
69
- Timeout::timeout(@connect_timeout) { connect_sem.wait }
71
+ Timeout::timeout(@connect_timeout) { iq_received_sem.wait }
72
+ connect_sem.wait
70
73
  rescue Timeout::Error
71
74
  @stream.delete_iq_callback(self)
72
75
  end
@@ -43,7 +43,7 @@ module Jabber
43
43
  identity.send(field).to_s
44
44
  end.join('/') + '<'
45
45
  end.join
46
-
46
+
47
47
  # 4. Sort the supported service discovery features. [15]
48
48
  features.sort! do |feature1,feature2|
49
49
  feature1.var <=> feature2.var
@@ -71,7 +71,7 @@ module Jabber
71
71
  # 7.1. Append the XML character data of the FORM_TYPE field's
72
72
  # <value/> element, followed by the '<' character.
73
73
  fform_type = form.field('FORM_TYPE')
74
- form_type = fform_type ? fform_type.values.to_s : nil
74
+ form_type = fform_type ? fform_type.first_element_text('value') : nil
75
75
  s += "#{form_type}<"
76
76
 
77
77
  # 7.2. Sort the fields by the value of the "var" attribute.
@@ -27,6 +27,7 @@ module Jabber
27
27
  def initialize(jid)
28
28
  super()
29
29
  @jid = (jid.kind_of?(JID) ? jid : JID.new(jid.to_s))
30
+ @authenticated = false
30
31
  end
31
32
 
32
33
  ##
@@ -113,6 +114,7 @@ module Jabber
113
114
  else
114
115
  auth_nonsasl(password)
115
116
  end
117
+ @authenticated = true
116
118
  rescue
117
119
  Jabber::debuglog("#{$!.class}: #{$!}\n#{$!.backtrace.join("\n")}")
118
120
  raise ClientAuthenticationFailure.new, $!.to_s
@@ -133,6 +135,7 @@ module Jabber
133
135
  end
134
136
 
135
137
  jid = nil
138
+ semaphore = Semaphore.new
136
139
  send_with_id(iq) do |reply|
137
140
  reply_bind = reply.first_element('bind')
138
141
  if reply_bind
@@ -141,7 +144,9 @@ module Jabber
141
144
  jid = JID.new(reported_jid.text)
142
145
  end
143
146
  end
147
+ semaphore.run
144
148
  end
149
+ semaphore.wait
145
150
  jid
146
151
  end
147
152
 
@@ -171,13 +176,13 @@ module Jabber
171
176
  sasl.auth(password)
172
177
 
173
178
  # Restart stream after SASL auth
174
- stop
175
- start
179
+ restart
176
180
  # And wait for features - again
177
181
  @features_sem.wait
178
182
 
179
183
  # Resource binding (RFC3920 - 7)
180
184
  if @stream_features.has_key? 'bind'
185
+ Jabber::debuglog("**********Handling bind")
181
186
  @jid = bind(@jid.resource)
182
187
  end
183
188
 
@@ -187,10 +192,19 @@ module Jabber
187
192
  session = iq.add REXML::Element.new('session')
188
193
  session.add_namespace @stream_features['session']
189
194
 
190
- send_with_id(iq)
195
+ semaphore = Semaphore.new
196
+ send_with_id(iq) {
197
+ semaphore.run
198
+ }
199
+ semaphore.wait
191
200
  end
192
201
  end
193
202
 
203
+ def restart
204
+ stop
205
+ start
206
+ end
207
+
194
208
  ##
195
209
  # See Client#auth_anonymous_sasl
196
210
  def auth_anonymous
@@ -239,7 +253,7 @@ module Jabber
239
253
  authset = Iq.new_authset(@jid, password)
240
254
  end
241
255
  send_with_id(authset)
242
- $defout.flush
256
+ $>.flush
243
257
 
244
258
  true
245
259
  end
@@ -19,8 +19,9 @@ module Jabber
19
19
  # before proceeding
20
20
  attr_accessor :features_timeout
21
21
 
22
- # Keep-alive interval in seconds, defaults to 60
23
- # (see private method keepalive_loop for implementation details)
22
+ # Keep-alive interval in seconds, or nil to disable keepalive,
23
+ # defaults to 60 (see private method keepalive_loop for
24
+ # implementation details)
24
25
  attr_accessor :keepalive_interval
25
26
 
26
27
  # Allow TLS negotiation? Defaults to true
@@ -78,9 +79,11 @@ module Jabber
78
79
 
79
80
  accept_features
80
81
 
81
- @keepaliveThread = Thread.new do
82
- Thread.current.abort_on_exception = true
83
- keepalive_loop
82
+ unless @keepalive_interval.nil?
83
+ @keepaliveThread = Thread.new do
84
+ Thread.current.abort_on_exception = true
85
+ keepalive_loop
86
+ end
84
87
  end
85
88
  end
86
89