gmcmillan-xmpp4r 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +91 -0
  3. data/COPYING +340 -0
  4. data/LICENSE +59 -0
  5. data/README.rdoc +122 -0
  6. data/README_ruby19.txt +43 -0
  7. data/Rakefile +258 -0
  8. data/data/doc/xmpp4r/examples/advanced/adventure/README +56 -0
  9. data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +23 -0
  10. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +136 -0
  11. data/data/doc/xmpp4r/examples/advanced/adventure/cube.xml +15 -0
  12. data/data/doc/xmpp4r/examples/advanced/adventure/tower.xml +69 -0
  13. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +424 -0
  14. data/data/doc/xmpp4r/examples/advanced/fileserve.conf +11 -0
  15. data/data/doc/xmpp4r/examples/advanced/fileserve.rb +346 -0
  16. data/data/doc/xmpp4r/examples/advanced/getonline.rb +56 -0
  17. data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +315 -0
  18. data/data/doc/xmpp4r/examples/advanced/migrate.rb +88 -0
  19. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +266 -0
  20. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
  21. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
  22. data/data/doc/xmpp4r/examples/advanced/recvfile.rb +85 -0
  23. data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +129 -0
  24. data/data/doc/xmpp4r/examples/advanced/sendfile.conf +10 -0
  25. data/data/doc/xmpp4r/examples/advanced/sendfile.rb +72 -0
  26. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +51 -0
  27. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +43 -0
  28. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +10 -0
  29. data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +109 -0
  30. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +146 -0
  31. data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +14 -0
  32. data/data/doc/xmpp4r/examples/basic/change_password.rb +41 -0
  33. data/data/doc/xmpp4r/examples/basic/client.rb +70 -0
  34. data/data/doc/xmpp4r/examples/basic/component.rb +11 -0
  35. data/data/doc/xmpp4r/examples/basic/echo.rb +37 -0
  36. data/data/doc/xmpp4r/examples/basic/jabbersend.rb +41 -0
  37. data/data/doc/xmpp4r/examples/basic/mass_sender.rb +68 -0
  38. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +12 -0
  39. data/data/doc/xmpp4r/examples/basic/mucinfo.rb +41 -0
  40. data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +82 -0
  41. data/data/doc/xmpp4r/examples/basic/register.rb +42 -0
  42. data/data/doc/xmpp4r/examples/basic/remove_registration.rb +18 -0
  43. data/data/doc/xmpp4r/examples/basic/roster.rb +44 -0
  44. data/data/doc/xmpp4r/examples/basic/rosterprint.rb +50 -0
  45. data/data/doc/xmpp4r/examples/basic/rosterrename.rb +34 -0
  46. data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +171 -0
  47. data/data/doc/xmpp4r/examples/basic/send_vcard.rb +67 -0
  48. data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
  49. data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
  50. data/data/doc/xmpp4r/examples/basic/versionbot.rb +75 -0
  51. data/lib/xmpp4r.rb +118 -0
  52. data/lib/xmpp4r/base64.rb +32 -0
  53. data/lib/xmpp4r/bytestreams.rb +15 -0
  54. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +321 -0
  55. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +257 -0
  56. data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +31 -0
  57. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +54 -0
  58. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +153 -0
  59. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +86 -0
  60. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +198 -0
  61. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +65 -0
  62. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +82 -0
  63. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +170 -0
  64. data/lib/xmpp4r/bytestreams/iq/si.rb +206 -0
  65. data/lib/xmpp4r/callbacks.rb +133 -0
  66. data/lib/xmpp4r/caps.rb +1 -0
  67. data/lib/xmpp4r/caps/c.rb +67 -0
  68. data/lib/xmpp4r/caps/helper/generator.rb +160 -0
  69. data/lib/xmpp4r/caps/helper/helper.rb +84 -0
  70. data/lib/xmpp4r/client.rb +345 -0
  71. data/lib/xmpp4r/command/helper/responder.rb +53 -0
  72. data/lib/xmpp4r/command/iq/command.rb +154 -0
  73. data/lib/xmpp4r/component.rb +103 -0
  74. data/lib/xmpp4r/connection.rb +231 -0
  75. data/lib/xmpp4r/dataforms.rb +5 -0
  76. data/lib/xmpp4r/dataforms/x/data.rb +297 -0
  77. data/lib/xmpp4r/debuglog.rb +63 -0
  78. data/lib/xmpp4r/delay.rb +5 -0
  79. data/lib/xmpp4r/delay/x/delay.rb +99 -0
  80. data/lib/xmpp4r/discovery.rb +8 -0
  81. data/lib/xmpp4r/discovery/helper/helper.rb +58 -0
  82. data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
  83. data/lib/xmpp4r/discovery/iq/discoinfo.rb +211 -0
  84. data/lib/xmpp4r/discovery/iq/discoitems.rb +147 -0
  85. data/lib/xmpp4r/entity_time.rb +6 -0
  86. data/lib/xmpp4r/entity_time/iq.rb +45 -0
  87. data/lib/xmpp4r/entity_time/responder.rb +57 -0
  88. data/lib/xmpp4r/errors.rb +284 -0
  89. data/lib/xmpp4r/feature_negotiation.rb +5 -0
  90. data/lib/xmpp4r/feature_negotiation/iq/feature.rb +28 -0
  91. data/lib/xmpp4r/framework/base.rb +55 -0
  92. data/lib/xmpp4r/framework/bot.rb +148 -0
  93. data/lib/xmpp4r/httpbinding.rb +5 -0
  94. data/lib/xmpp4r/httpbinding/client.rb +275 -0
  95. data/lib/xmpp4r/idgenerator.rb +37 -0
  96. data/lib/xmpp4r/iq.rb +221 -0
  97. data/lib/xmpp4r/jid.rb +167 -0
  98. data/lib/xmpp4r/last.rb +2 -0
  99. data/lib/xmpp4r/last/helper/helper.rb +37 -0
  100. data/lib/xmpp4r/last/iq/last.rb +67 -0
  101. data/lib/xmpp4r/location.rb +2 -0
  102. data/lib/xmpp4r/location/helper/helper.rb +56 -0
  103. data/lib/xmpp4r/location/location.rb +179 -0
  104. data/lib/xmpp4r/message.rb +226 -0
  105. data/lib/xmpp4r/muc.rb +14 -0
  106. data/lib/xmpp4r/muc/helper/mucbrowser.rb +92 -0
  107. data/lib/xmpp4r/muc/helper/mucclient.rb +469 -0
  108. data/lib/xmpp4r/muc/helper/simplemucclient.rb +332 -0
  109. data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
  110. data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
  111. data/lib/xmpp4r/muc/iq/mucowner.rb +15 -0
  112. data/lib/xmpp4r/muc/item.rb +143 -0
  113. data/lib/xmpp4r/muc/x/muc.rb +70 -0
  114. data/lib/xmpp4r/muc/x/mucuserinvite.rb +60 -0
  115. data/lib/xmpp4r/muc/x/mucuseritem.rb +36 -0
  116. data/lib/xmpp4r/presence.rb +232 -0
  117. data/lib/xmpp4r/pubsub.rb +8 -0
  118. data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
  119. data/lib/xmpp4r/pubsub/children/event.rb +49 -0
  120. data/lib/xmpp4r/pubsub/children/item.rb +35 -0
  121. data/lib/xmpp4r/pubsub/children/items.rb +53 -0
  122. data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
  123. data/lib/xmpp4r/pubsub/children/publish.rb +38 -0
  124. data/lib/xmpp4r/pubsub/children/retract.rb +41 -0
  125. data/lib/xmpp4r/pubsub/children/subscription.rb +62 -0
  126. data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
  127. data/lib/xmpp4r/pubsub/children/unsubscribe.rb +63 -0
  128. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +129 -0
  129. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +156 -0
  130. data/lib/xmpp4r/pubsub/helper/oauth_service_helper.rb +90 -0
  131. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +490 -0
  132. data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
  133. data/lib/xmpp4r/query.rb +15 -0
  134. data/lib/xmpp4r/reliable.rb +168 -0
  135. data/lib/xmpp4r/rexmladdons.rb +197 -0
  136. data/lib/xmpp4r/roster.rb +7 -0
  137. data/lib/xmpp4r/roster/helper/roster.rb +532 -0
  138. data/lib/xmpp4r/roster/iq/roster.rb +215 -0
  139. data/lib/xmpp4r/roster/x/roster.rb +138 -0
  140. data/lib/xmpp4r/rpc.rb +2 -0
  141. data/lib/xmpp4r/rpc/helper/client.rb +123 -0
  142. data/lib/xmpp4r/rpc/helper/server.rb +74 -0
  143. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +67 -0
  144. data/lib/xmpp4r/rpc/iq/rpc.rb +23 -0
  145. data/lib/xmpp4r/sasl.rb +259 -0
  146. data/lib/xmpp4r/semaphore.rb +38 -0
  147. data/lib/xmpp4r/stream.rb +611 -0
  148. data/lib/xmpp4r/streamparser.rb +66 -0
  149. data/lib/xmpp4r/test/listener_mocker.rb +118 -0
  150. data/lib/xmpp4r/tune.rb +2 -0
  151. data/lib/xmpp4r/tune/helper/helper.rb +58 -0
  152. data/lib/xmpp4r/tune/tune.rb +113 -0
  153. data/lib/xmpp4r/vcard.rb +6 -0
  154. data/lib/xmpp4r/vcard/helper/vcard.rb +84 -0
  155. data/lib/xmpp4r/vcard/iq/vcard.rb +109 -0
  156. data/lib/xmpp4r/version.rb +7 -0
  157. data/lib/xmpp4r/version/helper/responder.rb +72 -0
  158. data/lib/xmpp4r/version/helper/simpleresponder.rb +44 -0
  159. data/lib/xmpp4r/version/iq/version.rb +105 -0
  160. data/lib/xmpp4r/x.rb +37 -0
  161. data/lib/xmpp4r/xhtml.rb +1 -0
  162. data/lib/xmpp4r/xhtml/html.rb +115 -0
  163. data/lib/xmpp4r/xmpp4r.rb +20 -0
  164. data/lib/xmpp4r/xmppelement.rb +168 -0
  165. data/lib/xmpp4r/xmppstanza.rb +162 -0
  166. data/setup.rb +1586 -0
  167. data/test/bytestreams/tc_ibb.rb +188 -0
  168. data/test/bytestreams/tc_socks5bytestreams.rb +114 -0
  169. data/test/caps/tc_helper.rb +158 -0
  170. data/test/dataforms/tc_data.rb +81 -0
  171. data/test/delay/tc_xdelay.rb +51 -0
  172. data/test/discovery/tc_responder.rb +91 -0
  173. data/test/entity_time/tc_responder.rb +65 -0
  174. data/test/last/tc_helper.rb +75 -0
  175. data/test/lib/assert_equal_xml.rb +14 -0
  176. data/test/lib/clienttester.rb +149 -0
  177. data/test/muc/tc_muc_mucclient.rb +834 -0
  178. data/test/muc/tc_muc_simplemucclient.rb +114 -0
  179. data/test/muc/tc_mucowner.rb +50 -0
  180. data/test/pubsub/tc_helper.rb +785 -0
  181. data/test/pubsub/tc_nodeconfig.rb +61 -0
  182. data/test/pubsub/tc_subscriptionconfig.rb +41 -0
  183. data/test/roster/tc_helper.rb +523 -0
  184. data/test/roster/tc_iqqueryroster.rb +173 -0
  185. data/test/roster/tc_xroster.rb +73 -0
  186. data/test/rpc/tc_helper.rb +96 -0
  187. data/test/tc_callbacks.rb +129 -0
  188. data/test/tc_class_names.rb +146 -0
  189. data/test/tc_client.rb +30 -0
  190. data/test/tc_errors.rb +146 -0
  191. data/test/tc_idgenerator.rb +30 -0
  192. data/test/tc_iq.rb +113 -0
  193. data/test/tc_iqquery.rb +31 -0
  194. data/test/tc_jid.rb +204 -0
  195. data/test/tc_presence.rb +150 -0
  196. data/test/tc_rexml.rb +139 -0
  197. data/test/tc_stream.rb +193 -0
  198. data/test/tc_streamComponent.rb +105 -0
  199. data/test/tc_streamError.rb +129 -0
  200. data/test/tc_streamSend.rb +59 -0
  201. data/test/tc_streamparser.rb +137 -0
  202. data/test/tc_xmppstanza.rb +135 -0
  203. data/test/ts_xmpp4r.rb +44 -0
  204. data/test/tune/tc_helper_recv.rb +82 -0
  205. data/test/tune/tc_helper_send.rb +74 -0
  206. data/test/tune/tc_tune.rb +79 -0
  207. data/test/vcard/tc_helper.rb +49 -0
  208. data/test/vcard/tc_iqvcard.rb +62 -0
  209. data/test/version/tc_helper.rb +60 -0
  210. data/test/version/tc_iqqueryversion.rb +97 -0
  211. data/test/xhtml/tc_html.rb +41 -0
  212. data/tools/gen_requires.bash +31 -0
  213. data/tools/xmpp4r-gemspec-test.rb +11 -0
  214. data/xmpp4r.gemspec +249 -0
  215. metadata +299 -0
@@ -0,0 +1,834 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ $:.unshift File::dirname(__FILE__) + '/../../lib'
5
+
6
+ require 'test/unit'
7
+ require File::dirname(__FILE__) + '/../lib/clienttester'
8
+ require 'xmpp4r/muc'
9
+ require 'xmpp4r/semaphore'
10
+ include Jabber
11
+
12
+ class MUCClientTest < Test::Unit::TestCase
13
+ include ClientTester
14
+
15
+ def test_new1
16
+ m = MUC::MUCClient.new(@client)
17
+ assert_equal(nil, m.jid)
18
+ assert_equal(nil, m.my_jid)
19
+ assert_equal({}, m.roster)
20
+ assert(!m.active?)
21
+ end
22
+
23
+ # JEP-0045: 6.3 Entering a Room
24
+ def test_enter_room
25
+ state { |pres|
26
+ assert_kind_of(Presence, pres)
27
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
28
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/thirdwitch'), pres.to)
29
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
30
+ "<error code='400' type='modify'>" +
31
+ "<jid-malformed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
32
+ "</error></presence>")
33
+ }
34
+ state { |pres|
35
+ assert_kind_of(Presence, pres)
36
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
37
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/thirdwitch'), pres.to)
38
+ send("<presence from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'>" +
39
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='owner' role='moderator'/></x>" +
40
+ "</presence>" +
41
+ "<presence from='darkcave@macbeth.shakespeare.lit/secondwitch' to='hag66@shakespeare.lit/pda'>" +
42
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='admin' role='moderator'/></x>" +
43
+ "</presence>" +
44
+ "<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
45
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
46
+ "</presence>")
47
+ }
48
+
49
+
50
+ m = MUC::MUCClient.new(@client)
51
+ m.my_jid = 'hag66@shakespeare.lit/pda'
52
+ assert(!m.active?)
53
+ assert_nil(m.room)
54
+
55
+ assert_raises(ServerError) {
56
+ m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
57
+ }
58
+ wait_state
59
+ assert(!m.active?)
60
+ assert_nil(m.room)
61
+
62
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
63
+ wait_state
64
+ assert(m.active?)
65
+ assert_equal('darkcave', m.room)
66
+ assert_equal(3, m.roster.size)
67
+ m.roster.each { |resource,pres|
68
+ assert_equal(resource, pres.from.resource)
69
+ assert_equal('darkcave', pres.from.node)
70
+ assert_equal('macbeth.shakespeare.lit', pres.from.domain)
71
+ assert_kind_of(String, resource)
72
+ assert_kind_of(Presence, pres)
73
+ assert(%w(firstwitch secondwitch thirdwitch).include?(resource))
74
+ assert_kind_of(MUC::XMUCUser, pres.x)
75
+ assert_kind_of(Array, pres.x.items)
76
+ assert_equal(1, pres.x.items.size)
77
+ }
78
+ assert_equal(:owner, m.roster['firstwitch'].x.items[0].affiliation)
79
+ assert_equal(:moderator, m.roster['firstwitch'].x.items[0].role)
80
+ assert_equal(:admin, m.roster['secondwitch'].x.items[0].affiliation)
81
+ assert_equal(:moderator, m.roster['secondwitch'].x.items[0].role)
82
+ assert_equal(:member, m.roster['thirdwitch'].x.items[0].affiliation)
83
+ assert_equal(:participant, m.roster['thirdwitch'].x.items[0].role)
84
+ assert_nil(m.roster['thirdwitch'].x.items[0].jid)
85
+
86
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='crone1@shakespeare.lit/desktop'>" +
87
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='none' jid='hag66@shakespeare.lit/pda' role='participant'/></x>" +
88
+ "</presence>")
89
+ n = 0
90
+ while m.roster.size != 3 and n < 1000
91
+ Thread::pass
92
+ n += 1
93
+ end
94
+ assert_equal(3, m.roster.size)
95
+ assert_equal(:none, m.roster['thirdwitch'].x.items[0].affiliation)
96
+ assert_equal(:participant, m.roster['thirdwitch'].x.items[0].role)
97
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), m.roster['thirdwitch'].x.items[0].jid)
98
+ end
99
+
100
+ def test_enter_room_password
101
+ state { |pres|
102
+ assert_kind_of(Presence, pres)
103
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
104
+ "<error code='401' type='auth'><not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
105
+ "</presence>")
106
+ }
107
+ state { |pres|
108
+ assert_kind_of(Presence, pres)
109
+ assert_equal('cauldron', pres.x.password)
110
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
111
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
112
+ "</presence>")
113
+ }
114
+
115
+ m = MUC::MUCClient.new(@client)
116
+ m.my_jid = 'hag66@shakespeare.lit/pda'
117
+ assert_raises(ServerError) {
118
+ m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
119
+ }
120
+ wait_state
121
+ assert(!m.active?)
122
+
123
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch', 'cauldron'))
124
+ wait_state
125
+ assert(m.active?)
126
+ end
127
+
128
+ def test_members_only_room
129
+ state { |pres|
130
+ assert_kind_of(Presence, pres)
131
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
132
+ "<error code='407' type='auth'><registration-required xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
133
+ "</presence>")
134
+ }
135
+
136
+ m = MUC::MUCClient.new(@client)
137
+ m.my_jid = 'hag66@shakespeare.lit/pda'
138
+ assert_raises(ServerError) {
139
+ m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
140
+ }
141
+ assert(!m.active?)
142
+
143
+ wait_state
144
+ end
145
+
146
+ def test_banned_users
147
+ state { |pres|
148
+ assert_kind_of(Presence, pres)
149
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
150
+ "<error code='403' type='auth'><forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
151
+ "</presence>")
152
+ }
153
+
154
+ m = MUC::MUCClient.new(@client)
155
+ m.my_jid = 'hag66@shakespeare.lit/pda'
156
+ assert_raises(ServerError) {
157
+ m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
158
+ }
159
+ assert(!m.active?)
160
+
161
+ wait_state
162
+ end
163
+
164
+ def test_nickname_conflict
165
+ state { |pres|
166
+ assert_kind_of(Presence, pres)
167
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
168
+ "<error code='409' type='cancel'><conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
169
+ "</presence>")
170
+ }
171
+
172
+ m = MUC::MUCClient.new(@client)
173
+ m.my_jid = 'hag66@shakespeare.lit/pda'
174
+ assert_raises(ServerError) {
175
+ m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
176
+ }
177
+ assert(!m.active?)
178
+
179
+ wait_state
180
+ end
181
+
182
+ def test_max_users
183
+ state { |pres|
184
+ assert_kind_of(Presence, pres)
185
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
186
+ "<error code='503' type='wait'><service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
187
+ "</presence>")
188
+ }
189
+
190
+ m = MUC::MUCClient.new(@client)
191
+ m.my_jid = 'hag66@shakespeare.lit/pda'
192
+ assert_raises(ServerError) {
193
+ m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
194
+ }
195
+ assert(!m.active?)
196
+
197
+ wait_state
198
+ end
199
+
200
+ def test_locked_room
201
+ state { |pres|
202
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
203
+ "<error code='404' type='cancel'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
204
+ "</presence>")
205
+ }
206
+
207
+ m = MUC::MUCClient.new(@client)
208
+ m.my_jid = 'hag66@shakespeare.lit/pda'
209
+ assert_raises(ServerError) {
210
+ m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
211
+ }
212
+ assert(!m.active?)
213
+ wait_state
214
+ end
215
+
216
+ def test_exit_room
217
+ state { |pres|
218
+ assert_kind_of(Presence, pres)
219
+ assert_nil(pres.type)
220
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
221
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
222
+ "</presence>")
223
+ }
224
+ state { |pres|
225
+ assert_kind_of(Presence, pres)
226
+ assert_equal(:unavailable, pres.type)
227
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
228
+ assert_nil(pres.status)
229
+ send("<presence from='darkcave@macbeth.shakespeare.lit/secondwitch' to='hag66@shakespeare.lit/pda'>" +
230
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
231
+ "</presence>")
232
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda' type='unavailable'>" +
233
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='none'/></x>" +
234
+ "</presence>")
235
+ }
236
+
237
+ ignored_stanzas = 0
238
+ @client.add_stanza_callback { |stanza|
239
+ ignored_stanzas += 1
240
+ }
241
+
242
+ m = MUC::MUCClient.new(@client)
243
+ m.my_jid = 'hag66@shakespeare.lit/pda'
244
+ assert_equal(0, ignored_stanzas)
245
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
246
+ wait_state
247
+ assert(m.active?)
248
+
249
+ assert_equal(0, ignored_stanzas)
250
+ assert_equal(m, m.exit)
251
+ wait_state
252
+ assert(!m.active?)
253
+ assert_equal(1, ignored_stanzas)
254
+ end
255
+
256
+ def test_custom_exit_message
257
+ state { |pres|
258
+ assert_kind_of(Presence, pres)
259
+ assert_nil(pres.type)
260
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
261
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
262
+ "</presence>")
263
+ }
264
+ state { |pres|
265
+ assert_kind_of(Presence, pres)
266
+ assert_equal(:unavailable, pres.type)
267
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
268
+ assert_equal('gone where the goblins go', pres.status)
269
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda' type='unavailable'>" +
270
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='none'/></x>" +
271
+ "</presence>")
272
+ }
273
+
274
+ m = MUC::MUCClient.new(@client)
275
+ m.my_jid = 'hag66@shakespeare.lit/pda'
276
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
277
+ assert(m.active?)
278
+ wait_state
279
+
280
+ assert_equal(m, m.exit('gone where the goblins go'))
281
+ assert(!m.active?)
282
+ wait_state
283
+ end
284
+
285
+ def test_joins
286
+ state { |pres|
287
+ assert_kind_of(Presence, pres)
288
+ assert_nil(pres.type)
289
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
290
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/thirdwitch'), pres.to)
291
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
292
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
293
+ "</presence>")
294
+ }
295
+ state { |pres|
296
+ assert_kind_of(Presence, pres)
297
+ assert_equal(:unavailable, pres.type)
298
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
299
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/thirdwitch'), pres.to)
300
+ assert_nil(pres.status)
301
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda' type='unavailable'>" +
302
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='none'/></x>" +
303
+ "</presence>")
304
+ }
305
+ state { |pres|
306
+ assert_kind_of(Presence, pres)
307
+ assert_nil(pres.type)
308
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
309
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/fourthwitch'), pres.to)
310
+ send("<presence from='darkcave@macbeth.shakespeare.lit/fourthwitch' to='hag66@shakespeare.lit/pda'>" +
311
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
312
+ "</presence>")
313
+ }
314
+ state { |pres|
315
+ assert_kind_of(Presence, pres)
316
+ assert_equal(:unavailable, pres.type)
317
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
318
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/fourthwitch'), pres.to)
319
+ assert_equal(pres.status, 'Exiting one last time')
320
+ send("<presence from='darkcave@macbeth.shakespeare.lit/fourthwitch' to='hag66@shakespeare.lit/pda' type='unavailable'>" +
321
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='none'/></x>" +
322
+ "</presence>")
323
+ }
324
+
325
+ m = MUC::MUCClient.new(@client)
326
+ m.my_jid = 'hag66@shakespeare.lit/pda'
327
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
328
+ wait_state
329
+ assert(m.active?)
330
+
331
+ assert_raises(RuntimeError) { m.join('darkcave@macbeth.shakespeare.lit/thirdwitch') }
332
+ assert_raises(RuntimeError) { m.join('darkcave@macbeth.shakespeare.lit/fourthwitch') }
333
+ assert(m.active?)
334
+
335
+ assert_equal(m, m.exit)
336
+ wait_state
337
+ assert(!m.active?)
338
+ assert_raises(RuntimeError) { m.exit }
339
+ assert(!m.active?)
340
+
341
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/fourthwitch'))
342
+ wait_state
343
+ assert(m.active?)
344
+
345
+ assert_raises(RuntimeError) { m.join('darkcave@macbeth.shakespeare.lit/thirdwitch') }
346
+ assert_raises(RuntimeError) { m.join('darkcave@macbeth.shakespeare.lit/fourthwitch') }
347
+ assert(m.active?)
348
+
349
+ assert_equal(m, m.exit('Exiting one last time'))
350
+ wait_state
351
+ assert(!m.active?)
352
+ assert_raises(RuntimeError) { m.exit }
353
+ assert(!m.active?)
354
+ end
355
+
356
+ def test_message_callback
357
+ state { |pres|
358
+ assert_kind_of(Presence, pres)
359
+ assert_equal('cauldron', pres.x.password)
360
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
361
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
362
+ "</presence>")
363
+ }
364
+
365
+ message_lock = Semaphore.new
366
+
367
+ messages_client = 0
368
+ @client.add_message_callback { |msg|
369
+ messages_client += 1
370
+ message_lock.run
371
+ }
372
+
373
+ m = MUC::MUCClient.new(@client)
374
+ m.my_jid = 'hag66@shakespeare.lit/pda'
375
+ messages_muc = 0
376
+ m.add_message_callback { |msg|
377
+ messages_muc += 1
378
+ message_lock.run
379
+ }
380
+ messages_muc_private = 0
381
+ m.add_private_message_callback { |msg|
382
+ messages_muc_private += 1
383
+ message_lock.run
384
+ }
385
+
386
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch', 'cauldron'))
387
+ assert(m.active?)
388
+
389
+ assert_equal(0, messages_client)
390
+ assert_equal(0, messages_muc)
391
+ assert_equal(0, messages_muc_private)
392
+
393
+ send("<message from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'><body>Hello</body></message>")
394
+ message_lock.wait
395
+
396
+ assert_equal(0, messages_client)
397
+ assert_equal(1, messages_muc)
398
+ assert_equal(0, messages_muc_private)
399
+
400
+ send("<message from='user@domain/resource' to='hag66@shakespeare.lit/pda'><body>Hello</body></message>")
401
+ message_lock.wait
402
+
403
+ assert_equal(1, messages_client)
404
+ assert_equal(1, messages_muc)
405
+ assert_equal(0, messages_muc_private)
406
+
407
+ send("<message type='chat' from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'><body>Hello</body></message>")
408
+ message_lock.wait
409
+
410
+ assert_equal(1, messages_client)
411
+ assert_equal(1, messages_muc)
412
+ assert_equal(1, messages_muc_private)
413
+
414
+ wait_state
415
+ end
416
+
417
+ def test_presence_callbacks
418
+ state { |pres|
419
+ assert_kind_of(Presence, pres)
420
+ assert_nil(pres.x.password)
421
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
422
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
423
+ "</presence>")
424
+ }
425
+
426
+ presence_lock = Semaphore.new
427
+
428
+ presences_client = 0
429
+ @client.add_presence_callback { |pres|
430
+ presences_client += 1
431
+ presence_lock.run
432
+ }
433
+ m = MUC::MUCClient.new(@client)
434
+ m.my_jid = 'hag66@shakespeare.lit/pda'
435
+ presences_join = 0
436
+ m.add_join_callback { |pres|
437
+ presences_join += 1
438
+ presence_lock.run
439
+ }
440
+ presences_leave = 0
441
+ m.add_leave_callback { |pres|
442
+ presences_leave += 1
443
+ presence_lock.run
444
+ }
445
+ presences_muc = 0
446
+ m.add_presence_callback { |pres|
447
+ presences_muc += 1
448
+ presence_lock.run
449
+ }
450
+
451
+ assert_equal(0, presences_client)
452
+ assert_equal(0, presences_join)
453
+ assert_equal(0, presences_leave)
454
+ assert_equal(0, presences_muc)
455
+
456
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
457
+ assert(m.active?)
458
+
459
+ assert_equal(0, presences_client)
460
+ assert_equal(0, presences_join) # Joins before own join won't be called back
461
+ assert_equal(0, presences_leave)
462
+ assert_equal(0, presences_muc)
463
+
464
+ send("<presence from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'>" +
465
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
466
+ "</presence>")
467
+ presence_lock.wait
468
+ assert_equal(0, presences_client)
469
+ assert_equal(1, presences_join)
470
+ assert_equal(0, presences_leave)
471
+ assert_equal(0, presences_muc)
472
+
473
+ send("<presence from='user@domain/resource' to='hag66@shakespeare.lit/pda'>" +
474
+ "<show>chat</show>" +
475
+ "</presence>")
476
+ presence_lock.wait
477
+ assert_equal(1, presences_client)
478
+ assert_equal(1, presences_join)
479
+ assert_equal(0, presences_leave)
480
+ assert_equal(0, presences_muc)
481
+
482
+ send("<presence from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'>" +
483
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
484
+ "<show>away</show></presence>")
485
+ presence_lock.wait
486
+ assert_equal(1, presences_client)
487
+ assert_equal(1, presences_join)
488
+ assert_equal(0, presences_leave)
489
+ assert_equal(1, presences_muc)
490
+
491
+ send("<presence from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda' type='unavailable'/>")
492
+ presence_lock.wait
493
+ assert_equal(1, presences_client)
494
+ assert_equal(1, presences_join)
495
+ assert_equal(1, presences_leave)
496
+ assert_equal(1, presences_muc)
497
+ wait_state
498
+ end
499
+
500
+ def test_send
501
+ state { |pres|
502
+ assert_kind_of(Presence, pres)
503
+ assert_nil(pres.x.password)
504
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
505
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
506
+ "</presence>")
507
+ }
508
+ state { |stanza|
509
+ assert_kind_of(Message, stanza)
510
+ assert(:groupchat, stanza.type)
511
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), stanza.from)
512
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit'), stanza.to)
513
+ assert_equal('First message', stanza.body)
514
+ }
515
+ state { |stanza|
516
+ assert_kind_of(Message, stanza)
517
+ assert(:chat, stanza.type)
518
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), stanza.from)
519
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/secondwitch'), stanza.to)
520
+ assert_equal('Second message', stanza.body)
521
+ }
522
+ state { |stanza|
523
+ assert_kind_of(Message, stanza)
524
+ assert(:chat, stanza.type)
525
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), stanza.from)
526
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/firstwitch'), stanza.to)
527
+ assert_equal('Third message', stanza.body)
528
+ }
529
+
530
+ m = MUC::MUCClient.new(@client)
531
+ m.my_jid = 'hag66@shakespeare.lit/pda'
532
+
533
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
534
+ wait_state
535
+ assert(m.active?)
536
+
537
+ m.send(Jabber::Message.new(nil, 'First message'))
538
+ wait_state
539
+ m.send(Jabber::Message.new(nil, 'Second message'), 'secondwitch')
540
+ wait_state
541
+ m.send(Jabber::Message.new('secondwitch', 'Third message'), 'firstwitch')
542
+ wait_state
543
+ end
544
+
545
+ def test_nick
546
+ state { |pres|
547
+ assert_kind_of(Presence, pres)
548
+ assert_nil(pres.x.password)
549
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
550
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
551
+ "</presence>")
552
+ }
553
+ state { |pres|
554
+ assert_kind_of(Presence, pres)
555
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
556
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/secondwitch'), pres.to)
557
+ assert_nil(pres.type)
558
+ send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
559
+ "<error code='409' type='cancel'><conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
560
+ "</presence>")
561
+ }
562
+ state { |pres|
563
+ assert_kind_of(Presence, pres)
564
+ assert_equal(JID.new('hag66@shakespeare.lit/pda'), pres.from)
565
+ assert_equal(JID.new('darkcave@macbeth.shakespeare.lit/oldhag'), pres.to)
566
+ assert_nil(pres.type)
567
+ send("<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda' type='unavailable'>" +
568
+ "<x xmlns='http://jabber.org/protocol/muc#user'>" +
569
+ "<item affiliation='member' jid='hag66@shakespeare.lit/pda' nick='oldhag' role='participant'/>" +
570
+ "<status code='303'/>" +
571
+ "</x></presence>" +
572
+ "<presence from='darkcave@macbeth.shakespeare.lit/oldhag' to='hag66@shakespeare.lit/pda'>" +
573
+ "<x xmlns='http://jabber.org/protocol/muc#user'>" +
574
+ "<item affiliation='member' jid='hag66@shakespeare.lit/pda' role='participant'/>" +
575
+ "</x></presence>")
576
+ }
577
+
578
+ m = MUC::MUCClient.new(@client)
579
+ m.my_jid = 'hag66@shakespeare.lit/pda'
580
+
581
+ assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
582
+ wait_state
583
+ assert(m.active?)
584
+ assert_equal('thirdwitch', m.nick)
585
+
586
+ assert_raises(ServerError) {
587
+ m.nick = 'secondwitch'
588
+ }
589
+ wait_state
590
+ assert(m.active?)
591
+ assert_equal('thirdwitch', m.nick)
592
+
593
+ m.nick = 'oldhag'
594
+ wait_state
595
+ assert(m.active?)
596
+ assert_equal('oldhag', m.nick)
597
+ end
598
+
599
+ # JEP-0045: 10.2 Room Configuration
600
+ def test_configuration
601
+ room = JID.new('darkcave@macbeth.shakespeare.lit/thirdwitch')
602
+ jid = JID.new('hag66@shakespeare.lit/pda')
603
+
604
+ state { |pres|
605
+ send(
606
+ "<presence from='darkcave@macbeth.shakespeare.lit/thirdwitch' to='hag66@shakespeare.lit/pda'>" +
607
+ "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='owner' role='moderator'/></x>" +
608
+ "</presence>"
609
+ )
610
+ }
611
+
612
+ state { |iq|
613
+ assert_kind_of(Jabber::Iq,iq)
614
+ assert_equal(jid, iq.from)
615
+ assert_equal(room.strip, iq.to)
616
+ assert_equal(:get, iq.type)
617
+
618
+ assert_kind_of(Jabber::MUC::IqQueryMUCOwner, iq.first_element('query'))
619
+
620
+ send(muc_config_form.sub("id='config1'","id='#{iq.id}'"))
621
+ }
622
+
623
+ state { |room_config|
624
+ assert_kind_of(Jabber::Iq, room_config)
625
+ assert_equal(room.strip, room_config.to)
626
+ assert_equal(:set, room_config.type)
627
+
628
+ assert_kind_of(Jabber::MUC::IqQueryMUCOwner, room_config.first_element('query'))
629
+
630
+ form = room_config.first_element('query/x')
631
+ assert_kind_of(Dataforms::XData, form)
632
+ assert_equal(:submit, form.type)
633
+ assert_equal(1, form.elements.size)
634
+ assert_equal('muc#roomconfig_roomname', form.first_element('field').var)
635
+ assert_equal(['Dunsinane'], form.first_element('field').values)
636
+
637
+ send(muc_config_acknowledgement.sub("id='config1'","id='#{room_config.id}'"))
638
+ }
639
+
640
+ m = MUC::MUCClient.new(@client)
641
+ m.my_jid = jid
642
+ m.join(room)
643
+ wait_state
644
+ assert_equal(true, m.owner?)
645
+
646
+ assert_equal(%w{muc#roomconfig_roomname muc#roomconfig_roomdesc
647
+ muc#roomconfig_enablelogging muc#roomconfig_changesubject muc#roomconfig_allowinvites
648
+ muc#roomconfig_maxusers muc#roomconfig_presencebroadcast muc#roomconfig_getmemberlist
649
+ muc#roomconfig_publicroom muc#roomconfig_persistentroom muc#roomconfig_moderatedroom
650
+ muc#roomconfig_membersonly muc#roomconfig_passwordprotectedroom muc#roomconfig_roomsecret
651
+ muc#roomconfig_whois muc#roomconfig_roomadmins muc#roomconfig_roomowners}, m.get_room_configuration)
652
+ wait_state
653
+
654
+ m.submit_room_configuration( 'muc#roomconfig_roomname' => 'Dunsinane' )
655
+ wait_state
656
+ end
657
+
658
+ # example 150 from XEP-0045
659
+ def muc_config_form
660
+ "<iq from='darkcave@macbeth.shakespeare.lit'
661
+ id='config1'
662
+ to='crone1@shakespeare.lit/desktop'
663
+ type='result'>
664
+ <query xmlns='http://jabber.org/protocol/muc#owner'>
665
+ <x xmlns='jabber:x:data' type='form'>
666
+ <title>Configuration for \"darkcave\" Room</title>
667
+ <instructions>
668
+ Complete this form to make changes to
669
+ the configuration of your room.
670
+ </instructions>
671
+ <field
672
+ type='hidden'
673
+ var='FORM_TYPE'>
674
+ <value>http://jabber.org/protocol/muc#roomconfig</value>
675
+ </field>
676
+ <field
677
+ label='Natural-Language Room Name'
678
+ type='text-single'
679
+ var='muc#roomconfig_roomname'>
680
+ <value>A Dark Cave</value>
681
+ </field>
682
+ <field
683
+ label='Short Description of Room'
684
+ type='text-single'
685
+ var='muc#roomconfig_roomdesc'>
686
+ <value>The place for all good witches!</value>
687
+ </field>
688
+ <field
689
+ label='Enable Public Logging?'
690
+ type='boolean'
691
+ var='muc#roomconfig_enablelogging'>
692
+ <value>0</value>
693
+ </field>
694
+ <field
695
+ label='Allow Occupants to Change Subject?'
696
+ type='boolean'
697
+ var='muc#roomconfig_changesubject'>
698
+ <value>0</value>
699
+ </field>
700
+ <field
701
+ label='Allow Occupants to Invite Others?'
702
+ type='boolean'
703
+ var='muc#roomconfig_allowinvites'>
704
+ <value>0</value>
705
+ </field>
706
+ <field
707
+ label='Maximum Number of Occupants'
708
+ type='list-single'
709
+ var='muc#roomconfig_maxusers'>
710
+ <value>10</value>
711
+ <option label='10'><value>10</value></option>
712
+ <option label='20'><value>20</value></option>
713
+ <option label='30'><value>30</value></option>
714
+ <option label='50'><value>50</value></option>
715
+ <option label='100'><value>100</value></option>
716
+ <option label='None'><value>none</value></option>
717
+ </field>
718
+ <field
719
+ label='Roles for which Presence is Broadcast'
720
+ type='list-multi'
721
+ var='muc#roomconfig_presencebroadcast'>
722
+ <value>moderator</value>
723
+ <value>participant</value>
724
+ <value>visitor</value>
725
+ <option label='Moderator'><value>moderator</value></option>
726
+ <option label='Participant'><value>participant</value></option>
727
+ <option label='Visitor'><value>visitor</value></option>
728
+ </field>
729
+ <field
730
+ label='Roles and Affiliations that May Retrieve Member List'
731
+ type='list-multi'
732
+ var='muc#roomconfig_getmemberlist'>
733
+ <value>moderator</value>
734
+ <value>participant</value>
735
+ <value>visitor</value>
736
+ <option label='Moderator'><value>moderator</value></option>
737
+ <option label='Participant'><value>participant</value></option>
738
+ <option label='Visitor'><value>visitor</value></option>
739
+ </field>
740
+ <field
741
+ label='Make Room Publicly Searchable?'
742
+ type='boolean'
743
+ var='muc#roomconfig_publicroom'>
744
+ <value>0</value>
745
+ </field>
746
+ <field
747
+ label='Make Room Persistent?'
748
+ type='boolean'
749
+ var='muc#roomconfig_persistentroom'>
750
+ <value>0</value>
751
+ </field>
752
+ <field
753
+ label='Make Room Moderated?'
754
+ type='boolean'
755
+ var='muc#roomconfig_moderatedroom'>
756
+ <value>0</value>
757
+ </field>
758
+ <field
759
+ label='Make Room Members Only?'
760
+ type='boolean'
761
+ var='muc#roomconfig_membersonly'>
762
+ <value>0</value>
763
+ </field>
764
+ <field
765
+ label='Password Required for Entry?'
766
+ type='boolean'
767
+ var='muc#roomconfig_passwordprotectedroom'>
768
+ <value>1</value>
769
+ </field>
770
+ <field type='fixed'>
771
+ <value>
772
+ If a password is required to enter this room,
773
+ you must specify the password below.
774
+ </value>
775
+ </field>
776
+ <field
777
+ label='Password'
778
+ type='text-private'
779
+ var='muc#roomconfig_roomsecret'>
780
+ <value>cauldronburn</value>
781
+ </field>
782
+ <field
783
+ label='Who May Discover Real JIDs?'
784
+ type='list-single'
785
+ var='muc#roomconfig_whois'>
786
+ <value>moderators</value>
787
+ <option label='Moderators Only'>
788
+ <value>moderators</value>
789
+ </option>
790
+ <option label='Anyone'>
791
+ <value>anyone</value>
792
+ </option>
793
+ </field>
794
+ <field type='fixed'>
795
+ <value>
796
+ You may specify additional people who have
797
+ administrative privileges in the room. Please
798
+ provide one Jabber ID per line.
799
+ </value>
800
+ </field>
801
+ <field
802
+ label='Room Admins'
803
+ type='jid-multi'
804
+ var='muc#roomconfig_roomadmins'>
805
+ <value>wiccarocks@shakespeare.lit</value>
806
+ <value>hecate@shakespeare.lit</value>
807
+ </field>
808
+ <field type='fixed'>
809
+ <value>
810
+ You may specify additional owners for this
811
+ room. Please provide one Jabber ID per line.
812
+ </value>
813
+ </field>
814
+ <field
815
+ label='Room Owners'
816
+ type='jid-multi'
817
+ var='muc#roomconfig_roomowners'/>
818
+ </x>
819
+ </query>
820
+ </iq>"
821
+ end
822
+
823
+ def muc_config_acknowledgement
824
+ "<iq from='darkcave@macbeth.shakespeare.lit'
825
+ id='config1'
826
+ to='crone1@shakespeare.lit/desktop'>
827
+ <query xmlns='http://jabber.org/protocol/muc#owner'>
828
+ <x xmlns='jabber:x:data' type='result'>
829
+ <field var='muc#roomconfig_roomname'><value>Dunsinane</value></field>
830
+ </x>
831
+ </query>
832
+ </iq>"
833
+ end
834
+ end