xmpp4r 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/ChangeLog +12 -0
  2. data/Rakefile +2 -4
  3. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +6 -6
  4. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +3 -3
  5. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +5 -5
  6. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +17 -4
  7. data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +5 -0
  8. data/data/doc/xmpp4r/examples/basic/echo_threaded.rb +6 -2
  9. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +13 -0
  10. data/lib/xmpp4r.rb +0 -6
  11. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +6 -7
  12. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +5 -6
  13. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +3 -5
  14. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +1 -1
  15. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +10 -8
  16. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +3 -5
  17. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +11 -17
  18. data/lib/xmpp4r/bytestreams/iq/si.rb +13 -32
  19. data/lib/xmpp4r/callbacks.rb +124 -0
  20. data/lib/xmpp4r/client.rb +2 -5
  21. data/lib/xmpp4r/command/helper/responder.rb +53 -0
  22. data/lib/xmpp4r/command/iq/command.rb +154 -0
  23. data/lib/xmpp4r/connection.rb +49 -12
  24. data/lib/xmpp4r/dataforms/x/data.rb +66 -29
  25. data/lib/xmpp4r/delay/x/delay.rb +2 -3
  26. data/lib/xmpp4r/discovery/iq/discoinfo.rb +20 -33
  27. data/lib/xmpp4r/discovery/iq/discoitems.rb +5 -28
  28. data/lib/xmpp4r/error.rb +5 -10
  29. data/lib/xmpp4r/feature_negotiation/iq/feature.rb +2 -20
  30. data/lib/xmpp4r/httpbinding.rb +5 -0
  31. data/lib/xmpp4r/httpbinding/client.rb +285 -0
  32. data/lib/xmpp4r/iq.rb +22 -41
  33. data/lib/xmpp4r/message.rb +8 -38
  34. data/lib/xmpp4r/muc.rb +2 -0
  35. data/lib/xmpp4r/muc/helper/mucclient.rb +50 -1
  36. data/lib/xmpp4r/muc/helper/simplemucclient.rb +2 -2
  37. data/lib/xmpp4r/muc/iq/mucowner.rb +11 -0
  38. data/lib/xmpp4r/muc/x/muc.rb +2 -30
  39. data/lib/xmpp4r/muc/x/mucuserinvite.rb +4 -2
  40. data/lib/xmpp4r/muc/x/mucuseritem.rb +4 -2
  41. data/lib/xmpp4r/presence.rb +7 -35
  42. data/lib/xmpp4r/pubsub.rb +1 -0
  43. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +174 -0
  44. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +153 -0
  45. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +326 -0
  46. data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
  47. data/lib/xmpp4r/pubsub/stanzas/event.rb +49 -0
  48. data/lib/xmpp4r/pubsub/stanzas/item.rb +27 -0
  49. data/lib/xmpp4r/pubsub/stanzas/items.rb +35 -0
  50. data/lib/xmpp4r/pubsub/stanzas/subscription.rb +58 -0
  51. data/lib/xmpp4r/query.rb +4 -32
  52. data/lib/xmpp4r/rexmladdons.rb +7 -772
  53. data/lib/xmpp4r/roster/helper/roster.rb +29 -50
  54. data/lib/xmpp4r/roster/iq/roster.rb +6 -35
  55. data/lib/xmpp4r/roster/x/roster.rb +13 -30
  56. data/lib/xmpp4r/rpc.rb +2 -0
  57. data/lib/xmpp4r/rpc/helper/client.rb +114 -0
  58. data/lib/xmpp4r/rpc/helper/server.rb +75 -0
  59. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +57 -0
  60. data/lib/xmpp4r/rpc/iq/rpc.rb +24 -0
  61. data/lib/xmpp4r/sasl.rb +1 -1
  62. data/lib/xmpp4r/semaphore.rb +38 -0
  63. data/lib/xmpp4r/stream.rb +104 -165
  64. data/lib/xmpp4r/streamparser.rb +2 -2
  65. data/lib/xmpp4r/vcard/iq/vcard.rb +5 -12
  66. data/lib/xmpp4r/version/helper/responder.rb +2 -1
  67. data/lib/xmpp4r/version/iq/version.rb +6 -18
  68. data/lib/xmpp4r/x.rb +20 -26
  69. data/lib/xmpp4r/xmpp4r.rb +1 -1
  70. data/lib/xmpp4r/xmppelement.rb +152 -0
  71. data/lib/xmpp4r/{xmlstanza.rb → xmppstanza.rb} +17 -29
  72. data/setup.rb +1 -0
  73. data/test/bytestreams/tc_ibb.rb +8 -8
  74. data/test/dataforms/tc_data.rb +81 -0
  75. data/test/lib/clienttester.rb +20 -17
  76. data/test/muc/tc_muc_mucclient.rb +48 -23
  77. data/test/muc/tc_muc_simplemucclient.rb +7 -4
  78. data/test/muc/tc_mucowner.rb +50 -0
  79. data/test/pubsub/tc_helper.rb +227 -0
  80. data/test/roster/tc_helper.rb +181 -55
  81. data/test/roster/tc_iqqueryroster.rb +33 -0
  82. data/test/roster/tc_xroster.rb +6 -3
  83. data/test/rpc/tc_helper.rb +84 -0
  84. data/test/tc_callbacks.rb +2 -1
  85. data/test/tc_class_names.rb +9 -1
  86. data/test/tc_error.rb +1 -0
  87. data/test/tc_iq.rb +13 -12
  88. data/test/tc_message.rb +1 -0
  89. data/test/tc_presence.rb +1 -0
  90. data/test/tc_rexml.rb +1 -1
  91. data/test/tc_stream.rb +147 -102
  92. data/test/tc_streamComponent.rb +94 -0
  93. data/test/tc_streamError.rb +67 -29
  94. data/test/tc_streamSend.rb +1 -1
  95. data/test/tc_xmppstanza.rb +125 -0
  96. data/test/ts_xmpp4r.rb +37 -28
  97. data/test/version/tc_helper.rb +14 -0
  98. data/test/version/tc_iqqueryversion.rb +4 -3
  99. metadata +163 -123
  100. data/data/doc/xmpp4r/examples/basic/echo_nonthreaded.rb +0 -32
  101. data/lib/callbacks.rb +0 -122
  102. data/test/tc_streamThreaded.rb +0 -168
  103. data/test/tc_xmlstanza.rb +0 -76
@@ -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/dataforms'
5
6
  require 'xmpp4r/muc/x/muc'
6
7
  require 'xmpp4r/muc/x/mucuserinvite'
7
8
  require 'xmpp4r/muc/x/mucuseritem'
9
+ require 'xmpp4r/muc/iq/mucowner'
8
10
  require 'xmpp4r/muc/helper/mucbrowser'
9
11
  require 'xmpp4r/muc/helper/mucclient'
10
12
  require 'xmpp4r/muc/helper/simplemucclient'
@@ -94,6 +94,11 @@ module Jabber
94
94
  # but all join-failures should be type='error'
95
95
  elsif r.from == jid and r.kind_of?(Presence) and r.type != :unavailable
96
96
  # Our own presence reflected back - success
97
+ if r.x(XMUCUser) and (i = r.x(XMUCUser).items.first)
98
+ @affiliation = i.affiliation # we're interested in if it's :owner
99
+ @role = i.role # :moderator ?
100
+ end
101
+
97
102
  handle_presence(r, false)
98
103
  true
99
104
  else
@@ -235,7 +240,7 @@ module Jabber
235
240
  # If stanza is a Jabber::Message, <tt>stanza.type</tt> will be
236
241
  # automatically set to :groupchat if directed to room or :chat
237
242
  # if directed to participant.
238
- # stanza:: [XMLStanza] to send
243
+ # stanza:: [XMPPStanza] to send
239
244
  # to:: [String] Stanza destination recipient, or room if +nil+
240
245
  def send(stanza, to=nil)
241
246
  if stanza.kind_of? Message
@@ -377,6 +382,50 @@ module Jabber
377
382
  @stream.delete_presence_callback(self)
378
383
  @stream.delete_message_callback(self)
379
384
  end
385
+
386
+ public
387
+ def owner?
388
+ @affiliation == :owner
389
+ end
390
+
391
+ def configure(options={})
392
+ raise 'You are not the owner' unless owner?
393
+
394
+ iq = Iq.new(:get, jid)
395
+ iq.to = @jid
396
+ iq.from = @my_jid
397
+ iq.add(IqQueryMUCOwner.new)
398
+
399
+ fields = []
400
+
401
+ answer = @stream.send_with_id(iq)
402
+ raise "Configuration not possible for this room" unless answer.query && answer.query.x(XData)
403
+
404
+ answer.query.x(XData).fields.each { |field|
405
+ if (var = field.attributes['var'])
406
+ fields << var
407
+ end
408
+ }
409
+
410
+
411
+ # fill out the reply form
412
+ iq = Iq.new(:set, jid)
413
+ iq.to = @jid
414
+ iq.from = @my_jid
415
+ query = IqQueryMUCOwner.new
416
+ form = Dataforms::XData.new
417
+ form.type = :submit
418
+ options.each do |var, values|
419
+ field = Dataforms::XDataField.new
420
+ values = [values] unless values.is_a?(Array)
421
+ field.var, field.values = var, values
422
+ form.add(field)
423
+ end
424
+ query.add(form)
425
+ iq.add(query)
426
+
427
+ @stream.send_with_id(iq)
428
+ end
380
429
  end
381
430
  end
382
431
  end
@@ -155,9 +155,9 @@ module Jabber
155
155
  # recipients:: [Hash] of [JID] => [String] Reason
156
156
  def invite(recipients)
157
157
  msg = Message.new
158
- x = msg.add(XMucUser.new)
158
+ x = msg.add(XMUCUser.new)
159
159
  recipients.each { |jid,reason|
160
- x.add(XMucUserInvite.new(jid, reason))
160
+ x.add(XMUCUserInvite.new(jid, reason))
161
161
  }
162
162
  send(msg)
163
163
  end
@@ -0,0 +1,11 @@
1
+ require 'xmpp4r/x'
2
+
3
+ module Jabber
4
+ module MUC
5
+ class IqQueryMUCOwner < IqQuery
6
+ name_xmlns 'query', 'http://jabber.org/protocol/muc#owner'
7
+
8
+ include XParent
9
+ end
10
+ end
11
+ end
@@ -13,13 +13,7 @@ module Jabber
13
13
  #
14
14
  # See JEP-0045 for details
15
15
  class XMUC < X
16
- ##
17
- # Initialize an <x/> element
18
- # and set namespace to http://jabber.org/protocol/muc
19
- def initialize
20
- super
21
- add_namespace('http://jabber.org/protocol/muc')
22
- end
16
+ name_xmlns 'x', 'http://jabber.org/protocol/muc'
23
17
 
24
18
  ##
25
19
  # Text content of the <tt><password/></tt> element
@@ -45,26 +39,7 @@ module Jabber
45
39
  #
46
40
  # See JEP-0058 for details
47
41
  class XMUCUser < X
48
- ##
49
- # Initialize an <x/> element
50
- # and set namespace to http://jabber.org/protocol/muc#user
51
- def initialize
52
- super
53
- add_namespace('http://jabber.org/protocol/muc#user')
54
- end
55
-
56
- ##
57
- # Add a children element,
58
- # will be imported to [XMUCUserItem] if name is "item"
59
- def typed_add(element)
60
- if element.kind_of?(REXML::Element) && (element.name == 'item')
61
- super(XMUCUserItem::new.import(element))
62
- elsif element.kind_of?(REXML::Element) && (element.name == 'invite')
63
- super(XMUCUserInvite::new.import(element))
64
- else
65
- super(element)
66
- end
67
- end
42
+ name_xmlns 'x', 'http://jabber.org/protocol/muc#user'
68
43
 
69
44
  ##
70
45
  # Retrieve the three-digit code in
@@ -91,8 +66,5 @@ module Jabber
91
66
  res
92
67
  end
93
68
  end
94
-
95
- X.add_namespaceclass('http://jabber.org/protocol/muc', XMUC)
96
- X.add_namespaceclass('http://jabber.org/protocol/muc#user', XMUCUser)
97
69
  end
98
70
  end
@@ -4,9 +4,11 @@
4
4
 
5
5
  module Jabber
6
6
  module MUC
7
- class XMUCUserInvite < REXML::Element
7
+ class XMUCUserInvite < XMPPElement
8
+ name_xmlns 'invite', 'http://jabber.org/protocol/muc#user'
9
+
8
10
  def initialize(to=nil, reason=nil)
9
- super('invite')
11
+ super()
10
12
  set_to(to)
11
13
  set_reason(reason)
12
14
  end
@@ -4,9 +4,11 @@
4
4
 
5
5
  module Jabber
6
6
  module MUC
7
- class XMUCUserItem < REXML::Element
7
+ class XMUCUserItem < XMPPElement
8
+ name_xmlns 'item', 'http://jabber.org/protocol/muc#user'
9
+
8
10
  def initialize(affiliation=nil, role=nil, jid=nil)
9
- super('item')
11
+ super()
10
12
  set_affiliation(affiliation)
11
13
  set_role(role)
12
14
  set_jid(jid)
@@ -2,15 +2,19 @@
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/xmlstanza'
5
+ require 'xmpp4r/xmppstanza'
6
6
  require 'xmpp4r/x'
7
7
 
8
8
  module Jabber
9
9
  ##
10
10
  # The presence class is used to construct presence messages to
11
11
  # send to the Jabber service.
12
- class Presence < XMLStanza
12
+ class Presence < XMPPStanza
13
+ name_xmlns 'presence', 'jabber:client'
14
+ force_xmlns true
15
+
13
16
  include Comparable
17
+ include XParent
14
18
 
15
19
  ##
16
20
  # Create presence stanza
@@ -18,31 +22,12 @@ module Jabber
18
22
  # status:: [String] Initial status message
19
23
  # priority:: [Fixnum] Initial priority value
20
24
  def initialize(show=nil, status=nil, priority=nil)
21
- super("presence")
25
+ super()
22
26
  set_show(show) if show
23
27
  set_status(status) if status
24
28
  set_priority(priority) if priority
25
29
  end
26
30
 
27
- ##
28
- # Add an element to the presence stanza
29
- # * <x/> elements are converted to [X]
30
- # element:: [REXML::Element] to add
31
- def typed_add(element)
32
- if element.kind_of?(REXML::Element) && (element.name == 'x')
33
- super(X::import(element))
34
- else
35
- super(element)
36
- end
37
- end
38
-
39
- ##
40
- # Create a new presence from a stanza
41
- # result:: [Presence] Imported XMLStanza
42
- def Presence.import(xmlstanza)
43
- Presence::new.import(xmlstanza)
44
- end
45
-
46
31
  ##
47
32
  # Get type of presence
48
33
  #
@@ -93,19 +78,6 @@ module Jabber
93
78
  self
94
79
  end
95
80
 
96
- ##
97
- # Get the first <x/> element in this stanza, or nil if none found.
98
- # namespace:: [String] Optional, find the first <x/> element having this xmlns
99
- # result:: [REXML::Element] or nil
100
- def x(namespace=nil)
101
- each_element('x') { |x|
102
- if namespace.nil? or namespace == x.namespace
103
- return x
104
- end
105
- }
106
- nil
107
- end
108
-
109
81
  ##
110
82
  # Get Availability Status (RFC3921 - 5.2)
111
83
  # result:: [Symbol] or [Nil] Valid values according to RFC3921:
@@ -0,0 +1 @@
1
+ require 'xmpp4r/pubsub/helper/servicehelper'
@@ -0,0 +1,174 @@
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/discovery'
6
+
7
+ module Jabber
8
+ module PubSub
9
+ class NodeBrowser
10
+ ##
11
+ # Initialize a new NodeBrowser
12
+ # new(stream,pubsubservice)
13
+ # stream:: [Jabber::Stream]
14
+ def initialize(stream)
15
+ @stream = stream
16
+ end
17
+
18
+ ##
19
+ # Retrive the nodes
20
+ # Throws an ErrorException when receiving
21
+ # <tt><iq type='error'/></tt>
22
+ # jid:: [JID] Target entity (set only domain!)
23
+ # return:: [Array] of [String] or [nil]
24
+ def nodes(jid)
25
+ iq = Iq.new(:get,jid)
26
+ iq.from = @stream.jid
27
+ iq.add(Discovery::IqQueryDiscoItems.new)
28
+ nodes = []
29
+ err = nil
30
+ @stream.send_with_id(iq) { |answer|
31
+ if answer.type == :result
32
+ answer.query.each_element('item') { |item|
33
+ nodes.push(item.node)
34
+ }
35
+ true
36
+ elsif answer.type == :error
37
+ err = answer.error
38
+ true
39
+ else
40
+ false
41
+ end
42
+ }
43
+ return nodes
44
+ end
45
+
46
+ ##
47
+ # Retrive the nodes with names
48
+ # Throws an ErrorExeption when reciving
49
+ # <tt><iq type='error'/></tt>
50
+ # jid:: [Jabber::JID] Target entity (set only domain!)
51
+ # return:: [Array] of [Hash] with keys 'node' => [String] and 'name' => [String] or [nil]
52
+ def nodes_names(jid)
53
+ iq = Iq.new(:get,jid)
54
+ iq.from = @stream.jid
55
+ iq.add(Discovery::IqQueryDiscoItems.new)
56
+ nodes = []
57
+ err = nil
58
+ @stream.send_with_id(iq) { |answer|
59
+ if answer.type == :result
60
+ answer.query.each_element('item') { |item|
61
+ nodes.push( {'node' => item.node,'name' => item.iname } )
62
+ }
63
+ true
64
+ elsif answer.type == :error
65
+ err = answer.error
66
+ true
67
+ else
68
+ false
69
+ end
70
+ }
71
+ return nodes
72
+ end
73
+
74
+
75
+ ##
76
+ # Retrive the items from a node
77
+ # Throws an ErrorExeption when reciving
78
+ # <tt><iq type='error'/></tt>
79
+ # jid:: [Jabber::JID] Target entity (set only domain!)
80
+ # node:: [String]
81
+ # return:: [Array] of [Hash] with keys 'name' => [String] and 'jid' => [Jabber::JID]
82
+ def items(jid,node)
83
+ iq = Iq.new(:get,jid)
84
+ iq.from = @stream.jid
85
+ discoitems = Discovery::IqQueryDiscoItems.new
86
+ discoitems.node = node
87
+ iq.add(discoitems)
88
+ items = []
89
+ err = nil
90
+ @stream.send_with_id(iq) { |answer|
91
+ if answer.type == :result
92
+ answer.query.each_element('item') { |item|
93
+ items.push( {'jid' => item.jid,'name' => item.iname } )
94
+ }
95
+ true
96
+ elsif answer.type == :error
97
+ err = answer.error
98
+ true
99
+ else
100
+ false
101
+ end
102
+ }
103
+ return items
104
+ end
105
+
106
+ ##
107
+ # get disco info for a node
108
+ # jid:: [Jabber::JID]
109
+ # node:: [String]
110
+ # return:: [Hash] with possible keys type:: [String] ,category:: [String],features:: [Array] of feature, nodeinformation:: [Jabber::XData]
111
+ # check http://www.xmpp.org/extensions/xep-0060.html#entity for more infos
112
+
113
+ # this is only for a xep <-> nodebrowser.rb understanding
114
+ alias get_metadata get_info
115
+
116
+ def get_info(jid,node)
117
+ iq = Iq.new(:get,jid)
118
+ iq.from = @stream.jid
119
+ discoinfo = Discovery::IqQueryDiscoInfo.new
120
+ discoinfo.node = node
121
+ iq.add(discoinfo)
122
+ info = {}
123
+ @stream.send_with_id(iq) { |answer|
124
+ if answer.type == :result
125
+
126
+ identity = answer.query.identity
127
+ info['type'] = identity.type
128
+ info['category'] = identity.category
129
+
130
+ info['features'] = answer.query.features
131
+
132
+ # i think its not needed - if you think so then delete it
133
+ # answer.query.each_element('identity') { |identity|
134
+ # info['type'] = identity.type
135
+ # info['category'] = identity.category
136
+ # }
137
+ #
138
+ # features = []
139
+ # answer.query.each_element('feature') { |feature|
140
+ # features.push(feature)
141
+ # }
142
+ # info['features'] = features
143
+ #
144
+ answer.query.each_element('x') { |x|
145
+ info['nodeinformation'] = x
146
+ }
147
+ end
148
+ }
149
+ return info
150
+ end
151
+
152
+ ##
153
+ # get type of node
154
+ # jid:: [Jabber::JID]
155
+ # node:: [String]
156
+ #
157
+ def type(jid,node)
158
+ info = get_info(jid,node)
159
+ return info['type']
160
+ end
161
+
162
+ ##
163
+ # get category of node
164
+ # jid:: [Jabber::JID]
165
+ # node:: [String]
166
+ #
167
+ def category(jid,node)
168
+ info = get_info(jid,node)
169
+ return info['category']
170
+ end
171
+
172
+ end #class
173
+ end #module
174
+ end #module
@@ -0,0 +1,153 @@
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
+ # For a documentation of the retunvalues please look into the
6
+ # documentation of [Jabber::PubSub::ServiceHelper]
7
+ # This class is only a wrapper around [Jabber::PubSub::ServiceHelper]
8
+ #
9
+
10
+
11
+ require 'xmpp4r/pubsub/helper/servicehelper'
12
+ require 'xmpp4r/pubsub/helper/nodebrowser'
13
+
14
+ module Jabber
15
+ module PubSub
16
+ class NodeHelper < ServiceHelper
17
+
18
+ attr_reader :nodename
19
+ attr_reader :name
20
+ attr_reader :jiod
21
+ attr_reader :my_subscriptions
22
+ ##
23
+ # creates a new node
24
+ # new(client,service,nodename)
25
+ # stream:: [Jabber::Stream]
26
+ # jid:: [String] (jid of the pubsub service)
27
+ # nodename:: [String]
28
+ def initialize(stream,jid,nodename=nil,create_if_not_exist=true)
29
+ super(stream,jid)
30
+ @nodename = nodename
31
+ @jid = jid
32
+ @stream = client
33
+
34
+ get_subscriptions
35
+
36
+ if create_if_not_exist and not node_exist?
37
+ # if no nodename is given a instant node will created
38
+ # (if the service supports instant nodes)
39
+ @nodename = create_node
40
+ end
41
+ end
42
+
43
+ ##
44
+ # creates the node
45
+ # create(configuration=nil)
46
+ # configuration:: [Jabber::XData]
47
+ def create_node(configuration=nil)
48
+ create(@nodename,configuration)
49
+ end
50
+
51
+ ##
52
+ # get the configuration of the node
53
+ # get_configuration(configuration=nil)
54
+ # configuration:: [Jabber::XData]
55
+ def get_configuration(subid=nil)
56
+ get_options(@nodename,subid)
57
+ end
58
+
59
+ ##
60
+ # set the configuration of the node
61
+ # set_configuration(configuration=nil)
62
+ # configuration:: [Jabber::XData]
63
+ # subid:: [String] default is nil
64
+ def set_configuration(configuration,subid=nil)
65
+ set_options(@nodename,configuration,subid)
66
+ end
67
+
68
+ ##
69
+ # deletes the node
70
+ # delete
71
+ def delete_node
72
+ delete(@nodename)
73
+ end
74
+
75
+ ##
76
+ # publishing content on this node
77
+ # publish_content(items)
78
+ # items:: [REXML::Element]
79
+ def publish_content(items)
80
+ publish(@nodename,items)
81
+ end
82
+
83
+ ##
84
+ # gets all items from the node
85
+ # get_all_items
86
+ def get_all_items
87
+ items(@nodename)
88
+ end
89
+
90
+ ##
91
+ # get a count of items
92
+ # get_items(count)
93
+ # count:: [Fixnum]
94
+ def get_items(count)
95
+ items(@nodename,count)
96
+ end
97
+
98
+ ##
99
+ # get all node affiliations
100
+ # get_affiliations
101
+ def get_affiliations
102
+ affiliations
103
+ end
104
+
105
+ ##
106
+ # get all subscriptions on this node
107
+ # get_subscriptions
108
+ def get_subscriptions
109
+ subscriptions(@nodename)
110
+ end
111
+
112
+ ##
113
+ # get all subscribers subscribed on this node
114
+ # get_subscribers
115
+ def get_subscribers
116
+ @subscriptions = subscribers(@nodename)
117
+ end
118
+
119
+ ##
120
+ # subscribe to this node
121
+ # do_subscribe
122
+ def do_subscribe
123
+ subscribe(@nodename)
124
+ get_subscriptions
125
+ end
126
+
127
+ ##
128
+ # unsubscribe from this node
129
+ # do_unsubscribe(subid = nil)
130
+ # subid:: [String]
131
+ def do_unsubscribe(subid)
132
+ unsubscribe(@nodename,subid)
133
+ end
134
+
135
+ ##
136
+ # purge all items from this node
137
+ # purge_items
138
+ def purge_items
139
+ purge(@nodename)
140
+ end
141
+
142
+ private
143
+
144
+ def node_exist?
145
+ nodebrowser = PubSub::NodeBrowser.new(@stream)
146
+ nodebrowser.nodes.include?(nodename)
147
+ end
148
+ def disco_info
149
+ end
150
+
151
+ end #class
152
+ end #module
153
+ end #module