xmpp4r 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/ChangeLog +12 -0
  2. data/Rakefile +2 -4
  3. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +6 -6
  4. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +3 -3
  5. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +5 -5
  6. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +17 -4
  7. data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +5 -0
  8. data/data/doc/xmpp4r/examples/basic/echo_threaded.rb +6 -2
  9. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +13 -0
  10. data/lib/xmpp4r.rb +0 -6
  11. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +6 -7
  12. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +5 -6
  13. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +3 -5
  14. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +1 -1
  15. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +10 -8
  16. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +3 -5
  17. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +11 -17
  18. data/lib/xmpp4r/bytestreams/iq/si.rb +13 -32
  19. data/lib/xmpp4r/callbacks.rb +124 -0
  20. data/lib/xmpp4r/client.rb +2 -5
  21. data/lib/xmpp4r/command/helper/responder.rb +53 -0
  22. data/lib/xmpp4r/command/iq/command.rb +154 -0
  23. data/lib/xmpp4r/connection.rb +49 -12
  24. data/lib/xmpp4r/dataforms/x/data.rb +66 -29
  25. data/lib/xmpp4r/delay/x/delay.rb +2 -3
  26. data/lib/xmpp4r/discovery/iq/discoinfo.rb +20 -33
  27. data/lib/xmpp4r/discovery/iq/discoitems.rb +5 -28
  28. data/lib/xmpp4r/error.rb +5 -10
  29. data/lib/xmpp4r/feature_negotiation/iq/feature.rb +2 -20
  30. data/lib/xmpp4r/httpbinding.rb +5 -0
  31. data/lib/xmpp4r/httpbinding/client.rb +285 -0
  32. data/lib/xmpp4r/iq.rb +22 -41
  33. data/lib/xmpp4r/message.rb +8 -38
  34. data/lib/xmpp4r/muc.rb +2 -0
  35. data/lib/xmpp4r/muc/helper/mucclient.rb +50 -1
  36. data/lib/xmpp4r/muc/helper/simplemucclient.rb +2 -2
  37. data/lib/xmpp4r/muc/iq/mucowner.rb +11 -0
  38. data/lib/xmpp4r/muc/x/muc.rb +2 -30
  39. data/lib/xmpp4r/muc/x/mucuserinvite.rb +4 -2
  40. data/lib/xmpp4r/muc/x/mucuseritem.rb +4 -2
  41. data/lib/xmpp4r/presence.rb +7 -35
  42. data/lib/xmpp4r/pubsub.rb +1 -0
  43. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +174 -0
  44. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +153 -0
  45. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +326 -0
  46. data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
  47. data/lib/xmpp4r/pubsub/stanzas/event.rb +49 -0
  48. data/lib/xmpp4r/pubsub/stanzas/item.rb +27 -0
  49. data/lib/xmpp4r/pubsub/stanzas/items.rb +35 -0
  50. data/lib/xmpp4r/pubsub/stanzas/subscription.rb +58 -0
  51. data/lib/xmpp4r/query.rb +4 -32
  52. data/lib/xmpp4r/rexmladdons.rb +7 -772
  53. data/lib/xmpp4r/roster/helper/roster.rb +29 -50
  54. data/lib/xmpp4r/roster/iq/roster.rb +6 -35
  55. data/lib/xmpp4r/roster/x/roster.rb +13 -30
  56. data/lib/xmpp4r/rpc.rb +2 -0
  57. data/lib/xmpp4r/rpc/helper/client.rb +114 -0
  58. data/lib/xmpp4r/rpc/helper/server.rb +75 -0
  59. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +57 -0
  60. data/lib/xmpp4r/rpc/iq/rpc.rb +24 -0
  61. data/lib/xmpp4r/sasl.rb +1 -1
  62. data/lib/xmpp4r/semaphore.rb +38 -0
  63. data/lib/xmpp4r/stream.rb +104 -165
  64. data/lib/xmpp4r/streamparser.rb +2 -2
  65. data/lib/xmpp4r/vcard/iq/vcard.rb +5 -12
  66. data/lib/xmpp4r/version/helper/responder.rb +2 -1
  67. data/lib/xmpp4r/version/iq/version.rb +6 -18
  68. data/lib/xmpp4r/x.rb +20 -26
  69. data/lib/xmpp4r/xmpp4r.rb +1 -1
  70. data/lib/xmpp4r/xmppelement.rb +152 -0
  71. data/lib/xmpp4r/{xmlstanza.rb → xmppstanza.rb} +17 -29
  72. data/setup.rb +1 -0
  73. data/test/bytestreams/tc_ibb.rb +8 -8
  74. data/test/dataforms/tc_data.rb +81 -0
  75. data/test/lib/clienttester.rb +20 -17
  76. data/test/muc/tc_muc_mucclient.rb +48 -23
  77. data/test/muc/tc_muc_simplemucclient.rb +7 -4
  78. data/test/muc/tc_mucowner.rb +50 -0
  79. data/test/pubsub/tc_helper.rb +227 -0
  80. data/test/roster/tc_helper.rb +181 -55
  81. data/test/roster/tc_iqqueryroster.rb +33 -0
  82. data/test/roster/tc_xroster.rb +6 -3
  83. data/test/rpc/tc_helper.rb +84 -0
  84. data/test/tc_callbacks.rb +2 -1
  85. data/test/tc_class_names.rb +9 -1
  86. data/test/tc_error.rb +1 -0
  87. data/test/tc_iq.rb +13 -12
  88. data/test/tc_message.rb +1 -0
  89. data/test/tc_presence.rb +1 -0
  90. data/test/tc_rexml.rb +1 -1
  91. data/test/tc_stream.rb +147 -102
  92. data/test/tc_streamComponent.rb +94 -0
  93. data/test/tc_streamError.rb +67 -29
  94. data/test/tc_streamSend.rb +1 -1
  95. data/test/tc_xmppstanza.rb +125 -0
  96. data/test/ts_xmpp4r.rb +37 -28
  97. data/test/version/tc_helper.rb +14 -0
  98. data/test/version/tc_iqqueryversion.rb +4 -3
  99. metadata +163 -123
  100. data/data/doc/xmpp4r/examples/basic/echo_nonthreaded.rb +0 -32
  101. data/lib/callbacks.rb +0 -122
  102. data/test/tc_streamThreaded.rb +0 -168
  103. data/test/tc_xmlstanza.rb +0 -76
@@ -1,168 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- $:.unshift '../lib'
4
-
5
- require 'tempfile'
6
- require 'test/unit'
7
- require 'socket'
8
- require 'xmpp4r/stream'
9
- include Jabber
10
-
11
- class StreamThreadedTest < Test::Unit::TestCase
12
- def setup
13
- @tmpfile = Tempfile::new("StreamSendTest")
14
- @tmpfilepath = @tmpfile.path()
15
- @tmpfile.unlink
16
- @servlisten = UNIXServer::new(@tmpfilepath)
17
- thServer = Thread.new { @server = @servlisten.accept }
18
- @iostream = UNIXSocket::new(@tmpfilepath)
19
- n = 0
20
- while not defined? @server and n < 10
21
- sleep 0.1
22
- n += 1
23
- end
24
- @stream = Stream::new
25
- @stream.start(@iostream)
26
- end
27
-
28
- def teardown
29
- @stream.close
30
- @server.close
31
- end
32
-
33
- ##
34
- # tests that connection really waits the call to process() to dispatch
35
- # stanzas to filters
36
- def test_process
37
- called = false
38
- @stream.add_xml_callback { called = true }
39
- assert(!called)
40
- @server.puts('<stream:stream>')
41
- @server.flush
42
- assert(called)
43
- end
44
-
45
- def test_process100
46
- @server.puts('<stream:stream>')
47
- @server.flush
48
-
49
- n = 0
50
- @stream.add_message_callback { n += 1 }
51
-
52
- 100.times {
53
- @server.puts('<message/>')
54
- @server.flush
55
- }
56
-
57
- assert_equal(100, n)
58
-
59
- @server.puts('<message/>' * 100)
60
- @server.flush
61
- sleep 0.1
62
-
63
- assert_equal(200, n)
64
- end
65
-
66
- def test_send
67
- @server.puts('<stream:stream>')
68
- @server.flush
69
-
70
- Thread.new {
71
- assert_equal(Iq.new(:get).to_s, @server.gets('>'))
72
- @stream.receive(Iq.new(:result))
73
- }
74
-
75
- called = 0
76
- @stream.send(Iq.new(:get)) { |reply|
77
- called += 1
78
- if reply.kind_of? Iq and reply.type == :result
79
- true
80
- else
81
- false
82
- end
83
- }
84
-
85
- assert_equal(1, called)
86
- end
87
-
88
- def test_send_nested
89
- @server.puts('<stream:stream>')
90
- @server.flush
91
- finished = Mutex.new
92
- finished.lock
93
-
94
- Thread.new {
95
- assert_equal(Iq.new(:get).to_s, @server.gets('>'))
96
- @server.puts(Iq.new(:result).set_id('1').to_s)
97
- @server.flush
98
- assert_equal(Iq.new(:set).to_s, @server.gets('>'))
99
- @server.puts(Iq.new(:result).set_id('2').to_s)
100
- @server.flush
101
- assert_equal(Iq.new(:get).to_s, @server.gets('>'))
102
- @server.puts(Iq.new(:result).set_id('3').to_s)
103
- @server.flush
104
-
105
- finished.unlock
106
- }
107
-
108
- called_outer = 0
109
- called_inner = 0
110
-
111
- @stream.send(Iq.new(:get)) { |reply|
112
- called_outer += 1
113
- assert_kind_of(Iq, reply)
114
- assert_equal(:result, reply.type)
115
-
116
- if reply.id == '1'
117
- @stream.send(Iq.new(:set)) { |reply|
118
- called_inner += 1
119
- assert_kind_of(Iq, reply)
120
- assert_equal(:result, reply.type)
121
- assert_equal('2', reply.id)
122
-
123
- @stream.send(Iq.new(:get))
124
-
125
- true
126
- }
127
- false
128
- elsif reply.id == '3'
129
- true
130
- else
131
- false
132
- end
133
- }
134
-
135
- assert_equal(2, called_outer)
136
- assert_equal(1, called_inner)
137
-
138
- finished.lock
139
- end
140
-
141
- def test_bidi
142
- @server.puts('<stream:stream>')
143
- @server.flush
144
- finished = Mutex.new
145
- ok = true
146
-
147
- Thread.new {
148
- 100.times { |i|
149
- ok &&= (Iq.new(:get).set_id(i).to_s == @server.gets('>'))
150
- @server.puts(Iq.new(:result).set_id(i).to_s)
151
- @server.flush
152
- }
153
- finished.unlock
154
- }
155
-
156
- 100.times { |i|
157
- @stream.send(Iq.new(:get).set_id(i)) { |reply|
158
- ok &&= reply.kind_of? Iq
159
- ok &&= (:result == reply.type)
160
- ok &&= (i.to_s == reply.id)
161
- true
162
- }
163
- }
164
-
165
- assert(ok)
166
- 2.times { finished.lock }
167
- end
168
- end
@@ -1,76 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- $:.unshift '../lib'
4
-
5
- require 'test/unit'
6
- require 'socket'
7
- require 'xmpp4r/rexmladdons'
8
- require 'xmpp4r/xmlstanza'
9
- require 'xmpp4r/iq'
10
- include Jabber
11
-
12
- class XMLStanzaTest < Test::Unit::TestCase
13
-
14
- def test_from
15
- x = XMLStanza::new("message")
16
- assert_equal(nil, x.from)
17
- assert_equal(x, x.set_from("blop"))
18
- assert_equal("blop", x.from.to_s)
19
- x.from = "tada"
20
- assert_equal("tada", x.from.to_s)
21
- end
22
-
23
- def test_to
24
- x = XMLStanza::new("message")
25
- assert_equal(nil, x.to)
26
- assert_equal(x, x.set_to("blop"))
27
- assert_equal("blop", x.to.to_s)
28
- x.to = "tada"
29
- assert_equal("tada", x.to.to_s)
30
- end
31
-
32
- def test_id
33
- x = XMLStanza::new("message")
34
- assert_equal(nil, x.id)
35
- assert_equal(x, x.set_id("blop"))
36
- assert_equal("blop", x.id)
37
- x.id = "tada"
38
- assert_equal("tada", x.id)
39
- end
40
-
41
- def test_type
42
- x = XMLStanza::new("message")
43
- assert_equal(nil, x.type)
44
- assert_equal(x, x.set_type("blop"))
45
- assert_equal("blop", x.type)
46
- x.type = "tada"
47
- assert_equal("tada", x.type)
48
- end
49
-
50
- def test_import
51
- x = XMLStanza::new("iq")
52
- x.id = "heya"
53
- q = x.add_element("query")
54
- q.add_namespace("about:blank")
55
- q.add_element("b").text = "I am b"
56
- q.add_text("I am text")
57
- q.add_element("a").add_attribute("href", "http://home.gna.org/xmpp4r/")
58
- x.add_text("yow")
59
- x.add_element("query")
60
-
61
- iq = Iq.import(x)
62
-
63
- assert_equal(x.id, iq.id)
64
- assert_equal(q.to_s, iq.query.to_s)
65
- assert_equal(x.to_s, iq.to_s)
66
- assert_equal(q.namespace, iq.queryns)
67
- end
68
-
69
- def test_error
70
- x = XMLStanza::new("presence")
71
- assert_equal(nil, x.error)
72
- x.typed_add(REXML::Element.new('error'))
73
- assert_equal('<error/>', x.error.to_s)
74
- assert_equal(Error, x.error.class)
75
- end
76
- end