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
@@ -7,7 +7,7 @@ require 'xmpp4r/x'
7
7
 
8
8
  module Jabber
9
9
  ##
10
- # The presence class is used to construct presence messages to
10
+ # The presence class is used to construct presence messages to
11
11
  # send to the Jabber service.
12
12
  class Presence < XMPPStanza
13
13
  name_xmlns 'presence', 'jabber:client'
@@ -107,6 +107,7 @@ module Jabber
107
107
  xe = add_element('show')
108
108
  end
109
109
  case val
110
+ when String then raise "Invalid value for show."
110
111
  when :away then text = 'away'
111
112
  when :chat then text = 'chat'
112
113
  when :dnd then text = 'dnd'
@@ -1 +1,8 @@
1
+ require 'xmpp4r/pubsub/iq/pubsub'
2
+ require 'xmpp4r/pubsub/children/event'
3
+ require 'xmpp4r/pubsub/children/item'
4
+ require 'xmpp4r/pubsub/children/items'
5
+ require 'xmpp4r/pubsub/children/publish'
6
+ require 'xmpp4r/pubsub/children/subscription'
7
+ require 'xmpp4r/pubsub/children/unsubscribe'
1
8
  require 'xmpp4r/pubsub/helper/servicehelper'
@@ -0,0 +1,86 @@
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/xmppelement'
6
+ require 'xmpp4r/pubsub/iq/pubsub'
7
+
8
+ module Jabber
9
+ module PubSub
10
+
11
+ class Configuration < XMPPElement
12
+ ##
13
+ # get the underlying XData form element
14
+ def form
15
+ children.each do |c|
16
+ return c if c.kind_of?(Jabber::Dataforms::XData)
17
+ end
18
+
19
+ nil
20
+ end
21
+
22
+ def form=(form)
23
+ children.each do |c|
24
+ delete_element(c)
25
+ if c.kind_of?(Jabber::Dataforms::XData)
26
+ delete(c)
27
+ end
28
+ end
29
+ add(form)
30
+ end
31
+
32
+ # Implemented by NodeConfig and SubscriptionConfig
33
+ def form_type
34
+ ''
35
+ end
36
+
37
+ def options=(options)
38
+ if options
39
+ self.form = form_for_options( form_type, options )
40
+ end
41
+ end
42
+
43
+ ##
44
+ # get a list of the configured options represented by this stanza
45
+ # return:: [Hash] the options and their values
46
+ def options
47
+ configured_options = {}
48
+
49
+ if !form.nil?
50
+ form.fields.each do |f|
51
+ f.values.size == 1 ? configured_options[f.var] = f.values.first : configured_options[f.var] = f.values
52
+ end
53
+ end
54
+
55
+ configured_options
56
+ end
57
+
58
+ def node=(node)
59
+ attributes['node'] = node
60
+ end
61
+
62
+ def node
63
+ attributes['node']
64
+ end
65
+
66
+ private
67
+
68
+ ##
69
+ # creates a Dataform for configuration
70
+ # config:: [Hash] the desired configuration options
71
+ def form_for_options(type, options)
72
+ form = Jabber::Dataforms::XData.new(:submit)
73
+ pubsub_config = Jabber::Dataforms::XDataField.new('FORM_TYPE', :hidden)
74
+ pubsub_config.values = [type]
75
+ form.add(pubsub_config)
76
+ options.each_pair do |key, value|
77
+ f = Jabber::Dataforms::XDataField.new(key)
78
+ f.values = [value]
79
+ form.add(f)
80
+ end
81
+
82
+ form
83
+ end
84
+ end
85
+ end
86
+ end
@@ -13,7 +13,7 @@ module Jabber
13
13
  class Event < XMPPElement
14
14
  name_xmlns 'event', NS_PUBSUB + '#event'
15
15
  force_xmlns true
16
-
16
+
17
17
  ##
18
18
  # return payload
19
19
  def payload
@@ -26,23 +26,23 @@ module Jabber
26
26
  def payload=(pl)
27
27
  add_element = pl
28
28
  end
29
-
29
+
30
30
  ##
31
31
  # return the payload type
32
32
  def event_type?
33
33
  # each child of event
34
- # this should interate only one time
34
+ # this should iterate only one time
35
35
  each_element('./event/*') { |plelement|
36
- case plelement.name
37
- when 'collection' then return :collection
38
- when 'configuration' then return :configuration
39
- when 'delete' then return :delete
40
- when 'items' then return :items
41
- when 'purge' then return :purge
42
- when 'subscription' then return :subscription
43
- else return nil
44
- end
45
- }
36
+ case plelement.name
37
+ when 'collection' then return :collection
38
+ when 'configuration' then return :configuration
39
+ when 'delete' then return :delete
40
+ when 'items' then return :items
41
+ when 'purge' then return :purge
42
+ when 'subscription' then return :subscription
43
+ else return nil
44
+ end
45
+ }
46
46
  end
47
47
  end
48
48
  end
@@ -11,7 +11,6 @@ module Jabber
11
11
  # One PubSub Item
12
12
  class Item < XMPPElement
13
13
  name_xmlns 'item', NS_PUBSUB
14
- force_xmlns true
15
14
  def initialize(id=nil)
16
15
  super()
17
16
  attributes['id'] = id
@@ -23,5 +22,14 @@ module Jabber
23
22
  attributes['id'] = myid
24
23
  end
25
24
  end
25
+
26
+ ##
27
+ # An Item wrapped in a Pubsub Event.
28
+ #
29
+ # See example 2 in http://www.xmpp.org/extensions/xep-0060.html#intro-howitworks
30
+ # and http://www.xmpp.org/extensions/xep-0060.html#schemas-event
31
+ class EventItem < Item
32
+ name_xmlns 'item', NS_PUBSUB + "#event"
33
+ end
26
34
  end
27
35
  end
@@ -11,7 +11,7 @@ module Jabber
11
11
  # a collection of Items
12
12
  class Items < XMPPElement
13
13
  name_xmlns 'items', NS_PUBSUB
14
- force_xmlns true
14
+
15
15
  def node
16
16
  attributes['node']
17
17
  end
@@ -31,5 +31,14 @@ module Jabber
31
31
  attributes['max_items'] = mymaxitems
32
32
  end
33
33
  end
34
+
35
+ ##
36
+ # Items wrapped in a Pubsub Event.
37
+ #
38
+ # See example 2 in http://www.xmpp.org/extensions/xep-0060.html#intro-howitworks
39
+ # and http://www.xmpp.org/extensions/xep-0060.html#schemas-event
40
+ class EventItems < Items
41
+ name_xmlns 'items', NS_PUBSUB + "#event"
42
+ end
34
43
  end
35
44
  end
@@ -0,0 +1,48 @@
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/xmppelement'
6
+ require 'xmpp4r/pubsub/children/configuration'
7
+
8
+ module Jabber
9
+ module PubSub
10
+ ##
11
+ # NodeConfig
12
+ #
13
+ # A <configure> XMPP element for pubsub nodes, see example 123 in
14
+ # http://www.xmpp.org/extensions/xep-0060.html#owner-create-and-configure
15
+ class NodeConfig < Configuration
16
+ name_xmlns 'configure', NS_PUBSUB
17
+
18
+ ##
19
+ # Construct a <configure> element.
20
+ # node:: [String] the node to configure
21
+ # options:: [Hash] the configuration to apply
22
+ def initialize(node = nil, options = nil)
23
+ super()
24
+
25
+ self.node = node
26
+ self.options = options
27
+ end
28
+
29
+ private
30
+
31
+ def form_type
32
+ 'http://jabber.org/protocol/pubsub#node_config'
33
+ end
34
+ end
35
+
36
+ ##
37
+ #
38
+ # OwnerNodeConfig
39
+ #
40
+ # A <configure> stanza for 'Owner' use cases
41
+ #
42
+ # see example 125 in
43
+ # http://www.xmpp.org/extensions/xep-0060.html#owner-configure-request
44
+ class OwnerNodeConfig < NodeConfig
45
+ name_xmlns 'configure', NS_PUBSUB + '#owner'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,24 @@
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/xmppelement'
6
+
7
+ module Jabber
8
+ module PubSub
9
+
10
+ ##
11
+ # Publish
12
+ #
13
+ # A <publish> XMPP element, see example 1 in
14
+ # http://www.xmpp.org/extensions/xep-0060.html#intro-howitworks
15
+ class Publish < XMPPElement
16
+ name_xmlns 'publish', NS_PUBSUB
17
+ ##
18
+ # return the node for this publication
19
+ def node
20
+ attributes['node']
21
+ end
22
+ end
23
+ end
24
+ end
@@ -11,41 +11,41 @@ module Jabber
11
11
  class Subscription < XMPPElement
12
12
  name_xmlns 'subscription', NS_PUBSUB
13
13
  def initialize(myjid=nil,mynode=nil,mysubid=nil,mysubscription=nil)
14
- super(true)
14
+ super()
15
15
  jid = myjid
16
- node = mynode
17
- subid = mysubid
18
- state = mysubscription
16
+ node = mynode
17
+ subid = mysubid
18
+ state = mysubscription
19
19
  end
20
20
  def jid
21
- attributes['jid']
21
+ (a = attribute('jid')).nil? ? a : JID.new(a.value)
22
22
  end
23
23
  def jid=(myjid)
24
- attributes['jid'] = myjid
24
+ add_attribute('jid', myjid ? myjid.to_s : nil)
25
25
  end
26
-
26
+
27
27
  def node
28
28
  attributes['node']
29
29
  end
30
30
  def node=(mynode)
31
31
  attributes['node'] = mynode
32
32
  end
33
-
33
+
34
34
  def subid
35
35
  attributes['subid']
36
36
  end
37
37
  def subid=(mysubid)
38
38
  attributes['subid'] = mysubid
39
39
  end
40
-
41
- def state
40
+
41
+ def state
42
42
  # each child of event
43
43
  # this should interate only one time
44
44
  case attributes['subscription']
45
45
  when 'none' then return :none
46
46
  when 'pending' then return :pending
47
47
  when 'subscribed' then return :subscribed
48
- when 'unconfigured' then return :items
48
+ when 'unconfigured' then return :unconfigured
49
49
  else return nil
50
50
  end
51
51
  end
@@ -53,6 +53,10 @@ module Jabber
53
53
  attributes['subscription'] = mystate
54
54
  end
55
55
  alias subscription state
56
+
57
+ def need_approval?
58
+ state == :pending
59
+ end
56
60
  end
57
61
  end
58
- end
62
+ end
@@ -0,0 +1,67 @@
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/xmppelement'
6
+ require 'xmpp4r/pubsub/children/configuration'
7
+ require 'xmpp4r/pubsub/iq/pubsub'
8
+
9
+ module Jabber
10
+ module PubSub
11
+ ##
12
+ # SubscriptionConfig
13
+ #
14
+ # An <options> XMPP element, see example 57 in
15
+ # http://www.xmpp.org/extensions/xep-0060.html#subscriber-configure-success
16
+ class SubscriptionConfig < Configuration
17
+ name_xmlns 'options', NS_PUBSUB
18
+
19
+ ##
20
+ # Construct a new Options stanza
21
+ # node:: [String] the node to which this subscription applies
22
+ # jid:: [String] or [Jabber::JID] the jid that holds the subscription
23
+ # options:: [Hash] the configuration for this subscription
24
+ # subid:: [String] (optional) subscription id
25
+ def initialize(node = nil, jid = nil, options = nil, subid = nil)
26
+ super()
27
+
28
+ self.node = node
29
+ self.jid = jid
30
+ self.options = options
31
+ self.subid = subid
32
+ end
33
+
34
+ ##
35
+ # set the 'jid' attribute of this stanza
36
+ # jid:: [Jabber::JID] or [String] the jid owning the subscription
37
+ def jid=(jid)
38
+ attributes['jid'] = jid.to_s
39
+ end
40
+
41
+ ##
42
+ # get the 'jid' attribute for this stanza
43
+ def jid
44
+ attributes['jid'] ? Jabber::JID.new(attributes['jid']) : nil
45
+ end
46
+
47
+ ##
48
+ # set the 'subid' attribute
49
+ # subid:: [String] the subscription id
50
+ def subid=(subid)
51
+ attributes['subid'] = subid
52
+ end
53
+
54
+ ##
55
+ # get the 'subid' attribute
56
+ def subid
57
+ attributes['subid']
58
+ end
59
+
60
+ private
61
+
62
+ def form_type
63
+ 'http://jabber.org/protocol/pubsub#subscribe_options'
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,48 @@
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/iq'
6
+
7
+ module Jabber
8
+ module PubSub
9
+ ##
10
+ # Unsubscribe
11
+ class Unsubscribe < XMPPElement
12
+ name_xmlns 'unsubscribe'
13
+ def initialize(myjid=nil,mynode=nil)
14
+ super()
15
+ jid = myjid
16
+ node = mynode
17
+ end
18
+
19
+ ##
20
+ # shows the jid
21
+ # return:: [String]
22
+ def jid
23
+ (a = attribute('jid')).nil? ? a : JID.new(a.value)
24
+ end
25
+
26
+ ##
27
+ # sets the jid
28
+ # =:: [Jabber::JID] or [String]
29
+ def jid=(myjid)
30
+ add_attribute('jid', myjid ? myjid.to_s : nil)
31
+ end
32
+
33
+ ##
34
+ # shows the node
35
+ # return:: [String]
36
+ def node
37
+ attributes['node']
38
+ end
39
+
40
+ ##
41
+ # sets the node
42
+ # =:: [String]
43
+ def node=(mynode)
44
+ attributes['node'] = mynode
45
+ end
46
+ end
47
+ end
48
+ end