File: subscription_config.rb

package info (click to toggle)
ruby-xmpp4r 0.5.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,384 kB
  • sloc: ruby: 17,382; xml: 74; sh: 12; makefile: 4
file content (67 lines) | stat: -rw-r--r-- 1,786 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://xmpp4r.github.io

require 'xmpp4r/xmppelement'
require 'xmpp4r/pubsub/children/configuration'
require 'xmpp4r/pubsub/iq/pubsub'

module Jabber
  module PubSub
    ##
    # SubscriptionConfig
    #
    # An <options> XMPP element, see example 57 in
    # http://www.xmpp.org/extensions/xep-0060.html#subscriber-configure-success
    class SubscriptionConfig < Configuration
      name_xmlns 'options', NS_PUBSUB

      ##
      # Construct a new Options stanza
      # node:: [String] the node to which this subscription applies
      # jid:: [String] or [Jabber::JID] the jid that holds the subscription
      # options:: [Hash] the configuration for this subscription
      # subid:: [String] (optional) subscription id
      def initialize(node = nil, jid = nil, options = nil, subid = nil)
        super()

        self.node = node
        self.jid = jid
        self.options = options
        self.subid = subid
      end

      ##
      # set the 'jid' attribute of this stanza
      # jid:: [Jabber::JID] or [String] the jid owning the subscription
      def jid=(jid)
        attributes['jid'] = jid.to_s
      end

      ##
      # get the 'jid' attribute for this stanza
      def jid
        attributes['jid'] ? Jabber::JID.new(attributes['jid']) : nil
      end

      ##
      # set the 'subid' attribute
      # subid:: [String] the subscription id
      def subid=(subid)
        attributes['subid'] = subid
      end

      ##
      # get the 'subid' attribute
      def subid
        attributes['subid']
      end

      private

      def form_type
        'http://jabber.org/protocol/pubsub#subscribe_options'
      end
    end
  end
end