xmpp4r 0.3.2 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/{ChangeLog → CHANGELOG} +33 -0
  2. data/LICENSE +9 -9
  3. data/README.rdoc +110 -0
  4. data/README_ruby19.txt +43 -0
  5. data/Rakefile +235 -74
  6. data/data/doc/xmpp4r/examples/advanced/adventure/README +0 -1
  7. data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +1 -1
  8. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +12 -12
  9. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +10 -11
  10. data/data/doc/xmpp4r/examples/advanced/fileserve.rb +11 -11
  11. data/data/doc/xmpp4r/examples/advanced/getonline.rb +7 -7
  12. data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +3 -3
  13. data/data/doc/xmpp4r/examples/advanced/migrate.rb +21 -22
  14. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +22 -22
  15. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
  16. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
  17. data/data/doc/xmpp4r/examples/advanced/recvfile.rb +0 -1
  18. data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +2 -3
  19. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +3 -3
  20. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +10 -10
  21. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +2 -2
  22. data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +12 -12
  23. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +2 -3
  24. data/data/doc/xmpp4r/examples/basic/change_password.rb +3 -3
  25. data/data/doc/xmpp4r/examples/basic/client.rb +5 -3
  26. data/data/doc/xmpp4r/examples/basic/component.rb +1 -1
  27. data/data/doc/xmpp4r/examples/basic/{echo_threaded.rb → echo.rb} +8 -7
  28. data/data/doc/xmpp4r/examples/basic/jabbersend.rb +5 -5
  29. data/data/doc/xmpp4r/examples/basic/mass_sender.rb +11 -11
  30. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +0 -1
  31. data/data/doc/xmpp4r/examples/basic/mucinfo.rb +3 -1
  32. data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +0 -1
  33. data/data/doc/xmpp4r/examples/basic/register.rb +21 -4
  34. data/data/doc/xmpp4r/examples/basic/roster.rb +7 -5
  35. data/data/doc/xmpp4r/examples/basic/rosterprint.rb +0 -0
  36. data/data/doc/xmpp4r/examples/basic/rosterrename.rb +2 -2
  37. data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +6 -7
  38. data/data/doc/xmpp4r/examples/basic/send_vcard.rb +3 -4
  39. data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
  40. data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
  41. data/data/doc/xmpp4r/examples/basic/versionbot.rb +1 -1
  42. data/lib/xmpp4r.rb +4 -4
  43. data/lib/xmpp4r/base64.rb +32 -0
  44. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +10 -11
  45. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +6 -8
  46. data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +3 -6
  47. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +0 -1
  48. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +8 -11
  49. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +4 -7
  50. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +7 -3
  51. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +10 -5
  52. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +14 -4
  53. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig +62 -0
  54. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +0 -1
  55. data/lib/xmpp4r/callbacks.rb +5 -5
  56. data/lib/xmpp4r/caps.rb +1 -0
  57. data/lib/xmpp4r/caps/c.rb +53 -0
  58. data/lib/xmpp4r/caps/helper/generator.rb +160 -0
  59. data/lib/xmpp4r/caps/helper/helper.rb +87 -0
  60. data/lib/xmpp4r/client.rb +111 -40
  61. data/lib/xmpp4r/command/iq/command.rb +1 -1
  62. data/lib/xmpp4r/component.rb +8 -8
  63. data/lib/xmpp4r/connection.rb +25 -9
  64. data/lib/xmpp4r/dataforms/x/data.rb +17 -5
  65. data/lib/xmpp4r/debuglog.rb +13 -5
  66. data/lib/xmpp4r/delay/x/delay.rb +1 -1
  67. data/lib/xmpp4r/discovery.rb +3 -2
  68. data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
  69. data/lib/xmpp4r/discovery/iq/discoinfo.rb +11 -12
  70. data/lib/xmpp4r/discovery/iq/discoitems.rb +12 -4
  71. data/lib/xmpp4r/{error.rb → errors.rb} +66 -10
  72. data/lib/xmpp4r/framework/base.rb +55 -0
  73. data/lib/xmpp4r/framework/bot.rb +148 -0
  74. data/lib/xmpp4r/httpbinding/client.rb +1 -1
  75. data/lib/xmpp4r/idgenerator.rb +1 -1
  76. data/lib/xmpp4r/iq.rb +34 -23
  77. data/lib/xmpp4r/jid.rb +2 -2
  78. data/lib/xmpp4r/message.rb +1 -1
  79. data/lib/xmpp4r/muc.rb +2 -0
  80. data/lib/xmpp4r/muc/helper/mucbrowser.rb +4 -19
  81. data/lib/xmpp4r/muc/helper/mucclient.rb +54 -23
  82. data/lib/xmpp4r/muc/helper/simplemucclient.rb +107 -1
  83. data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
  84. data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
  85. data/lib/xmpp4r/muc/iq/mucowner.rb +5 -1
  86. data/lib/xmpp4r/muc/item.rb +143 -0
  87. data/lib/xmpp4r/muc/x/mucuserinvite.rb +2 -2
  88. data/lib/xmpp4r/muc/x/mucuseritem.rb +3 -117
  89. data/lib/xmpp4r/presence.rb +2 -1
  90. data/lib/xmpp4r/pubsub.rb +7 -0
  91. data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
  92. data/lib/xmpp4r/pubsub/{stanzas → children}/event.rb +13 -13
  93. data/lib/xmpp4r/pubsub/{stanzas → children}/item.rb +9 -1
  94. data/lib/xmpp4r/pubsub/{stanzas → children}/items.rb +10 -1
  95. data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
  96. data/lib/xmpp4r/pubsub/children/publish.rb +24 -0
  97. data/lib/xmpp4r/pubsub/{stanzas → children}/subscription.rb +16 -12
  98. data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
  99. data/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
  100. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +49 -93
  101. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +39 -36
  102. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +253 -162
  103. data/lib/xmpp4r/pubsub/iq/pubsub.rb +1 -1
  104. data/lib/xmpp4r/rexmladdons.rb +56 -28
  105. data/lib/xmpp4r/roster.rb +0 -1
  106. data/lib/xmpp4r/roster/helper/roster.rb +26 -15
  107. data/lib/xmpp4r/roster/iq/roster.rb +19 -19
  108. data/lib/xmpp4r/roster/x/roster.rb +10 -10
  109. data/lib/xmpp4r/rpc/helper/client.rb +17 -8
  110. data/lib/xmpp4r/rpc/helper/server.rb +1 -2
  111. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +14 -4
  112. data/lib/xmpp4r/rpc/iq/rpc.rb +0 -1
  113. data/lib/xmpp4r/sasl.rb +27 -6
  114. data/lib/xmpp4r/stream.rb +39 -44
  115. data/lib/xmpp4r/streamparser.rb +4 -4
  116. data/lib/xmpp4r/tune.rb +2 -0
  117. data/lib/xmpp4r/tune/helper/helper.rb +58 -0
  118. data/lib/xmpp4r/tune/tune.rb +113 -0
  119. data/lib/xmpp4r/vcard.rb +0 -1
  120. data/lib/xmpp4r/vcard/helper/vcard.rb +1 -3
  121. data/lib/xmpp4r/vcard/iq/vcard.rb +14 -0
  122. data/lib/xmpp4r/version/iq/version.rb +0 -1
  123. data/lib/xmpp4r/x.rb +1 -1
  124. data/lib/xmpp4r/xhtml.rb +1 -0
  125. data/lib/xmpp4r/xhtml/html.rb +115 -0
  126. data/lib/xmpp4r/xmpp4r.rb +7 -5
  127. data/lib/xmpp4r/xmppelement.rb +21 -5
  128. data/lib/xmpp4r/xmppstanza.rb +6 -6
  129. data/setup.rb +4 -4
  130. data/test/bytestreams/tc_ibb.rb +2 -2
  131. data/test/bytestreams/tc_socks5bytestreams.rb +12 -2
  132. data/test/caps/tc_helper.rb +156 -0
  133. data/test/dataforms/tc_data.rb +0 -0
  134. data/test/delay/tc_xdelay.rb +2 -2
  135. data/test/discovery/tc_responder.rb +91 -0
  136. data/test/lib/assert_equal_xml.rb +14 -0
  137. data/test/lib/clienttester.rb +31 -24
  138. data/test/muc/tc_muc_mucclient.rb +249 -13
  139. data/test/muc/tc_muc_simplemucclient.rb +41 -2
  140. data/test/muc/tc_mucowner.rb +0 -0
  141. data/test/pubsub/tc_helper.rb +486 -51
  142. data/test/pubsub/tc_nodeconfig.rb +54 -0
  143. data/test/pubsub/tc_subscriptionconfig.rb +41 -0
  144. data/test/roster/tc_helper.rb +6 -7
  145. data/test/roster/tc_iqqueryroster.rb +16 -16
  146. data/test/roster/tc_xroster.rb +1 -1
  147. data/test/rpc/tc_helper.rb +15 -3
  148. data/test/tc_callbacks.rb +7 -7
  149. data/test/tc_class_names.rb +15 -6
  150. data/test/tc_client.rb +3 -3
  151. data/test/{tc_error.rb → tc_errors.rb} +54 -12
  152. data/test/tc_idgenerator.rb +0 -0
  153. data/test/tc_iq.rb +32 -29
  154. data/test/tc_iqquery.rb +2 -2
  155. data/test/tc_jid.rb +44 -42
  156. data/test/tc_message.rb +13 -12
  157. data/test/tc_presence.rb +25 -24
  158. data/test/tc_rexml.rb +81 -2
  159. data/test/tc_stream.rb +15 -13
  160. data/test/tc_streamComponent.rb +6 -5
  161. data/test/tc_streamError.rb +21 -15
  162. data/test/tc_streamSend.rb +9 -9
  163. data/test/tc_streamparser.rb +112 -0
  164. data/test/tc_xmppstanza.rb +19 -9
  165. data/test/ts_xmpp4r.rb +10 -1
  166. data/test/tune/tc_helper_recv.rb +84 -0
  167. data/test/tune/tc_helper_send.rb +74 -0
  168. data/test/tune/tc_tune.rb +79 -0
  169. data/test/vcard/tc_helper.rb +2 -2
  170. data/test/vcard/tc_iqvcard.rb +13 -3
  171. data/test/version/tc_helper.rb +2 -2
  172. data/test/version/tc_iqqueryversion.rb +10 -10
  173. data/test/xhtml/tc_html.rb +41 -0
  174. data/tools/gen_requires.bash +29 -8
  175. data/tools/xmpp4r-gemspec-test.rb +11 -0
  176. data/xmpp4r.gemspec +291 -0
  177. metadata +277 -218
  178. data/README +0 -28
  179. data/UPDATING +0 -40
  180. data/data/doc/xmpp4r/examples/buggy/jabber2jabber/jabber2jabber.rb +0 -18
  181. data/data/doc/xmpp4r/examples/buggy/miniedgarr_cgi.rb +0 -192
  182. data/data/doc/xmpp4r/examples/buggy/miniedgarr_watch.rb +0 -82
  183. data/lib/xmpp4r/authenticationfailure.rb +0 -13
  184. data/lib/xmpp4r/errorexception.rb +0 -32
  185. data/tools/doctoweb.bash +0 -30
@@ -4,6 +4,7 @@
4
4
 
5
5
  require 'xmpp4r/delay/x/delay'
6
6
  require 'xmpp4r/muc/helper/mucclient'
7
+ require 'xmpp4r/muc/iq/mucadminitem'
7
8
 
8
9
  module Jabber
9
10
  module MUC
@@ -101,7 +102,7 @@ module Jabber
101
102
  @subject = msg.subject
102
103
  @subject_block.call(time, sender_nick, @subject) if @subject_block
103
104
  end
104
-
105
+
105
106
  if msg.body
106
107
  if sender_nick.nil?
107
108
  @room_message_block.call(time, msg.body) if @room_message_block
@@ -162,6 +163,111 @@ module Jabber
162
163
  send(msg)
163
164
  end
164
165
 
166
+ ##
167
+ # Administratively remove one or more users from the room.
168
+ #
169
+ # Will wait for response, possibly raising ServerError
170
+ #
171
+ # Sample usage:
172
+ # my_muc.kick 'pistol', 'Avaunt, you cullion!'
173
+ # my_muc.kick(['Bill', 'Linus'], 'Stop flaming')
174
+ #
175
+ # recipients:: [Array] of, or single [String]: Nicks
176
+ # reason:: [String] Kick reason
177
+ def kick(recipients, reason)
178
+ recipients = [recipients] unless recipients.kind_of? Array
179
+ items = recipients.collect { |recipient|
180
+ item = IqQueryMUCAdminItem.new
181
+ item.nick = recipient
182
+ item.role = :none
183
+ item.reason = reason
184
+ item
185
+ }
186
+ send_affiliations(items)
187
+ end
188
+
189
+ ##
190
+ # Administratively ban one or more user jids from the room.
191
+ #
192
+ # Will wait for response, possibly raising ServerError
193
+ #
194
+ # Sample usage:
195
+ # my_muc.ban 'pistol@foobar.com', 'Avaunt, you cullion!'
196
+ #
197
+ # recipients:: [Array] of, or single [String]: JIDs
198
+ # reason:: [String] Ban reason
199
+ def ban(recipients, reason)
200
+ recipients = [recipients] unless recipients.kind_of? Array
201
+ items = recipients.collect { |recipient|
202
+ item = IqQueryMUCAdminItem.new
203
+ item.jid = recipient
204
+ item.affiliation = :outcast
205
+ item.reason = reason
206
+ item
207
+ }
208
+ send_affiliations(items)
209
+ end
210
+
211
+ ##
212
+ # Unban one or more user jids for the room.
213
+ #
214
+ # Will wait for response, possibly raising ServerError
215
+ #
216
+ # Sample usage:
217
+ # my_muc.unban 'pistol@foobar.com'
218
+ #
219
+ # recipients:: [Array] of, or single [String]: JIDs
220
+ def unban(recipients)
221
+ recipients = [recipients] unless recipients.kind_of? Array
222
+ items = recipients.collect { |recipient|
223
+ item = IqQueryMUCAdminItem.new
224
+ item.jid = recipient
225
+ item.affiliation = :none
226
+ item
227
+ }
228
+ send_affiliations(items)
229
+ end
230
+
231
+ ##
232
+ # Promote one or more users in the room to moderator.
233
+ #
234
+ # Will wait for response, possibly raising ServerError
235
+ #
236
+ # Sample usage:
237
+ # my_muc.promote 'pistol'
238
+ #
239
+ # recipients:: [Array] of, or single [String]: Nicks
240
+ def promote(recipients)
241
+ recipients = [recipients] unless recipients.kind_of? Array
242
+ items = recipients.collect { |recipient|
243
+ item = IqQueryMUCAdminItem.new
244
+ item.nick = recipient
245
+ item.role = :moderator
246
+ item
247
+ }
248
+ send_affiliations(items)
249
+ end
250
+
251
+ ##
252
+ # Demote one or more users in the room to participant.
253
+ #
254
+ # Will wait for response, possibly raising ServerError
255
+ #
256
+ # Sample usage:
257
+ # my_muc.demote 'pistol'
258
+ #
259
+ # recipients:: [Array] of, or single [String]: Nicks
260
+ def demote(recipients)
261
+ recipients = [recipients] unless recipients.kind_of? Array
262
+ items = recipients.collect { |recipient|
263
+ item = IqQueryMUCAdminItem.new
264
+ item.nick = recipient
265
+ item.role = :participant
266
+ item
267
+ }
268
+ send_affiliations(items)
269
+ end
270
+
165
271
  ##
166
272
  # Block to be invoked when a message *from* the room arrives
167
273
  #
@@ -0,0 +1,23 @@
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/x'
6
+
7
+ module Jabber
8
+ module MUC
9
+ class IqQueryMUCAdmin < IqQuery
10
+ name_xmlns 'query', 'http://jabber.org/protocol/muc#admin'
11
+
12
+ include XParent
13
+
14
+ def items
15
+ r = []
16
+ each_element('item') { |item|
17
+ r << item if item.kind_of? IqQueryMUCAdminItem
18
+ }
19
+ r
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
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/muc/item'
6
+
7
+ module Jabber
8
+ module MUC
9
+ class IqQueryMUCAdminItem < MUC::UserItem
10
+ name_xmlns 'item', 'http://jabber.org/protocol/muc#admin'
11
+
12
+ def initialize(affiliation=nil, role=nil, jid=nil)
13
+ super()
14
+ set_affiliation(affiliation)
15
+ set_role(role)
16
+ set_jid(jid)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,10 +1,14 @@
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
+
1
5
  require 'xmpp4r/x'
2
6
 
3
7
  module Jabber
4
8
  module MUC
5
9
  class IqQueryMUCOwner < IqQuery
6
10
  name_xmlns 'query', 'http://jabber.org/protocol/muc#owner'
7
-
11
+
8
12
  include XParent
9
13
  end
10
14
  end
@@ -0,0 +1,143 @@
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
+ module Jabber
6
+ module MUC
7
+ ##
8
+ # Don't use this. It is the base class (unifying shared
9
+ # attributes) of XMUCUserItem and IqQueryMUCAdminItem
10
+ class UserItem < XMPPElement
11
+ def affiliation
12
+ case attributes['affiliation']
13
+ when 'admin' then :admin
14
+ when 'member' then :member
15
+ when 'none' then :none
16
+ when 'outcast' then :outcast
17
+ when 'owner' then :owner
18
+ else nil
19
+ end
20
+ end
21
+
22
+ def affiliation=(v)
23
+ case v
24
+ when :admin then attributes['affiliation'] = 'admin'
25
+ when :member then attributes['affiliation'] = 'member'
26
+ when :none then attributes['affiliation'] = 'none'
27
+ when :outcast then attributes['affiliation'] = 'outcast'
28
+ when :owner then attributes['affiliation'] = 'owner'
29
+ else attributes['affiliation'] = nil
30
+ end
31
+ end
32
+
33
+ def set_affiliation(v)
34
+ self.affiliation = v
35
+ self
36
+ end
37
+
38
+ def jid
39
+ attributes['jid'].nil? ? nil : JID.new(attributes['jid'])
40
+ end
41
+
42
+ def jid=(j)
43
+ attributes['jid'] = j.nil? ? nil : j.to_s
44
+ end
45
+
46
+ def set_jid(j)
47
+ self.jid = j
48
+ self
49
+ end
50
+
51
+ def nick
52
+ attributes['nick']
53
+ end
54
+
55
+ def nick=(n)
56
+ attributes['nick'] = n
57
+ end
58
+
59
+ def set_nick(n)
60
+ self.nick = n
61
+ self
62
+ end
63
+
64
+ def role
65
+ case attributes['role']
66
+ when 'moderator' then :moderator
67
+ when 'none' then :none
68
+ when 'participant' then :participant
69
+ when 'visitor' then :visitor
70
+ else nil
71
+ end
72
+ end
73
+
74
+ def role=(r)
75
+ case r
76
+ when :moderator then attributes['role'] = 'moderator'
77
+ when :none then attributes['role'] = 'none'
78
+ when :participant then attributes['role'] = 'participant'
79
+ when :visitor then attributes['role'] = 'visitor'
80
+ else attributes['role'] = nil
81
+ end
82
+ end
83
+
84
+ def set_role(r)
85
+ self.role = r
86
+ self
87
+ end
88
+
89
+ def reason
90
+ text = nil
91
+ each_element('reason') { |xe| text = xe.text }
92
+ text
93
+ end
94
+
95
+ def reason=(s)
96
+ delete_elements('reasion')
97
+ add_element('reason').text = s
98
+ end
99
+
100
+ def set_reason(s)
101
+ self.reason = s
102
+ self
103
+ end
104
+
105
+ def continue
106
+ c = nil
107
+ each_element('continue') { |xe| c = xe }
108
+ c.nil?
109
+ end
110
+
111
+ def continue=(c)
112
+ delete_elements('continue')
113
+ add_element('continue') if c
114
+ end
115
+
116
+ def set_continue(c)
117
+ self.continue = c
118
+ self
119
+ end
120
+
121
+ def actors
122
+ a = []
123
+ each_element('actor') { |xe|
124
+ a.push(JID.new(xe.attributes['jid']))
125
+ }
126
+ a
127
+ end
128
+
129
+ def actors=(a)
130
+ delete_elements('actor')
131
+ a.each { |jid|
132
+ e = add_element('actor')
133
+ e.attributes['jid'] = jid.to_s
134
+ }
135
+ end
136
+
137
+ def set_actors(a)
138
+ self.actors = a
139
+ self
140
+ end
141
+ end
142
+ end
143
+ end
@@ -14,7 +14,7 @@ module Jabber
14
14
  end
15
15
 
16
16
  def to
17
- attributes['to'].nil? ? nil : JID::new(attributes['to'])
17
+ attributes['to'].nil? ? nil : JID.new(attributes['to'])
18
18
  end
19
19
 
20
20
  def to=(j)
@@ -27,7 +27,7 @@ module Jabber
27
27
  end
28
28
 
29
29
  def from
30
- attributes['from'].nil? ? nil : JID::new(attributes['from'])
30
+ attributes['from'].nil? ? nil : JID.new(attributes['from'])
31
31
  end
32
32
 
33
33
  def from=(j)
@@ -2,9 +2,11 @@
2
2
  # License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
3
3
  # Website::http://home.gna.org/xmpp4r/
4
4
 
5
+ require 'xmpp4r/muc/item'
6
+
5
7
  module Jabber
6
8
  module MUC
7
- class XMUCUserItem < XMPPElement
9
+ class XMUCUserItem < MUC::UserItem
8
10
  name_xmlns 'item', 'http://jabber.org/protocol/muc#user'
9
11
 
10
12
  def initialize(affiliation=nil, role=nil, jid=nil)
@@ -14,100 +16,6 @@ module Jabber
14
16
  set_jid(jid)
15
17
  end
16
18
 
17
- def affiliation
18
- case attributes['affiliation']
19
- when 'admin' then :admin
20
- when 'member' then :member
21
- when 'none' then :none
22
- when 'outcast' then :outcast
23
- when 'owner' then :owner
24
- else nil
25
- end
26
- end
27
-
28
- def affiliation=(v)
29
- case v
30
- when :admin then attributes['affiliation'] = 'admin'
31
- when :member then attributes['affiliation'] = 'member'
32
- when :none then attributes['affiliation'] = 'none'
33
- when :outcast then attributes['affiliation'] = 'outcast'
34
- when :owner then attributes['affiliation'] = 'owner'
35
- else attributes['affiliation'] = nil
36
- end
37
- end
38
-
39
- def set_affiliation(v)
40
- self.affiliation = v
41
- self
42
- end
43
-
44
- def jid
45
- attributes['jid'].nil? ? nil : JID::new(attributes['jid'])
46
- end
47
-
48
- def jid=(j)
49
- attributes['jid'] = j.nil? ? nil : j.to_s
50
- end
51
-
52
- def set_jid(j)
53
- self.jid = j
54
- self
55
- end
56
-
57
- def nick
58
- attributes['nick']
59
- end
60
-
61
- def nick=(n)
62
- attributes['nick'] = n
63
- end
64
-
65
- def set_nick(n)
66
- self.nick = n
67
- self
68
- end
69
-
70
- def role
71
- case attributes['role']
72
- when 'moderator' then :moderator
73
- when 'none' then :none
74
- when 'participant' then :participant
75
- when 'visitor' then :visitor
76
- else nil
77
- end
78
- end
79
-
80
- def role=(r)
81
- case r
82
- when :moderator then attributes['role'] = 'moderator'
83
- when :none then attributes['role'] = 'none'
84
- when :participant then attributes['role'] = 'participant'
85
- when :visitor then attributes['role'] = 'visitor'
86
- else attributes['role'] = nil
87
- end
88
- end
89
-
90
- def set_role(r)
91
- self.role = r
92
- self
93
- end
94
-
95
- def reason
96
- text = nil
97
- each_element('reason') { |xe| text = xe.text }
98
- text
99
- end
100
-
101
- def reason=(s)
102
- delete_elements('reasion')
103
- add_element('reason').text = s
104
- end
105
-
106
- def set_reason(s)
107
- self.reason = s
108
- self
109
- end
110
-
111
19
  def continue
112
20
  c = nil
113
21
  each_element('continue') { |xe| c = xe }
@@ -123,28 +31,6 @@ module Jabber
123
31
  self.continue = c
124
32
  self
125
33
  end
126
-
127
- def actors
128
- a = []
129
- each_element('actor') { |xe|
130
- a.push(JID::new(xe.attributes['jid']))
131
- }
132
- a
133
- end
134
-
135
- def actors=(a)
136
- delete_elements('actor')
137
- a.each { |jid|
138
- e = add_element('actor')
139
- e.attributes['jid'] = jid.to_s
140
- }
141
- end
142
-
143
- def set_actors(a)
144
- self.actors = a
145
- self
146
- end
147
34
  end
148
35
  end
149
36
  end
150
-