xmpp4r 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +12 -0
- data/Rakefile +2 -4
- data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +6 -6
- data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +3 -3
- data/data/doc/xmpp4r/examples/advanced/minimuc.rb +5 -5
- data/data/doc/xmpp4r/examples/advanced/xmpping.rb +17 -4
- data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +5 -0
- data/data/doc/xmpp4r/examples/basic/echo_threaded.rb +6 -2
- data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +13 -0
- data/lib/xmpp4r.rb +0 -6
- data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +6 -7
- data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +5 -6
- data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +3 -5
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +1 -1
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +10 -8
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +3 -5
- data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +11 -17
- data/lib/xmpp4r/bytestreams/iq/si.rb +13 -32
- data/lib/xmpp4r/callbacks.rb +124 -0
- data/lib/xmpp4r/client.rb +2 -5
- data/lib/xmpp4r/command/helper/responder.rb +53 -0
- data/lib/xmpp4r/command/iq/command.rb +154 -0
- data/lib/xmpp4r/connection.rb +49 -12
- data/lib/xmpp4r/dataforms/x/data.rb +66 -29
- data/lib/xmpp4r/delay/x/delay.rb +2 -3
- data/lib/xmpp4r/discovery/iq/discoinfo.rb +20 -33
- data/lib/xmpp4r/discovery/iq/discoitems.rb +5 -28
- data/lib/xmpp4r/error.rb +5 -10
- data/lib/xmpp4r/feature_negotiation/iq/feature.rb +2 -20
- data/lib/xmpp4r/httpbinding.rb +5 -0
- data/lib/xmpp4r/httpbinding/client.rb +285 -0
- data/lib/xmpp4r/iq.rb +22 -41
- data/lib/xmpp4r/message.rb +8 -38
- data/lib/xmpp4r/muc.rb +2 -0
- data/lib/xmpp4r/muc/helper/mucclient.rb +50 -1
- data/lib/xmpp4r/muc/helper/simplemucclient.rb +2 -2
- data/lib/xmpp4r/muc/iq/mucowner.rb +11 -0
- data/lib/xmpp4r/muc/x/muc.rb +2 -30
- data/lib/xmpp4r/muc/x/mucuserinvite.rb +4 -2
- data/lib/xmpp4r/muc/x/mucuseritem.rb +4 -2
- data/lib/xmpp4r/presence.rb +7 -35
- data/lib/xmpp4r/pubsub.rb +1 -0
- data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +174 -0
- data/lib/xmpp4r/pubsub/helper/nodehelper.rb +153 -0
- data/lib/xmpp4r/pubsub/helper/servicehelper.rb +326 -0
- data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
- data/lib/xmpp4r/pubsub/stanzas/event.rb +49 -0
- data/lib/xmpp4r/pubsub/stanzas/item.rb +27 -0
- data/lib/xmpp4r/pubsub/stanzas/items.rb +35 -0
- data/lib/xmpp4r/pubsub/stanzas/subscription.rb +58 -0
- data/lib/xmpp4r/query.rb +4 -32
- data/lib/xmpp4r/rexmladdons.rb +7 -772
- data/lib/xmpp4r/roster/helper/roster.rb +29 -50
- data/lib/xmpp4r/roster/iq/roster.rb +6 -35
- data/lib/xmpp4r/roster/x/roster.rb +13 -30
- data/lib/xmpp4r/rpc.rb +2 -0
- data/lib/xmpp4r/rpc/helper/client.rb +114 -0
- data/lib/xmpp4r/rpc/helper/server.rb +75 -0
- data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +57 -0
- data/lib/xmpp4r/rpc/iq/rpc.rb +24 -0
- data/lib/xmpp4r/sasl.rb +1 -1
- data/lib/xmpp4r/semaphore.rb +38 -0
- data/lib/xmpp4r/stream.rb +104 -165
- data/lib/xmpp4r/streamparser.rb +2 -2
- data/lib/xmpp4r/vcard/iq/vcard.rb +5 -12
- data/lib/xmpp4r/version/helper/responder.rb +2 -1
- data/lib/xmpp4r/version/iq/version.rb +6 -18
- data/lib/xmpp4r/x.rb +20 -26
- data/lib/xmpp4r/xmpp4r.rb +1 -1
- data/lib/xmpp4r/xmppelement.rb +152 -0
- data/lib/xmpp4r/{xmlstanza.rb → xmppstanza.rb} +17 -29
- data/setup.rb +1 -0
- data/test/bytestreams/tc_ibb.rb +8 -8
- data/test/dataforms/tc_data.rb +81 -0
- data/test/lib/clienttester.rb +20 -17
- data/test/muc/tc_muc_mucclient.rb +48 -23
- data/test/muc/tc_muc_simplemucclient.rb +7 -4
- data/test/muc/tc_mucowner.rb +50 -0
- data/test/pubsub/tc_helper.rb +227 -0
- data/test/roster/tc_helper.rb +181 -55
- data/test/roster/tc_iqqueryroster.rb +33 -0
- data/test/roster/tc_xroster.rb +6 -3
- data/test/rpc/tc_helper.rb +84 -0
- data/test/tc_callbacks.rb +2 -1
- data/test/tc_class_names.rb +9 -1
- data/test/tc_error.rb +1 -0
- data/test/tc_iq.rb +13 -12
- data/test/tc_message.rb +1 -0
- data/test/tc_presence.rb +1 -0
- data/test/tc_rexml.rb +1 -1
- data/test/tc_stream.rb +147 -102
- data/test/tc_streamComponent.rb +94 -0
- data/test/tc_streamError.rb +67 -29
- data/test/tc_streamSend.rb +1 -1
- data/test/tc_xmppstanza.rb +125 -0
- data/test/ts_xmpp4r.rb +37 -28
- data/test/version/tc_helper.rb +14 -0
- data/test/version/tc_iqqueryversion.rb +4 -3
- metadata +163 -123
- data/data/doc/xmpp4r/examples/basic/echo_nonthreaded.rb +0 -32
- data/lib/callbacks.rb +0 -122
- data/test/tc_streamThreaded.rb +0 -168
- data/test/tc_xmlstanza.rb +0 -76
data/test/tc_streamThreaded.rb
DELETED
@@ -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
|
data/test/tc_xmlstanza.rb
DELETED
@@ -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
|